:root {
  --ink: #12233f;
  --muted: #667795;
  --line: #d7e5f7;
  --panel: rgba(255,255,255,.86);
  --blue: #1457b8;
  --cyan: #32bde8;
  --red: #d64545;
  --green: #0e9f6e;
  --shadow: 0 18px 50px rgba(22, 78, 150, .14);
  --left-width: clamp(240px, 22vw, 360px);
  --right-width: clamp(300px, 26vw, 460px);
}
* { box-sizing: border-box; }
body {
  height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: "LINE Seed JP", system-ui, sans-serif;
  background: linear-gradient(135deg, #f7fbff, #e9f5ff 48%, #fafdff);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.app {
  display: grid;
  grid-template-areas: "top top top top top" "left resize-left main resize-right right";
  grid-template-columns: var(--left-width) 6px minmax(360px, 1fr) 6px var(--right-width);
  grid-template-rows: 66px minmax(0, 1fr);
  height: 100dvh;
  gap: 10px;
  padding: 12px;
  max-width: 100vw;
  overflow: hidden;
}
.topbar, .left, .main, .right {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  border-radius: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; white-space: nowrap; }
.brand span { white-space: nowrap; }
.brand span, .account span, .scope, .section-title, .card p, .meta { color: var(--muted); font-size: 12px; }
.logo, .avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
}
.scope { flex: 1; }
.left { grid-area: left; display: grid; grid-template-rows: auto auto 1fr auto; gap: 14px; padding: 16px; border-radius: 22px; min-height: 0; min-width: 0; }
.main { grid-area: main; border-radius: 22px; min-width: 0; overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.right { grid-area: right; border-radius: 22px; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.resize-handle {
  align-self: stretch;
  border-radius: 999px;
  cursor: col-resize;
  background: rgba(20, 87, 184, .12);
  transition: background .15s ease;
}
.resize-handle:hover, .resize-handle.dragging { background: rgba(20, 87, 184, .34); }
.resize-left { grid-area: resize-left; }
.resize-right { grid-area: resize-right; }
body.resizing { user-select: none; cursor: col-resize; }
.right header { padding: 16px; border-bottom: 1px solid var(--line); }
.right h2 { margin: 0 0 4px; font-size: 16px; }
.right p { margin: 0; color: var(--muted); font-size: 12px; }
.section { min-height: 0; }
.section.fill { overflow: auto; }
.section-title { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.section-title > div { display: flex; gap: 6px; min-width: 0; flex-wrap: wrap; justify-content: flex-start; }
select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}
select, input { height: 38px; padding: 0 11px; }
textarea { min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.project-list, .mini-list, .list, .ai-cards { display: grid; gap: 10px; }
.project-item, .mini-item, .card, .ai-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}
.project-item { color: var(--muted); min-width: 0; text-align: center; overflow-wrap: anywhere; }
.project-item.active { color: var(--ink); box-shadow: inset 4px 0 0 var(--blue); background: #f4faff; }
.account { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); }
.account > div { min-width: 0; }
.account strong, .account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .primary, .ghost, .danger, .icon {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.icon { min-height: 32px; padding: 0 10px; font-size: 12px; }
.tabs button { background: transparent; color: var(--muted); }
.tabs button.active, .primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--cyan)); }
.ghost, .icon { color: var(--blue); background: #eef6ff; border: 1px solid var(--line); }
.danger { color: var(--red); background: #fff0f0; border: 1px solid #ffd4d4; }
.view { overflow: auto; padding: 16px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.toolbar h1 { font-size: 20px; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { display: grid; gap: 8px; }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.card h2 { margin: 0; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; background: #eaf4ff; color: var(--blue); font-size: 11px; font-weight: 800; }
.badge.done { color: var(--green); background: #e8f8f1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail { white-space: pre-wrap; line-height: 1.7; }
.ai-cards { align-content: start; padding: 16px; overflow: auto; }
.ai-card p { white-space: pre-wrap; line-height: 1.7; }
.chat-message {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  overflow-wrap: anywhere;
}
.chat-message.user {
  margin-left: 18px;
  border-color: #bfdbfe;
  background: #eef6ff;
}
.chat-message.assistant {
  margin-right: 18px;
}
.chat-message strong { font-size: 12px; color: var(--blue); }
.chat-message p { margin: 0; white-space: pre-wrap; line-height: 1.65; }
.composer { display: grid; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #f7fbff; min-height: 0; }
.composer textarea { min-height: 76px; max-height: 132px; }
.composer .primary { width: 100%; }
.composer .primary:disabled { cursor: wait; opacity: .72; }
dialog { width: min(720px, calc(100vw - 32px)); border: 0; border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(9, 24, 50, .35); }
.dialog-body { display: grid; gap: 10px; margin: 14px 0; }
.dialog-status {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef6ff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.dialog-status[hidden] { display: none; }
.dialog-status::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #9fc8ff;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.dialog-status.error {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #b42318;
}
.dialog-status.error::before { display: none; }
dialog.is-busy { cursor: wait; }
dialog.is-busy input,
dialog.is-busy textarea,
dialog.is-busy select,
dialog.is-busy button { cursor: wait; }
@keyframes spin { to { transform: rotate(360deg); } }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
menu { display: flex; justify-content: end; gap: 8px; padding: 0; margin: 0; }
@media (max-width: 900px) {
  body { height: auto; min-height: 100dvh; overflow-x: hidden; overflow-y: auto; }
  .app {
    grid-template-areas:
      "top"
      "main"
      "right"
      "left";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(520px, auto) minmax(420px, auto) auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .resize-handle { display: none; }
  .topbar { min-height: 66px; }
  .right { min-height: 460px; }
  .left { min-height: 520px; }
}
@media (max-width: 720px) {
  .app { gap: 8px; padding: 8px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 12px; }
  .scope { flex-basis: 100%; }
  .top-actions { width: 100%; }
  .top-actions .primary { width: 100%; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .grid2 { grid-template-columns: 1fr; }
}
