:root {
  color-scheme: dark;
  --bg: #120f10;
  --bg-2: #1a1412;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 218, 184, 0.15);
  --border-strong: rgba(255, 218, 184, 0.26);
  --text: #fff8f2;
  --muted: #b7a59a;
  --soft: #78675f;
  --green: #ff7a3d;
  --cyan: #ffd166;
  --purple: #3dd6c6;
  --amber: #f6c85f;
  --coral: #ff5d7a;
  --ink: #24100a;
  --teal: #3dd6c6;
  --blue: #6bbcff;
  --rose: #ff8fb1;
  --violet: #a891ff;
  --red: var(--coral);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --surface: rgba(255, 255, 255, 0.075);
  --surface-2: rgba(255, 255, 255, 0.1);
  --surface-3: rgba(255, 255, 255, 0.13);
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.38);
  --small-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #171112 0%, var(--bg) 42%, #080707 100%),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 218, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 218, 184, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, rgba(255, 122, 61, 0.09), transparent 42%, rgba(61, 214, 198, 0.055));
  background-size: 42px 42px, 42px 42px, 100% 100%;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 88%);
}

body:not(.is-authed) .appbar,
body:not(.is-authed) main {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(38px, 9svh, 92px) 24px 28px;
  overflow: hidden auto;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 122, 61, 0.22), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(61, 214, 198, 0.18), transparent 34%),
    linear-gradient(135deg, #171112, #24100a 46%, #0b1414);
}

body.is-authed .login-screen {
  display: none;
}

.login-screen::before {
  position: absolute;
  inset: -28%;
  content: "";
  background:
    conic-gradient(from 120deg, rgba(255, 122, 61, 0.18), rgba(255, 209, 102, 0.22), rgba(61, 214, 198, 0.16), rgba(255, 122, 61, 0.18));
  filter: blur(34px);
  animation: loginFlow 14s linear infinite;
}

.login-flow span {
  position: absolute;
  width: 36vw;
  height: 36vw;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 122, 61, 0.2), rgba(61, 214, 198, 0.12));
  filter: blur(18px);
  animation: loginDrift 12s ease-in-out infinite alternate;
}

.login-flow span:nth-child(1) { left: -8vw; top: 10vh; }
.login-flow span:nth-child(2) { right: -10vw; top: -8vh; animation-delay: -4s; }
.login-flow span:nth-child(3) { left: 35vw; bottom: -16vh; animation-delay: -7s; }

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 218, 184, 0.26);
  border-radius: 24px;
  background: rgba(18, 13, 13, 0.72);
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(26px);
}

.login-card h1 {
  font-size: 36px;
}

.login-copy {
  color: #e8cbb9;
  line-height: 1.65;
}

.login-error {
  min-height: 20px;
  color: #ffb1a5;
  font-size: 13px;
}

.login-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-meta span {
  padding: 7px 10px;
  border: 1px solid rgba(255, 218, 184, 0.18);
  border-radius: 999px;
  color: #e8cbb9;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0) scale(0.985);
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1;
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 18px;
}

.appbar,
main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.appbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(220px, 0.55fr) minmax(420px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  margin-top: max(14px, env(safe-area-inset-top));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(18, 13, 13, 0.82);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px);
}

.logout-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: #f3ddcf;
  background: rgba(255, 255, 255, 0.07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 850;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 0 28px rgba(255, 122, 61, 0.34);
  font-weight: 900;
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
small {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.tab,
.tool-button,
.primary-button,
.quick-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  backdrop-filter: blur(20px);
}

.tab {
  min-height: 38px;
  min-width: 70px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #e0c9ba;
  font-size: 14px;
  font-weight: 760;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.11);
}

.tab.is-active {
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 36px rgba(255, 122, 61, 0.2);
}

main {
  padding: 0 0 58px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: panelIn 0.32s both;
}

.workspace-top {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  align-items: center;
  gap: 22px;
  padding: 58px 4px 24px;
}

.control-strip {
  display: flex;
  min-height: 380px;
  flex-direction: column;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.control-strip h1 {
  max-width: 760px;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.98;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.status-line span,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #ead8cc;
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 760;
}

.status-line span::before,
.status-pill::before {
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 14px rgba(255, 122, 61, 0.5);
  content: "";
  transform: rotate(45deg);
}

.status-line span:nth-child(2)::before {
  background: var(--purple);
  box-shadow: 0 0 14px rgba(61, 214, 198, 0.48);
}

.status-pill.is-ok {
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.status-pill.is-warn {
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--amber), #ffe7a3);
}

.status-pill.is-error {
  color: var(--text);
  border-color: transparent;
  background: linear-gradient(135deg, var(--coral), #ff9bb0);
}

.method-map {
  display: block;
  width: 100%;
  aspect-ratio: 920 / 380;
  border: 1px solid var(--border);
  border-radius: 26px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035)),
    rgba(21, 15, 14, 0.62);
  box-shadow: var(--shadow);
  object-fit: contain;
  overflow: hidden;
  backdrop-filter: blur(28px);
}

