:root {
  color-scheme: dark;
  --ink: #fff8ed;
  --ink-soft: #ead9c4;
  --muted: #bcae9e;
  --gold: #e1b76f;
  --gold-pale: #f3d8a4;
  --red: #bd2925;
  --red-bright: #e44c41;
  --green: #6ee0b5;
  --panel: rgba(10, 14, 18, 0.58);
  --panel-deep: rgba(6, 9, 12, 0.7);
  --line: rgba(242, 211, 164, 0.24);
  --line-strong: rgba(242, 211, 164, 0.42);
  --shadow: 0 34px 90px rgba(0, 0, 0, 0.46);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-scene: cubic-bezier(0.65, 0, 0.35, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #07090b;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: #07090b;
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea,
.panel {
  -webkit-tap-highlight-color: transparent;
}

.scene-stack,
.scene-layer,
.scene-light,
.scene-mist,
.scene-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.scene-stack {
  z-index: 0;
  overflow: hidden;
  background: #07090b;
}

.scene-layer {
  inset: -2.5%;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.035);
  transition:
    opacity 1000ms var(--ease-scene),
    transform 1400ms var(--ease-out);
  will-change: opacity, transform;
}

.scene-login {
  background-image: url("/static/assets/xiaoma-wallpaper.webp");
  opacity: 1;
  transform: scale(1.015);
}

.scene-workspace {
  background-image: url("/static/assets/xiaoma-workspace-bg.webp");
}

body.workspace-mode .scene-login {
  opacity: 0;
  transform: scale(1.045);
}

body.workspace-mode .scene-workspace {
  opacity: 1;
  transform: scale(1.015);
}

.scene-light {
  z-index: 1;
  background:
    linear-gradient(108deg, rgba(255, 226, 180, 0.22) 0%, transparent 27%),
    linear-gradient(250deg, rgba(161, 198, 224, 0.14) 0%, transparent 36%);
  mix-blend-mode: screen;
  opacity: 0.86;
  transition: opacity 900ms ease;
}

body.workspace-mode .scene-light {
  opacity: 1;
}

.scene-mist {
  z-index: 2;
  inset: auto -18% -24% -18%;
  height: 58%;
  filter: blur(34px);
  opacity: 0.22;
  will-change: transform;
}

.scene-mist-one {
  background: linear-gradient(166deg, transparent 18%, rgba(236, 239, 238, 0.5) 42%, transparent 64%);
  animation: mistOne 18s ease-in-out infinite alternate;
}

.scene-mist-two {
  bottom: -34%;
  background: linear-gradient(18deg, transparent 28%, rgba(255, 227, 192, 0.34) 48%, transparent 69%);
  animation: mistTwo 24s ease-in-out infinite alternate;
}

.scene-vignette {
  z-index: 3;
  background:
    linear-gradient(90deg, rgba(2, 4, 6, 0.58), transparent 34%, transparent 69%, rgba(2, 4, 6, 0.4)),
    linear-gradient(180deg, rgba(2, 4, 6, 0.34), transparent 30%, transparent 68%, rgba(2, 4, 6, 0.55));
  transition: opacity 900ms ease;
}

body.scene-changing .scene-vignette {
  opacity: 0.76;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1180px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
}

.view {
  grid-area: 1 / 1;
  min-width: 0;
  opacity: 1;
  filter: blur(0);
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 560ms var(--ease-scene),
    filter 680ms var(--ease-scene),
    transform 760ms var(--ease-out);
  will-change: opacity, filter, transform;
}

.view.entering {
  opacity: 0;
  filter: blur(12px);
  transform: translate3d(0, 26px, 0) scale(0.985);
}

.view.leaving {
  z-index: 2;
  opacity: 0;
  filter: blur(12px);
  pointer-events: none;
  transform: translate3d(0, -18px, 0) scale(1.012);
}

.hidden {
  display: none !important;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 24%),
    var(--panel);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 246, 226, 0.13);
  backdrop-filter: blur(22px) saturate(118%);
}

