:root {
  color-scheme: dark;
  --bg: #07111a;
  --bg-soft: #0d1a26;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --solid: #101b27;
  --text: #f3fbf8;
  --muted: #9bb3b0;
  --line: rgba(255, 255, 255, 0.14);
  --jade: #29d6c5;
  --jade-dark: #119487;
  --blue: #67a2ff;
  --gold: #d5a94b;
  --red: #e47a6e;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --chat-scale: 1;
  --rail: 292px;
  --composer: 94px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

/* Simple Codex-like workspace refresh */
:root {
  --bg: #0b0f14;
  --bg-soft: #111820;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --solid: #11171f;
  --line: rgba(255, 255, 255, 0.12);
  --muted: #9aa7b2;
  --jade: #27d3bd;
  --rail: 252px;
  --composer: 92px;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-soft: #eef4f4;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --solid: #ffffff;
  --line: rgba(25, 40, 52, 0.12);
  --text: #111820;
  --muted: #65727f;
}

body {
  background: linear-gradient(180deg, var(--bg), var(--bg-soft));
}

.app {
  background: transparent;
}

.rail {
  gap: 12px;
  background: rgba(9, 13, 18, 0.9);
}

:root[data-theme="light"] .rail {
  background: rgba(255, 255, 255, 0.88);
}

.rail-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.rail-brand b {
  font-size: 17px;
}

.rail-brand span {
  font-size: 12px;
}

.primary,
.secondary,
.rail-nav button,
.thread-list button,
.inspector-tabs button,
.prompt-chips button,
.agent-menu button,
.segmented button {
  border-radius: 10px;
  box-shadow: none;
}

.rail-nav {
  gap: 6px;
}

.rail-nav button {
  min-height: 40px;
}

.thread-list button {
  min-height: 38px;
  padding: 9px 10px;
}

.account-mini {
  border-radius: 12px;
  background: var(--panel);
}

.topbar {
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: rgba(11, 15, 20, 0.82);
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.86);
}

.topbar p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar h1 {
  font-size: clamp(20px, 3vw, 28px);
}

.top-actions {
  gap: 8px;
}

.top-actions button,
.top-actions span {
  min-height: 36px;
  border-radius: 10px;
}

.agent-layout {
  grid-template-columns: minmax(0, 920px);
  justify-content: center;
}

.inspector {
  display: none;
}

.chat-panel {
  width: min(100%, 920px);
  justify-self: center;
  padding: clamp(16px, 3vw, 30px);
}

.agent-hero {
  margin: min(10vh, 86px) 0 18px;
  text-align: center;
}

.agent-hero span {
  color: var(--muted);
  font-size: 12px;
}

.agent-hero h2 {
  max-width: none;
  margin-bottom: 10px;
  font-size: clamp(30px, 6vw, 50px);
  line-height: 1.08;
}

.agent-hero p {
  max-width: 620px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.7;
}

.prompt-chips {
  justify-content: center;
  margin-top: 18px;
}

.prompt-chips button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

:root[data-theme="light"] .prompt-chips button {
  background: #fff;
}

.messages {
  padding-bottom: 8px;
}

.message {
  max-width: min(760px, 100%);
}

.bubble {
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: none;
}

:root[data-theme="light"] .bubble {
  background: #fff;
}

.message.user .bubble {
  color: #06110f;
  background: #27d3bd;
}

.composer {
  max-width: min(920px, calc(100vw - var(--rail)));
  width: 100%;
  justify-self: center;
  align-self: end;
  grid-template-columns: 44px 56px minmax(0, 1fr) 68px;
  grid-template-rows: 52px;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgba(17, 23, 31, 0.94);
}

:root[data-theme="light"] .composer {
  background: rgba(255, 255, 255, 0.96);
}

#agentMenuBtn,
#voiceBtn,
#composerInput,
#sendBtn {
  grid-row: 1;
}

#agentMenuBtn {
  grid-column: 1;
}