.stage-board,
.course-grid,
.module-grid,
.asset-grid,
.source-note-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.stage-board {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.course-grid,
.asset-grid,
.source-note-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stage-card,
.course-card,
.module-card,
.asset-card,
.source-note,
.section-head,
.agent-panel,
.chat-workspace,
.prompt-form,
.prompt-output,
.archive-table-wrap {
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.045)),
    rgba(21, 15, 14, 0.68);
  box-shadow: var(--small-shadow);
  backdrop-filter: blur(22px);
}

.stage-card,
.course-card,
.module-card,
.asset-card,
.source-note {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.stage-card::after,
.course-card::after,
.module-card::after,
.asset-card::after,
.source-note::after {
  position: absolute;
  inset: auto 14px 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent, var(--green)), transparent);
  opacity: 0.45;
}

.stage-card {
  min-height: 178px;
  padding: 16px;
}

.course-card,
.module-card,
.asset-card,
.source-note {
  min-height: 168px;
  padding: 18px;
}

.stage-card span,
.course-card span,
.module-card span,
.asset-card span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent, var(--green)), var(--cyan));
  box-shadow: 0 12px 30px rgba(255, 122, 61, 0.12);
  font-size: 12px;
  font-weight: 850;
}

.course-card p,
.asset-card p,
.source-note p {
  margin-top: 10px;
  color: #c3afa4;
  line-height: 1.62;
}

.course-card p,
.source-note p {
  max-width: 34ch;
}

.source-note {
  min-height: 148px;
  --accent: var(--cyan);
}

.source-note h3 {
  color: #fff2e8;
  font-size: 17px;
}

.stage-card ul,
.module-card ul,
.asset-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #ead8cc;
  line-height: 1.58;
}

.section-head {
  margin: 32px 0 16px;
  padding: 20px;
}

.section-head p,
.chat-head p {
  margin-top: 10px;
  color: #c3afa4;
  line-height: 1.62;
}

.archive-table-wrap {
  overflow-x: auto;
}

.archive-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 10px;
  padding: 0 8px;
}

.archive-heading h3 {
  font-size: 22px;
}

.archive-heading span {
  color: #c3afa4;
  font-size: 14px;
  font-weight: 760;
}