.panel::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.025);
  content: "";
  pointer-events: none;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
}

.kicker,
.eyebrow,
.message-role,
.secure-mark,
.panel-index {
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-screen {
  display: grid;
  min-height: calc(100vh - 68px);
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 460px);
  gap: 72px;
  align-items: center;
}

.login-copy {
  max-width: 650px;
  padding: 0 0 12vh 18px;
  text-shadow: 0 12px 45px rgba(0, 0, 0, 0.76);
}

.kicker {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
  color: var(--gold-pale);
  font-size: 12px;
  font-weight: 800;
}

.kicker::before {
  width: 34px;
  height: 1px;
  background: var(--gold);
  content: "";
}

.login-copy h1 {
  max-width: 620px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 76px;
  font-weight: 500;
  line-height: 0.92;
}

.login-copy h1 span {
  color: #f7dcc0;
  font-style: italic;
}

.tagline {
  max-width: 500px;
  margin-top: 24px;
  color: #f0ddc8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1.55;
}

.title-rule {
  width: 210px;
  height: 1px;
  margin-top: 30px;
  overflow: hidden;
  background: rgba(242, 211, 164, 0.22);
}

.title-rule span {
  display: block;
  width: 72px;
  height: 100%;
  background: linear-gradient(90deg, var(--red-bright), var(--gold));
  animation: titleRule 6s var(--ease-out) infinite;
}

.auth-panel {
  width: 100%;
  padding: 34px;
  background:
    linear-gradient(125deg, rgba(160, 24, 21, 0.23), transparent 44%),
    linear-gradient(180deg, rgba(255, 239, 212, 0.12), transparent 38%),
    rgba(7, 11, 14, 0.66);
}

.auth-panel::before {
  position: absolute;
  top: 0;
  left: 34px;
  width: 84px;
  height: 2px;
  background: linear-gradient(90deg, var(--red-bright), var(--gold));
  content: "";
}

.panel-index {
  position: absolute;
  top: 24px;
  right: 28px;
  color: rgba(242, 211, 164, 0.26);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
}

.brand-row,
.topbar,
.account,
.modal-header,
.modal-actions,
.provider-state,
.meter-row,
.login-foot {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 16px;
  margin-bottom: 32px;
}

.mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 230, 193, 0.38);
  border-radius: 8px;
  color: #fff9ef;
  background: linear-gradient(145deg, #d44638, #8d1715 64%, #3c0908);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 16px 38px rgba(95, 10, 9, 0.38);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
}

.brand-row h2,
.account-modal h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.stack,
.account-grid {
  display: grid;
}

.stack {
  gap: 13px;
}

label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.input-frame,
.composer-field {
  position: relative;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(242, 211, 164, 0.2);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: rgba(3, 7, 10, 0.68);
  caret-color: var(--gold);
  transition:
    border-color 220ms ease,
    background 220ms ease,
    box-shadow 220ms ease;
}

input {
  min-height: 54px;
  padding: 0 46px 0 16px;
}

textarea {
  min-height: 84px;
  padding: 16px 100px 48px 17px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #817e7a;
}

input:focus,
textarea:focus {
  border-color: rgba(225, 183, 111, 0.72);
  background: rgba(3, 7, 10, 0.82);
  box-shadow:
    0 0 0 3px rgba(225, 183, 111, 0.09),
    0 18px 44px rgba(0, 0, 0, 0.2);
}

.input-status {
  position: absolute;
  top: 50%;
  right: 17px;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(225, 183, 111, 0.6);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.input-frame:focus-within .input-status {
  background: var(--gold);
  box-shadow: 0 0 14px rgba(225, 183, 111, 0.7);
}

button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fffaf2;
  background: linear-gradient(180deg, #d93c34, #ad201e);
  box-shadow: 0 14px 34px rgba(111, 12, 11, 0.35);
  cursor: pointer;
  font-weight: 750;
  transform: translateY(0);
  transition:
    transform 220ms var(--ease-out),
    border-color 220ms ease,
    background 220ms ease,
    box-shadow 220ms ease,
    opacity 220ms ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 40px rgba(111, 12, 11, 0.42),
    0 0 26px rgba(225, 183, 111, 0.1);
}

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

button:focus-visible {
  outline: 2px solid var(--gold-pale);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

button.secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 248, 237, 0.075);
  box-shadow: none;
}