#voiceBtn {
  grid-column: 2;
}

#composerInput {
  grid-column: 3;
}

#sendBtn {
  grid-column: 4;
}

.icon,
.send {
  height: 44px;
  min-height: 44px;
  border-radius: 11px;
  padding: 0 8px;
}

.composer textarea {
  min-height: 44px;
  max-height: 118px;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.42;
  background: rgba(255, 255, 255, 0.06);
}

.composer p {
  display: none;
}

.agent-menu {
  left: max(18px, calc((100vw - 920px + var(--rail)) / 2));
  right: max(18px, calc((100vw - 920px) / 2));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: 16px;
}

@media (max-width: 980px) {
  .composer {
    max-width: calc(100vw - 24px);
  }

  .agent-menu {
    left: 12px;
    right: 12px;
  }
}

@media (max-width: 620px) {
  :root {
    --composer: 76px;
  }

  .topbar {
    min-height: calc(56px + env(safe-area-inset-top));
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .top-actions {
    gap: 6px;
  }

  #accountBtn,
  #networkState {
    display: none;
  }

  #speakBtn,
  .menu-toggle {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 13px;
  }

  .chat-panel {
    width: 100%;
    padding: 12px;
  }

  .agent-hero {
    margin: 34px 0 14px;
    padding: 0;
  }

  .agent-hero span {
    display: block;
    margin-bottom: 6px;
  }

  .agent-hero h2 {
    font-size: 27px;
  }

  .agent-hero p {
    max-width: 320px;
    font-size: 13px;
    line-height: 1.55;
  }

  .prompt-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
  }

  .prompt-chips button {
    min-height: 36px;
    padding: 0 8px;
  }

  .message.user {
    max-width: 86%;
  }

  .bubble {
    border-radius: 13px;
    padding: 12px 13px;
  }

  .composer {
    max-width: calc(100vw - 16px);
    grid-template-columns: 42px 42px minmax(0, 1fr) 56px;
    grid-template-rows: 44px;
    gap: 7px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }

  .icon,
  .send {
    height: 42px;
    min-height: 42px;
    border-radius: 11px;
    font-size: 13px;
  }

  #voiceBtn {
    font-size: 0;
  }

  #voiceBtn::after {
    content: "语";
    font-size: 15px;
  }

  .composer textarea {
    min-height: 42px;
    max-height: 92px;
    padding: 10px 11px;
    font-size: 15px;
  }

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

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef6f5;
  --bg-soft: #f8fbfb;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --solid: #ffffff;
  --text: #10211f;
  --muted: #617772;
  --line: rgba(20, 105, 98, 0.18);
  --shadow: 0 18px 52px rgba(19, 97, 90, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
  pointer-events: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;
  -webkit-text-size-adjust: 100%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(41, 214, 197, 0.22), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(103, 162, 255, 0.18), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
}

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

button {
  color: inherit;
  cursor: pointer;
}

img {
  max-width: 100%;
}

body.agreement-pending .app {
  display: none;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  color: white;
  background:
    radial-gradient(circle, rgba(41, 214, 197, 0.18), transparent 48%),
    linear-gradient(135deg, #061019, #10233a 54%, #0a1718);
}

.boot[hidden] {
  display: none;
}

.boot-core {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.boot-core img {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.boot-core p,
.boot-core h1 {
  margin: 0;
}

.boot-core p {
  color: var(--jade);
  font-weight: 900;
}

.boot-core h1 {
  font-size: clamp(44px, 8vw, 78px);
  line-height: 1;
}

.boot-core span,
.boot small {
  color: rgba(255, 255, 255, 0.72);
}

.boot small {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  text-align: center;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(3, 8, 12, 0.72);
  backdrop-filter: blur(18px);
}

.gate[hidden] {
  display: none;
}

.gate-card {
  width: min(760px, 100%);
  max-height: min(840px, 92vh);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--solid);
  box-shadow: var(--shadow);
}

.compact-card {
  max-width: 620px;
}

.gate-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.gate-head img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

.gate-head p,
.topbar p,
.agent-hero span {
  margin: 0 0 5px;
  color: var(--jade);
  font-size: 13px;
  font-weight: 900;
}

.gate-head h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 42px);
}