.archive-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.archive-table th,
.archive-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.archive-table th {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.archive-table td {
  color: #ead8cc;
}

.agent-layout {
  display: grid;
  grid-template-columns: minmax(248px, 280px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 26px;
}

body[data-view="agent"] main {
  padding-bottom: 18px;
}

body[data-view="agent"] .agent-layout {
  height: min(720px, calc(100vh - 118px));
  min-height: 560px;
  margin-top: 14px;
}

.agent-panel {
  padding: 14px;
  min-height: 0;
  overflow: auto;
  font-size: 13px;
}

label {
  display: grid;
  gap: 8px;
  color: #f0ded2;
  font-size: 13px;
  font-weight: 760;
}

label + label,
.file-ledger,
.history-panel {
  margin-top: 14px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  outline: none;
  backdrop-filter: blur(20px);
}

select,
input {
  min-height: 48px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(255, 122, 61, 0.62);
  box-shadow: 0 0 0 3px rgba(255, 122, 61, 0.09);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.quick-button {
  min-height: 48px;
  padding: 7px 8px;
  border-radius: 12px;
  color: #ead8cc;
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}

.quick-button:hover {
  border-color: var(--accent, var(--green));
  background: rgba(255, 255, 255, 0.11);
}

.ledger-head,
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ledger-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-button {
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #e5d0c2;
}

.danger-button {
  color: #ffd0c9;
  border-color: rgba(255, 93, 122, 0.34);
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 36px rgba(255, 122, 61, 0.2);
  font-weight: 850;
}

.agent-note {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: #e9d7ca;
  background: rgba(255, 255, 255, 0.055);
}

.agent-note strong,
.agent-note span,
.agent-note small {
  display: block;
}

.agent-note strong {
  color: #fff4ec;
  font-size: 13px;
}

.agent-note span,
.agent-note small {
  color: var(--muted);
  line-height: 1.45;
}

.file-list {
  display: grid;
  gap: 8px;
  max-height: 150px;
  margin-top: 10px;
  overflow: auto;
}

.history-panel {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-head h3 {
  color: #fff4ec;
  font-size: 15px;
}

.run-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  margin-top: 10px;
  overflow: auto;
}

.run-item {
  position: relative;
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 78px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.run-item::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--green), var(--cyan));
  content: "";
}

.run-item span {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.run-item strong {
  color: #fff4ec;
  font-size: 13px;
  line-height: 1.35;
}

.run-item small {
  color: var(--muted);
  font-size: 12px;
}

.file-space-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.file-space {
  position: relative;
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.055);
  overflow: hidden;
  text-align: left;
}

.file-space::before {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 28px color-mix(in srgb, var(--accent), transparent 45%);
  content: "";
  transform: rotate(45deg);
}

.file-space::after {
  position: absolute;
  right: -38px;
  bottom: -58px;
  width: 98px;
  height: 98px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.48;
  content: "";
}

.file-space span,
.file-space strong,
.file-space small {
  display: block;
  position: relative;
  z-index: 1;
}

.file-space span {
  font-size: 13px;
  font-weight: 850;
}

.file-space strong {
  margin-top: 9px;
  color: var(--accent);
  font-size: 30px;
  line-height: 0.9;
}

.file-space small {
  margin-top: 8px;
  color: #c3afa4;
  font-size: 12px;
  line-height: 1.35;
}

.file-space.is-active {
  border-color: var(--accent);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent), transparent 86%), rgba(255, 255, 255, 0.05)),
    rgba(255, 255, 255, 0.055);
}

.file-item,
.empty,
.message {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
}

.file-item {
  padding: 10px;
  border-color: color-mix(in srgb, var(--accent), var(--border) 72%);
}

.file-item b,
.file-item small {
  display: block;
}

.file-item small {
  margin-top: 4px;
  color: var(--muted);
}

.empty {
  padding: 12px;
  color: var(--muted);
}

.chat-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}

.chat-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  min-height: 0;
  overflow: hidden auto;
  scrollbar-color: rgba(255, 122, 61, 0.58) rgba(255, 255, 255, 0.08);
}

.message {
  max-width: min(1040px, 98%);
  min-width: 0;
  padding: 13px;
}

.message.user {
  justify-self: end;
  background: linear-gradient(145deg, rgba(107, 188, 255, 0.14), rgba(255, 255, 255, 0.055));
}

.message.assistant {
  justify-self: start;
  background: linear-gradient(145deg, rgba(255, 122, 61, 0.11), rgba(255, 255, 255, 0.055));
}

.message.is-loading {
  border-color: rgba(246, 200, 95, 0.55);
}

.message b {
  display: block;
  margin-bottom: 10px;
  color: #fff5ec;
  font-size: 13px;
  font-weight: 850;
}

.message-body {
  max-width: 100%;
  color: #ead8cc;
  font-size: 13.5px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  word-break: normal;
}

.message.assistant .message-body {
  max-height: min(55vh, 560px);
  padding-right: 8px;
  overflow: hidden auto;
  scrollbar-color: rgba(255, 122, 61, 0.62) rgba(255, 255, 255, 0.08);
}

.message.user .message-body {
  max-width: 64ch;
}

.message-body h3,
.message-body h4,
.message-body h5 {
  margin: 18px 0 8px;
  color: #fff8f2;
  line-height: 1.28;
}

.message-body h3 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: #fff3e8;
  font-size: 17px;
}

.message-body h4 {
  color: #ffe2cf;
  font-size: 15px;
}

.message-body h5 {
  color: #ffd166;
  font-size: 13.5px;
}

.message-body p,
.message-body ul,
.message-body ol {
  margin: 10px 0;
}

.message-body ul,
.message-body ol {
  padding-left: 22px;
}

.message-body li + li {
  margin-top: 5px;
}

.message-body strong {
  color: #fff7ef;
  font-weight: 850;
}

.message-body code {
  padding: 2px 6px;
  border: 1px solid rgba(255, 218, 184, 0.18);
  border-radius: 7px;
  color: #dffcff;
  background: rgba(107, 188, 255, 0.1);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.93em;
}

.message-body .table-scroll {
  max-width: 100%;
  margin: 12px 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  scrollbar-color: rgba(107, 188, 255, 0.56) rgba(255, 255, 255, 0.08);
}