button.secondary:hover {
  border-color: var(--line-strong);
  background: rgba(255, 248, 237, 0.13);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.mist-button {
  width: 100%;
  min-height: 56px;
  justify-content: space-between;
  margin-top: 3px;
  border: 1px solid rgba(255, 231, 194, 0.25);
  padding: 0 20px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.44);
}

.mist-button::before {
  position: absolute;
  inset: -160% -55%;
  background: linear-gradient(104deg, transparent 30%, rgba(255, 239, 211, 0.35) 48%, transparent 66%);
  content: "";
  filter: blur(12px);
  transform: translateX(-38%);
  animation: buttonMist 5.5s ease-in-out infinite;
}

.mist-button > span {
  position: relative;
  z-index: 1;
}

.button-arrow,
.send-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.23);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.14);
  transition: transform 260ms var(--ease-out), background 260ms ease;
}

.mist-button:hover .button-arrow {
  background: rgba(255, 255, 255, 0.14);
  transform: translateX(3px);
}

.login-foot {
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.hint,
.account,
.relay-status span,
.context-meter p {
  color: var(--muted);
}

.hint {
  font-size: 12px;
  line-height: 1.5;
}

.secure-mark {
  flex: 0 0 auto;
  color: rgba(225, 183, 111, 0.64);
  font-size: 10px;
  font-weight: 800;
}

.error {
  min-height: 18px;
  color: #ffb1a7;
  font-size: 12px;
  font-weight: 650;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 68px);
  gap: 18px;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 68px;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 4px 0;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.68);
}

.workspace-title {
  position: relative;
  padding-left: 18px;
}

.workspace-title::before {
  position: absolute;
  inset: 1px auto 2px 0;
  width: 2px;
  background: linear-gradient(180deg, var(--gold), var(--red));
  content: "";
}

.workspace-title h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
}

.account {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 12;
  gap: 12px;
  justify-content: flex-end;
  padding: 6px 6px 6px 14px;
  border: 1px solid rgba(242, 211, 164, 0.2);
  border-radius: 8px;
  background: rgba(5, 9, 12, 0.68);
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 248, 237, 0.08);
  backdrop-filter: blur(18px) saturate(118%);
  font-size: 12px;
}

.account-button {
  min-width: 104px;
  min-height: 40px;
}

.account-dot,
.meter-row i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(110, 224, 181, 0.65);
}

.console-panel {
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 20%),
    rgba(7, 11, 14, 0.65);
}

.console-edge {
  position: absolute;
  top: 0;
  left: 26px;
  right: 26px;
  height: 1px;
  overflow: hidden;
}

.console-edge span {
  display: block;
  width: 28%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: consoleEdge 8s ease-in-out infinite;
}

.relay-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  grid-row: 2;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(110, 224, 181, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(110, 224, 181, 0.09), transparent 52%),
    rgba(3, 8, 11, 0.54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: statusIn 380ms var(--ease-out) both;
  transition:
    opacity 320ms ease,
    transform 380ms var(--ease-out);
}

.relay-status.entering,
.relay-status.leaving {
  opacity: 0;
  transform: translateY(-8px);
}

.relay-status.warn {
  border-color: rgba(225, 183, 111, 0.25);
  background:
    linear-gradient(90deg, rgba(225, 183, 111, 0.1), transparent 52%),
    rgba(3, 8, 11, 0.54);
}

.relay-status p {
  font-size: 13px;
  font-weight: 800;
}