.gate-body {
  max-height: min(560px, 58vh);
  overflow: auto;
  padding: 22px;
  color: var(--muted);
  line-height: 1.8;
}

.gate-body h2 {
  margin: 18px 0 8px;
  color: var(--text);
}

.gate-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 18px 22px 22px;
  border-top: 1px solid var(--line);
}

.gate-actions.stacked {
  grid-template-columns: 1fr;
}

.app {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--composer);
  overflow: hidden;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 64;
  border: 0;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
}

.rail {
  grid-row: 1 / span 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: max(18px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  background: rgba(5, 12, 18, 0.72);
  backdrop-filter: blur(20px);
}

:root[data-theme="light"] .rail {
  background: rgba(255, 255, 255, 0.76);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rail-brand img {
  width: 54px;
  height: 54px;
  border-radius: 15px;
}

.rail-brand b,
.rail-brand span {
  display: block;
}

.rail-brand span,
.account-mini,
.thread-list small,
.panel-page p,
.settings-card p,
.message-meta,
.tool-log,
.file-list button span,
.model-list span,
.memory-board span {
  color: var(--muted);
}

.primary,
.secondary,
.rail-nav button,
.thread-list button,
.inspector-tabs button,
.prompt-chips button,
.agent-menu button,
.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  font-weight: 850;
}

.primary {
  color: #041412;
  border-color: transparent;
  background: linear-gradient(135deg, var(--jade), #99fff2);
  box-shadow: 0 14px 32px rgba(41, 214, 197, 0.22);
}

.secondary.danger,
.danger {
  color: var(--red);
}

.wide {
  width: 100%;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-nav button,
.thread-list button {
  width: 100%;
  padding: 0 12px;
  text-align: left;
}

.rail-nav button.active,
.thread-list button.active,
.inspector-tabs button.active,
.segmented button.active {
  border-color: rgba(41, 214, 197, 0.48);
  color: var(--jade);
  background: rgba(41, 214, 197, 0.12);
}

.thread-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.thread-list button {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
}

.account-mini {
  margin: auto 0 0;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(41, 214, 197, 0.08);
  font-size: 12px;
  line-height: 1.6;
}

.account-mini b {
  color: var(--text);
  font-size: 14px;
}

.account-mini span {
  color: var(--jade);
  font-weight: 900;
}

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

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions button {
  min-width: 60px;
  padding: 0 12px;
}

.top-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--jade);
  font-weight: 900;
}

.menu-toggle {
  display: none;
}

.tab-view {
  min-height: 0;
  display: none;
  max-width: 100%;
  overflow: auto;
  overflow-x: hidden;
}

.tab-view.active {
  display: block;
}

.agent-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42%);
}

.chat-panel {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  padding: 22px;
}

.agent-hero {
  margin-bottom: 20px;
}

.agent-hero h2 {
  max-width: 820px;
  margin: 0 0 10px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
}

.agent-hero p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.prompt-chips button {
  min-height: 38px;
  padding: 0 13px;
  color: var(--jade);
}

.messages {
  display: grid;
  gap: 14px;
}

.message {
  max-width: min(840px, 100%);
}

.message.user {
  justify-self: end;
}

.bubble {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  font-size: calc(16px * var(--chat-scale));
  line-height: 1.72;
}