.message-body table {
  width: 100%;
  min-width: 680px;
  margin: 0;
  border-collapse: collapse;
  font-size: 13px;
}

.message-body th,
.message-body td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.message-body th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fff8f2;
  background: rgba(48, 27, 20, 0.96);
  font-weight: 850;
}

.message-body td {
  color: #ead8cc;
}

.message-body pre,
.prompt-output {
  white-space: pre-wrap;
  word-break: break-word;
}

.message-body pre {
  margin: 12px 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(24, 13, 10, 0.66);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.composer textarea {
  min-height: 48px;
  max-height: 76px;
  resize: none;
}

.prompt-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.prompt-form .wide {
  grid-column: 1 / -1;
}

.prompt-form .primary-button {
  min-height: 44px;
}

.prompt-output {
  min-height: 280px;
  margin-top: 14px;
  padding: 18px;
  color: #ead8cc;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loginFlow {
  from {
    transform: rotate(0deg) scale(1);
  }
  to {
    transform: rotate(360deg) scale(1.08);
  }
}

@keyframes loginDrift {
  from {
    transform: translate3d(0, 0, 0) scale(0.96);
  }
  to {
    transform: translate3d(42px, -34px, 0) scale(1.08);
  }
}

@media (max-width: 1080px) {
  .appbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .title-block {
    display: none;
  }

  .workspace-top,
  .agent-layout {
    grid-template-columns: 1fr;
  }

  body[data-view="agent"] .agent-layout {
    height: auto;
    min-height: 0;
  }

  .stage-board,
  .course-grid,
  .module-grid,
  .asset-grid,
  .source-note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .appbar,
  main {
    width: min(100% - 14px, 1180px);
  }

  .appbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
  }

  .brand {
    min-width: 0;
  }

  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logout-button {
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .tabs {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    overflow: visible;
  }

  .tab {
    min-width: 0;
    min-height: 40px;
    padding: 7px 8px;
    border-radius: 13px;
    font-size: 13px;
    line-height: 1.15;
  }

  h1 {
    font-size: 25px;
  }

  h2 {
    font-size: 21px;
  }

  .workspace-top {
    padding-top: 20px;
  }

  body[data-view="agent"] main {
    width: min(100% - 10px, 1180px);
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  body[data-view="agent"] .agent-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
  }

  .chat-workspace {
    order: 1;
    min-height: min(760px, calc(100svh - 178px));
    border-radius: 20px;
  }

  .agent-panel {
    order: 2;
    max-height: none;
    padding: 12px;
    border-radius: 18px;
  }

  .agent-panel label,
  .file-ledger,
  .history-panel {
    margin-top: 10px;
  }

  .chat-log {
    padding: 12px;
  }

  .chat-head {
    padding: 14px;
  }

  .chat-head h2 {
    font-size: 24px;
  }

  .chat-head p {
    font-size: 14px;
  }

  .composer {
    position: sticky;
    bottom: 0;
    padding: 10px;
    background: rgba(18, 13, 13, 0.92);
    backdrop-filter: blur(20px);
  }

  .composer textarea {
    min-height: 84px;
    max-height: 140px;
  }

  .composer .primary-button {
    min-height: 52px;
    font-size: 16px;
  }

  .control-strip {
    min-height: auto;
  }

  .control-strip h1 {
    font-size: 36px;
  }

  .method-map {
    aspect-ratio: 920 / 540;
    border-radius: 20px;
  }

  .stage-board,
  .course-grid,
  .module-grid,
  .asset-grid,
  .source-note-grid,
  .prompt-form {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }

  .message.assistant .message-body {
    max-height: none;
  }

  .file-space-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-space {
    min-height: 124px;
    padding: 14px;
  }

  .file-space strong {
    font-size: 38px;
  }

  .archive-heading {
    align-items: flex-start;
    flex-direction: column;
    margin-top: 16px;
  }
}

@media (max-width: 430px) {
  .file-space-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 22px;
  }

  .login-screen {
    padding-top: max(26px, env(safe-area-inset-top));
  }

  .appbar {
    top: 6px;
    width: min(100% - 8px, 1180px);
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    min-height: 38px;
    padding: 7px 6px;
    font-size: 12px;
  }

  .chat-workspace {
    min-height: calc(100svh - 170px);
  }

  .message {
    padding: 12px;
  }

  .message-body {
    font-size: 14px;
    line-height: 1.72;
  }
}