.relay-status span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.relay-status strong {
  color: var(--gold);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.status-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 20px rgba(110, 224, 181, 0.62);
  animation: relayPulse 1.5s ease-out infinite;
}

.relay-status.warn .status-pulse {
  background: var(--gold);
  box-shadow: 0 0 20px rgba(225, 183, 111, 0.62);
  animation-name: relayPulseGold;
}

.transcript {
  grid-row: 1;
  min-height: 46vh;
  overflow: auto;
  padding: 4px 8px 16px 4px;
  scroll-behavior: smooth;
  scrollbar-color: rgba(225, 183, 111, 0.32) transparent;
  scrollbar-width: thin;
}

.transcript::-webkit-scrollbar {
  width: 7px;
}

.transcript::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(225, 183, 111, 0.3);
}

.message {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  animation: messageIn 440ms var(--ease-out) both;
}

.message-role {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--gold);
  font-size: 11px;
  font-weight: 850;
}

.message-role::before {
  width: 14px;
  height: 1px;
  background: currentColor;
  content: "";
  opacity: 0.7;
}

.message pre {
  min-height: 0;
  margin: 0;
  padding: 17px 18px;
  overflow: auto;
  border: 1px solid rgba(242, 211, 164, 0.13);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(3, 7, 10, 0.43);
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-content {
  display: grid;
  gap: 10px;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message-images img {
  width: min(220px, 100%);
  max-height: 240px;
  border: 1px solid rgba(242, 211, 164, 0.2);
  border-radius: 8px;
  object-fit: contain;
  background: rgba(3, 7, 10, 0.58);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.message.user pre {
  border-color: rgba(228, 76, 65, 0.3);
  background:
    linear-gradient(90deg, rgba(173, 32, 30, 0.1), transparent 42%),
    rgba(3, 7, 10, 0.45);
}

.composer {
  display: grid;
  grid-row: 3;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding-top: 14px;
  border-top: 1px solid rgba(242, 211, 164, 0.1);
}

.composer-note {
  grid-row: 4;
  margin: 0;
  color: rgba(246, 232, 206, 0.58);
  font-size: 12px;
  line-height: 1.45;
}

.composer-note strong {
  color: rgba(225, 183, 111, 0.82);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.console-panel > .error {
  grid-row: 5;
}

.command-guide {
  position: fixed;
  left: 28px;
  bottom: 116px;
  z-index: 3;
  display: none;
  width: min(286px, max(180px, calc((100vw - 1180px) / 2 - 56px)));
  padding: 12px;
  border: 1px solid rgba(242, 211, 164, 0.11);
  border-radius: 8px;
  background: rgba(4, 8, 10, 0.46);
  box-shadow: none;
  backdrop-filter: blur(8px);
}

.workspace-mode .command-guide {
  display: block;
}

.guide-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.guide-heading strong {
  color: rgba(246, 232, 206, 0.86);
  font-size: 12px;
}

.guide-list {
  display: grid;
  gap: 4px;
}

.guide-command {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  min-height: 32px;
  padding: 6px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  text-align: left;
  transform: none;
}

.guide-command:hover,
.guide-command:focus-visible {
  background: rgba(225, 183, 111, 0.08);
  box-shadow: none;
  transform: none;
}

.guide-command code {
  color: var(--gold);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.guide-command span {
  min-width: 0;
  color: rgba(246, 232, 206, 0.62);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.38;
  white-space: normal;
}

.guide-copy-status {
  min-height: 14px;
  margin: 6px 0 0;
  color: rgba(110, 224, 181, 0.82);
  font-size: 11px;
  font-weight: 750;
}

.composer textarea {
  height: 86px;
  min-height: 86px;
  resize: none;
}

.composer-field {
  border-radius: 8px;
  transition: box-shadow 180ms ease;
}

.composer-field.drag-active {
  box-shadow:
    0 0 0 2px rgba(225, 183, 111, 0.7),
    0 0 34px rgba(225, 183, 111, 0.16);
}

.attachment-tray {
  display: flex;
  gap: 9px;
  padding: 0 0 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.attachment-chip {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  overflow: hidden;
  border: 1px solid rgba(242, 211, 164, 0.22);
  border-radius: 8px;
  background: rgba(3, 7, 10, 0.68);
}

.attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  padding: 0;
  color: #fff;
  background: rgba(4, 7, 9, 0.82);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 15px;
  line-height: 1;
}

.attachment-remove:hover {
  background: var(--red);
}

.attach-button {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 2;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 50%;
  padding: 0;
  color: var(--gold-pale);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}

.command-hint {
  position: absolute;
  right: 14px;
  bottom: 17px;
  color: rgba(225, 183, 111, 0.56);
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  pointer-events: none;
}

#runButton {
  width: 96px;
  min-width: 96px;
  min-height: 52px;
  flex-direction: row;
  padding: 0 13px;
}

#runButton .send-icon {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

#runButton .send-icon {
  transition: transform 240ms var(--ease-out);
}

#runButton:hover .send-icon {
  transform: translateY(-3px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 1;
  background: rgba(2, 5, 7, 0.47);
  backdrop-filter: blur(14px) saturate(112%);
  transition: opacity 340ms ease;
}

.modal-backdrop.entering,
.modal-backdrop.leaving {
  opacity: 0;
}

.account-modal {
  width: min(650px, 100%);
  padding: 30px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition:
    opacity 340ms ease,
    transform 480ms var(--ease-out);
}

.modal-backdrop.entering .account-modal,
.modal-backdrop.leaving .account-modal {
  opacity: 0;
  transform: translateY(24px) scale(0.97);
}

.modal-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 25px;
  font-weight: 350;
}

.account-grid {
  gap: 11px;
}

.account-grid label:not(:first-child) {
  margin-top: 5px;
}

.provider-state {
  justify-content: space-between;
  gap: 16px;
  margin-top: 3px;
  padding: 13px 15px;
  border: 1px solid rgba(242, 211, 164, 0.14);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(3, 7, 10, 0.45);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.modal-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 12px;
}

.context-meter {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  width: min(218px, calc(100vw - 40px));
  padding: 10px 11px;
  border: 1px solid rgba(242, 211, 164, 0.2);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(4, 8, 11, 0.72);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px) saturate(115%);
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 420ms ease,
    transform 520ms var(--ease-out);
}

.context-meter.entering,
.context-meter.leaving {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
}

.meter-row {
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}

.meter-row span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.meter-row strong {
  color: var(--gold-pale);
  font-family: Consolas, "Courier New", monospace;
}

.meter-track {
  height: 4px;
  margin: 7px 0 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter-track div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  box-shadow: 0 0 12px rgba(110, 224, 181, 0.36);
  transition: width 480ms var(--ease-out), background 280ms ease;
}

.context-meter.warn .meter-track div {
  background: linear-gradient(90deg, var(--gold), var(--red-bright));
}

.context-meter.warn .meter-row i {
  background: var(--gold);
  box-shadow: 0 0 12px rgba(225, 183, 111, 0.7);
}

.context-meter.danger {
  border-color: rgba(255, 112, 96, 0.7);
}

.context-meter p {
  overflow: hidden;
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-note {
  margin-top: -5px;
  color: var(--muted);
  font-size: 11px;
}

#runButton.is-stopping {
  border-color: rgba(255, 177, 167, 0.42);
  background: linear-gradient(135deg, #681818, #a82121);
}

#runButton.is-stopping .send-icon,
#runButton.is-stopping:hover .send-icon {
  border-radius: 7px;
  transform: none;
}

.message-thinking {
  padding: 10px 14px;
  border-left: 2px solid rgba(225, 183, 111, 0.48);
  color: var(--muted);
  background: rgba(225, 183, 111, 0.045);
  font-size: 12px;
}

.message-thinking summary {
  color: var(--gold-pale);
  cursor: pointer;
  font-weight: 750;
}

.message-thinking pre {
  margin-top: 9px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.message.streaming pre {
  border-color: rgba(110, 224, 181, 0.2);
}

.message.streaming .message-role::after {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(110, 224, 181, 0.7);
  content: "";
  animation: relayPulse 1.5s ease-out infinite;
}

@media (max-width: 880px) {
  .shell {
    width: min(100% - 28px, 760px);
    padding: 20px 0;
  }

  .login-screen {
    min-height: calc(100vh - 40px);
    grid-template-columns: 1fr;
    gap: 30px;
    align-content: center;
  }

  .login-copy {
    padding: 0;
  }

  .login-copy h1 {
    font-size: 56px;
  }

  .tagline {
    font-size: 17px;
  }

  .auth-panel {
    max-width: 520px;
    justify-self: end;
  }

  .workspace {
    min-height: calc(100vh - 40px);
  }
}

@media (max-width: 620px) {
  .shell {
    width: calc(100% - 20px);
    padding: 12px 0;
  }

  .login-screen {
    min-height: calc(100vh - 24px);
    gap: 22px;
  }

  .login-copy h1 {
    font-size: 42px;
  }

  .tagline {
    max-width: 320px;
    margin-top: 14px;
    font-size: 15px;
  }

  .title-rule {
    margin-top: 18px;
  }

  .auth-panel,
  .console-panel,
  .account-modal {
    padding: 18px;
  }

  .brand-row {
    margin-bottom: 24px;
  }

  .login-foot,
  .topbar,
  .provider-state {
    align-items: flex-start;
    flex-direction: column;
  }

  .secure-mark {
    display: none;
  }

  .workspace {
    min-height: calc(100vh - 24px);
  }

  .topbar {
    gap: 12px;
  }

  .account {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: auto;
    max-width: calc(100vw - 20px);
    justify-content: flex-end;
    padding: 5px;
  }

  .account #clientInfo {
    display: none;
  }

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

  #runButton {
    width: 100%;
    min-height: 52px;
    flex-direction: row;
  }

  .relay-status {
    grid-template-columns: auto 1fr;
  }

  .relay-status strong {
    display: none;
  }

  .context-meter {
    right: 10px;
    bottom: 10px;
  }

  .command-guide {
    position: static;
    width: 100%;
    margin-top: 12px;
  }

  .modal-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@keyframes mistOne {
  from { transform: translate3d(-7%, 4%, 0) scale(1.04); }
  to { transform: translate3d(8%, -2%, 0) scale(1.12); }
}

@keyframes mistTwo {
  from { transform: translate3d(7%, 1%, 0) scale(1.08); }
  to { transform: translate3d(-9%, -4%, 0) scale(1.16); }
}

@keyframes titleRule {
  0%, 100% { transform: translateX(-10px); opacity: 0.75; }
  50% { transform: translateX(138px); opacity: 1; }
}

@keyframes buttonMist {
  0%, 100% { transform: translateX(-42%) rotate(0deg); opacity: 0.45; }
  50% { transform: translateX(42%) rotate(2deg); opacity: 0.8; }
}

@keyframes consoleEdge {
  0%, 100% { transform: translateX(-20%); opacity: 0.45; }
  50% { transform: translateX(280%); opacity: 1; }
}

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

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

@keyframes relayPulse {
  0% { box-shadow: 0 0 0 0 rgba(110, 224, 181, 0.5), 0 0 18px rgba(110, 224, 181, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(110, 224, 181, 0), 0 0 18px rgba(110, 224, 181, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(110, 224, 181, 0), 0 0 18px rgba(110, 224, 181, 0.55); }
}

@keyframes relayPulseGold {
  0% { box-shadow: 0 0 0 0 rgba(225, 183, 111, 0.5), 0 0 18px rgba(225, 183, 111, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(225, 183, 111, 0), 0 0 18px rgba(225, 183, 111, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(225, 183, 111, 0), 0 0 18px rgba(225, 183, 111, 0.55); }
}