.message.user .bubble {
  color: #041412;
  border-color: transparent;
  background: linear-gradient(135deg, var(--jade), #8ffff1);
}

.bubble h3,
.bubble h4 {
  margin: 0 0 8px;
  color: var(--jade);
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child,
.bubble ol:last-child,
.bubble ul:last-child {
  margin-bottom: 0;
}

.bubble pre {
  overflow: auto;
  padding: 14px;
  border-radius: 14px;
  background: #050b0f;
  color: #dffcf8;
}

.agent-diagram {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid rgba(41, 214, 197, 0.2);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(41, 214, 197, 0.08), transparent),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(255, 255, 255, 0.04) 28px);
}

.agent-diagram-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.agent-diagram-grid span {
  min-height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: center;
  font-weight: 900;
}

.thinking-board {
  margin: 12px 0 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.thinking-board div {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(41, 214, 197, 0.26);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(41, 214, 197, 0.1), rgba(255, 255, 255, 0.035));
}

.thinking-board b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #041412;
  background: var(--jade);
  font-size: 13px;
}

.thinking-board span {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.inspector {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.inspector-pane {
  min-height: 0;
  display: none;
  overflow: auto;
  padding: 16px;
}

.inspector-pane.active {
  display: block;
}

.inspector h3,
.panel-page h2,
.settings-card h2,
.settings-card h3 {
  margin-top: 0;
}

.plan-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding-left: 20px;
}

.plan-list li,
.tool-log div,
.settings-card,
.panel-page,
.project-cards article,
.skill-grid article,
.memory-board article,
.model-list article {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.plan-list li {
  padding: 10px 12px;
}

.tool-log {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.tool-log div {
  padding: 10px 12px;
}

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

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.file-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px;
}

.file-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.file-list button {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  text-align: left;
}

.file-list button.active {
  color: var(--jade);
  border-color: rgba(41, 214, 197, 0.48);
  background: rgba(41, 214, 197, 0.1);
}

.file-view,
.terminal {
  min-height: 380px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #050b0f;
  color: #ddfff9;
  font: 13px/1.6 "SFMono-Regular", Consolas, monospace;
}

#previewFrame {
  width: 100%;
  height: min(70vh, 620px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.panel-page {
  min-height: calc(100% - 44px);
  max-width: calc(100vw - 44px);
  margin: 22px;
  padding: 22px;
  overflow-x: hidden;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.project-cards,
.skill-grid,
.model-list,
.memory-board,
.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.project-cards article,
.skill-grid article,
.memory-board article,
.model-list article,
.upgrade-grid article {
  padding: 16px;
}

.page-hero {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 8% 10%, rgba(41, 214, 197, 0.18), transparent 34%),
    linear-gradient(135deg, var(--panel-strong), var(--panel));
}

.page-hero p {
  margin: 0 0 8px;
  color: var(--jade);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-hero h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.05;
}

.page-hero span,
.upgrade-grid span,
.upgrade-log span,
.upgrade-log p {
  color: var(--muted);
  line-height: 1.65;
}

.upgrade-grid {
  margin-bottom: 18px;
}

.upgrade-grid article {
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.upgrade-grid b {
  color: var(--jade);
  font-size: 18px;
}

.upgrade-log {
  display: grid;
  gap: 10px;
}

.upgrade-log article {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.upgrade-log p {
  margin: 0;
}

.model-list article.active {
  border-color: rgba(41, 214, 197, 0.5);
  background: rgba(41, 214, 197, 0.1);
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.permission-card {
  align-content: start;
}

.permission-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.permission-options button {
  min-height: 84px;
  padding: 13px 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent),
    var(--panel);
  color: var(--text);
}

.permission-options button.active {
  border-color: rgba(41, 214, 197, 0.72);
  background:
    linear-gradient(135deg, rgba(41, 214, 197, 0.22), rgba(103, 162, 255, 0.12)),
    var(--panel-strong);
  box-shadow: 0 14px 34px rgba(41, 214, 197, 0.14);
}

.permission-options b,
.permission-options span,
.permission-summary strong,
.permission-summary span {
  display: block;
}

.permission-options b {
  margin-bottom: 6px;
  color: var(--jade);
  font-size: 16px;
}

.permission-options span,
.permission-summary span {
  color: var(--muted);
  line-height: 1.55;
}

.config-label textarea {
  margin-top: 8px;
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

.permission-summary,
.permission-notice {
  border: 1px solid rgba(41, 214, 197, 0.32);
  border-radius: 14px;
  background: rgba(41, 214, 197, 0.1);
}

.permission-summary {
  margin: 0;
  padding: 12px;
}

.permission-notice {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.permission-notice b {
  color: var(--jade);
}

.permission-notice span {
  color: var(--muted);
  line-height: 1.6;
}

.review-admin {
  display: grid;
  gap: 18px;
}

.review-admin[hidden] {
  display: none;
}

.review-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.review-stats article,
.review-orders article {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.review-stats article {
  padding: 16px;
}

.review-stats b {
  display: block;
  margin-bottom: 5px;
  color: var(--jade);
  font-size: 22px;
}

.review-stats span,
.review-orders small,
.review-orders span {
  color: var(--muted);
}

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

.segmented.compact {
  flex-wrap: nowrap;
}

.segmented.compact button {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.review-orders {
  display: grid;
  gap: 12px;
}

.review-orders article {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.review-order-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.review-order-top b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 17px;
}

.status-pill {
  min-width: 70px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.status-pill.pending {
  color: #ffd56b;
  border-color: rgba(255, 213, 107, 0.38);
  background: rgba(255, 213, 107, 0.1);
}

.status-pill.approved {
  color: var(--jade);
  border-color: rgba(41, 214, 197, 0.38);
  background: rgba(41, 214, 197, 0.1);
}

.status-pill.rejected {
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.34);
  background: rgba(255, 107, 107, 0.08);
}

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

.review-meta div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.review-meta b,
.review-meta span {
  display: block;
}

.review-meta b {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.review-meta span {
  overflow-wrap: anywhere;
}

.mini-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.token-balance {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(41, 214, 197, 0.28);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(41, 214, 197, 0.14), rgba(103, 162, 255, 0.08)),
    var(--panel);
}

.token-balance b {
  color: var(--jade);
  font-size: 34px;
  line-height: 1;
}

.token-balance span {
  color: var(--muted);
  font-weight: 900;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.pricing-card {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 92% 8%, rgba(41, 214, 197, 0.16), transparent 36%),
    var(--panel);
}

.pricing-card.featured {
  border-color: rgba(41, 214, 197, 0.5);
  background:
    linear-gradient(135deg, rgba(41, 214, 197, 0.16), rgba(213, 169, 75, 0.08)),
    var(--panel);
}

.pricing-card h4,
.pricing-card p {
  margin: 0;
}

.pricing-card strong {
  font-size: 30px;
}

.pricing-card small {
  color: var(--muted);
  line-height: 1.55;
}

.payment-body {
  display: grid;
  gap: 14px;
}

.payment-summary {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(41, 214, 197, 0.3);
  border-radius: 16px;
  background: rgba(41, 214, 197, 0.1);
}

.payment-summary b,
.payment-summary strong {
  color: var(--text);
}

.payment-summary strong {
  font-size: 34px;
  line-height: 1;
}

.payment-summary span {
  color: var(--jade);
  font-weight: 900;
}

.payment-qr-box {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed rgba(41, 214, 197, 0.42);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.payment-qr-box img {
  width: min(340px, 78vw);
  max-height: min(520px, 62vh);
  object-fit: contain;
  border-radius: 14px;
  background: white;
  box-shadow: 0 20px 48px rgba(2, 49, 44, 0.18);
}

.payment-qr-placeholder {
  max-width: 320px;
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  line-height: 1.6;
}

.payment-qr-placeholder b {
  color: var(--jade);
}

.payment-orders {
  display: grid;
  gap: 8px;
}

.payment-orders article {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.payment-orders b {
  color: var(--text);
}

.payment-orders span {
  color: var(--jade);
  font-weight: 900;
}

.payment-orders small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

#accountPanel {
  display: grid;
  gap: 10px;
}

#accountPanel article {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

#accountPanel b {
  color: var(--jade);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 12px;
  outline: none;
  color: var(--text);
  background: var(--panel);
  font-size: 16px;
}

:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
  background: white;
}

textarea {
  resize: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(41, 214, 197, 0.64);
  box-shadow: 0 0 0 4px rgba(41, 214, 197, 0.12);
}

.segmented,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button {
  flex: 1;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-row input {
  width: 48px;
}

.composer {
  grid-column: 2;
  min-height: var(--composer);
  max-width: 100vw;
  display: grid;
  grid-template-columns: 52px 70px minmax(0, 1fr) 82px;
  grid-template-rows: auto auto;
  align-items: end;
  gap: 8px 10px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.icon,
.send {
  height: 52px;
  padding: 0 8px;
}

.composer textarea {
  min-height: 52px;
  max-height: 130px;
  padding: 14px;
  line-height: 1.45;
}

.composer p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.agent-menu {
  position: fixed;
  left: calc(var(--rail) + 18px);
  right: 18px;
  bottom: calc(var(--composer) + max(12px, env(safe-area-inset-bottom)));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--solid);
  box-shadow: var(--shadow);
}

.agent-menu button {
  min-height: 46px;
  color: var(--jade);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--composer) + 22px);
  z-index: 110;
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  color: #041412;
  background: linear-gradient(135deg, var(--jade), #9ffff2);
  box-shadow: var(--shadow);
  font-weight: 900;
}

@media (max-width: 980px) {
  :root {
    --rail: 286px;
  }

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

  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(var(--rail), 88vw);
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .rail.open {
    transform: translateX(0);
  }

  .workspace {
    grid-column: 1;
  }

  .composer {
    grid-column: 1;
  }

  .menu-toggle {
    display: inline-block;
  }

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

  .inspector {
    min-height: 520px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .agent-menu {
    left: 14px;
    right: 14px;
  }
}

@media (max-width: 620px) {
  :root {
    --composer: 82px;
  }

  body {
    background: linear-gradient(180deg, var(--bg), var(--bg-soft));
  }

  .app {
    grid-template-rows: minmax(0, 1fr) var(--composer);
  }

  .topbar {
    min-height: calc(58px + env(safe-area-inset-top));
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 12px 10px;
    background: rgba(7, 17, 26, 0.92);
  }

  :root[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, 0.92);
  }

  .topbar p {
    display: none;
  }

  .top-actions {
    grid-column: auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .topbar h1 {
    font-size: 20px;
    line-height: 1.1;
  }

  .top-actions span {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  #speakBtn,
  .menu-toggle {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 11px;
    font-size: 14px;
  }

  .workspace {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .tab-view.active {
    height: 100%;
  }

  .agent-layout {
    height: 100%;
    display: block;
  }

  .inspector {
    display: none;
  }

  .agent-hero {
    margin: 0 0 10px;
    padding: 6px 2px 10px;
  }

  .agent-hero span {
    display: none;
  }

  .agent-hero h2 {
    margin-bottom: 6px;
    font-size: 23px;
    line-height: 1.18;
  }

  .agent-hero p {
    font-size: 14px;
    line-height: 1.5;
  }

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

  .prompt-chips button {
    min-height: 36px;
    padding: 0 8px;
    border-radius: 11px;
    font-size: 13px;
  }

  .chat-panel,
  .panel-page {
    padding: 12px;
    margin: 0;
    max-width: 100vw;
  }

  .messages {
    gap: 10px;
  }

  .message {
    max-width: 100%;
  }

  .message.user {
    max-width: 84%;
  }

  .message-meta {
    margin: 0 0 4px;
    font-size: 12px;
  }

  .bubble {
    padding: 12px 13px;
    border-radius: 15px;
    font-size: calc(15px * var(--chat-scale));
    line-height: 1.62;
    box-shadow: none;
  }

  .bubble h4 {
    margin-bottom: 6px;
    font-size: 16px;
  }

  .bubble p {
    margin-bottom: 8px;
  }

  .agent-diagram {
    display: none;
  }

  .thinking-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .thinking-board div {
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 8px;
    border-radius: 12px;
  }

  .thinking-board b {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .thinking-board span {
    font-size: 13px;
  }

  .composer {
    min-height: var(--composer);
    grid-template-columns: 42px minmax(0, 1fr) 48px 54px;
    grid-template-rows: 46px;
    align-items: center;
    gap: 7px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    background: rgba(7, 17, 26, 0.94);
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  :root[data-theme="light"] .composer {
    background: rgba(255, 255, 255, 0.96);
  }

  #agentMenuBtn {
    grid-column: 1;
    grid-row: 1;
  }

  #composerInput {
    grid-column: 2;
    grid-row: 1;
  }

  #voiceBtn {
    grid-column: 3;
    grid-row: 1;
  }

  #sendBtn {
    grid-column: 4;
    grid-row: 1;
  }

  .icon,
  .send {
    height: 44px;
    min-height: 44px;
    border-radius: 13px;
    padding: 0 6px;
    font-size: 14px;
  }

  .composer textarea {
    min-height: 44px;
    max-height: 96px;
    padding: 11px 12px;
    border-radius: 14px;
    line-height: 1.35;
  }

  .composer p {
    display: none;
  }

  .file-grid,
  .two-col,
  .agent-diagram-grid,
  .permission-options,
  .review-stats,
  .review-meta {
    grid-template-columns: 1fr;
  }

  .review-head,
  .review-order-top {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented.compact {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .agent-menu {
    grid-template-columns: repeat(2, 1fr);
    bottom: calc(var(--composer) + max(10px, env(safe-area-inset-bottom)));
    max-height: 42vh;
    overflow: auto;
  }

  .gate-actions {
    grid-template-columns: 1fr;
  }
}

/* Final simple workspace overrides */
:root {
  --bg: #0b0f14;
  --bg-soft: #111820;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --solid: #11171f;
  --line: rgba(255, 255, 255, 0.12);
  --muted: #9aa7b2;
  --jade: #27d3bd;
  --rail: 252px;
  --composer: 92px;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-soft: #eef4f4;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --solid: #ffffff;
  --line: rgba(25, 40, 52, 0.12);
  --text: #111820;
  --muted: #65727f;
}

body {
  background: linear-gradient(180deg, var(--bg), var(--bg-soft));
}

.app {
  background: transparent;
}

.rail {
  gap: 12px;
  background: rgba(9, 13, 18, 0.9);
}

:root[data-theme="light"] .rail {
  background: rgba(255, 255, 255, 0.88);
}

.rail-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.rail-brand b {
  font-size: 17px;
}

.rail-brand span {
  font-size: 12px;
}

.primary,
.secondary,
.rail-nav button,
.thread-list button,
.inspector-tabs button,
.prompt-chips button,
.agent-menu button,
.segmented button {
  border-radius: 10px;
  box-shadow: none;
}

.rail-nav {
  gap: 6px;
}

.rail-nav button {
  min-height: 40px;
}

.thread-list button {
  min-height: 38px;
  padding: 9px 10px;
}

.account-mini {
  border-radius: 12px;
  background: var(--panel);
}

.topbar {
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: rgba(11, 15, 20, 0.82);
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.86);
}

.topbar p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar h1 {
  font-size: clamp(20px, 3vw, 28px);
}

.top-actions {
  gap: 8px;
}

.top-actions button,
.top-actions span {
  min-height: 36px;
  border-radius: 10px;
}

.agent-layout {
  grid-template-columns: minmax(0, 920px);
  justify-content: center;
}

.inspector {
  display: none;
}

.chat-panel {
  width: min(100%, 920px);
  justify-self: center;
  padding: clamp(16px, 3vw, 30px);
}

.agent-hero {
  margin: min(10vh, 86px) 0 18px;
  text-align: center;
}

.agent-hero span {
  color: var(--muted);
  font-size: 12px;
}

.agent-hero h2 {
  max-width: none;
  margin-bottom: 10px;
  font-size: clamp(30px, 6vw, 50px);
  line-height: 1.08;
}

.agent-hero p {
  max-width: 620px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.7;
}

.prompt-chips {
  justify-content: center;
  margin-top: 18px;
}

.prompt-chips button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

:root[data-theme="light"] .prompt-chips button {
  background: #fff;
}

.messages {
  padding-bottom: 8px;
}

.message {
  max-width: min(760px, 100%);
}

.bubble {
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: none;
}

:root[data-theme="light"] .bubble {
  background: #fff;
}

.message.user .bubble {
  color: #06110f;
  background: #27d3bd;
}

.composer {
  max-width: min(920px, calc(100vw - var(--rail)));
  width: 100%;
  justify-self: center;
  align-self: end;
  grid-template-columns: 44px 56px minmax(0, 1fr) 68px;
  grid-template-rows: 52px;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: rgba(17, 23, 31, 0.94);
}

:root[data-theme="light"] .composer {
  background: rgba(255, 255, 255, 0.96);
}

#agentMenuBtn,
#voiceBtn,
#composerInput,
#sendBtn {
  grid-row: 1;
}

#agentMenuBtn {
  grid-column: 1;
}

#voiceBtn {
  grid-column: 2;
}

#composerInput {
  grid-column: 3;
}

#sendBtn {
  grid-column: 4;
}

.icon,
.send {
  height: 44px;
  min-height: 44px;
  border-radius: 11px;
  padding: 0 8px;
}

.composer textarea {
  min-height: 44px;
  max-height: 118px;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.42;
  background: rgba(255, 255, 255, 0.06);
}

.composer p {
  display: none;
}

.agent-menu {
  left: max(18px, calc((100vw - 920px + var(--rail)) / 2));
  right: max(18px, calc((100vw - 920px) / 2));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: 16px;
}

@media (max-width: 980px) {
  .composer {
    max-width: calc(100vw - 24px);
  }

  .agent-menu {
    left: 12px;
    right: 12px;
  }
}

@media (max-width: 620px) {
  :root {
    --composer: 76px;
  }

  .topbar {
    min-height: calc(56px + env(safe-area-inset-top));
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .top-actions {
    gap: 6px;
  }

  #accountBtn,
  #networkState {
    display: none;
  }

  #speakBtn,
  .menu-toggle {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 13px;
  }

  .chat-panel {
    width: 100%;
    padding: 12px;
  }

  .agent-hero {
    margin: 34px 0 14px;
    padding: 0;
  }

  .agent-hero span {
    display: block;
    margin-bottom: 6px;
  }

  .agent-hero h2 {
    font-size: 27px;
  }

  .agent-hero p {
    max-width: 320px;
    font-size: 13px;
    line-height: 1.55;
  }

  .prompt-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
  }

  .prompt-chips button {
    min-height: 36px;
    padding: 0 8px;
  }

  .message.user {
    max-width: 86%;
  }

  .bubble {
    border-radius: 13px;
    padding: 12px 13px;
  }

  .composer {
    max-width: calc(100vw - 16px);
    grid-template-columns: 42px 42px minmax(0, 1fr) 56px;
    grid-template-rows: 44px;
    gap: 7px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }

  .icon,
  .send {
    height: 42px;
    min-height: 42px;
    border-radius: 11px;
    font-size: 13px;
  }

  #voiceBtn {
    font-size: 0;
  }

  #voiceBtn::after {
    content: "语";
    font-size: 15px;
  }

  .composer textarea {
    min-height: 42px;
    max-height: 92px;
    padding: 10px 11px;
    font-size: 15px;
  }

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