:root {
  color-scheme: dark;
  --bg: #050b14;
  --surface: rgba(13, 27, 44, 0.82);
  --surface-strong: #0e1d2e;
  --line: rgba(128, 181, 220, 0.15);
  --text: #f3f8fc;
  --muted: #8ea5b7;
  --cyan: #50d8ff;
  --blue: #3986ff;
  --green: #5ce0aa;
  --danger: #ff718f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(34, 118, 181, 0.22), transparent 38%),
    linear-gradient(180deg, #07111f 0%, var(--bg) 56%);
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 1120px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(80, 216, 255, 0.52);
  border-radius: 12px;
  color: var(--cyan);
  font-weight: 800;
  box-shadow: inset 0 0 18px rgba(80, 216, 255, 0.13), 0 0 22px rgba(80, 216, 255, 0.08);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.9rem; letter-spacing: 0.18em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.66rem; letter-spacing: 0.06em; }

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.connection i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7c8a96;
  box-shadow: 0 0 0 4px rgba(124, 138, 150, 0.1);
}

.connection.online i { background: var(--green); box-shadow: 0 0 0 4px rgba(92, 224, 170, 0.1), 0 0 14px rgba(92, 224, 170, 0.55); }
.connection.error i { background: var(--danger); }

main { padding: 18px 0 36px; }

.assistant-panel {
  min-height: 510px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 18px 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(17, 38, 61, 0.74), rgba(6, 14, 25, 0.9));
  box-shadow: var(--shadow);
}

.ambient {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(50px);
  pointer-events: none;
}

.ambient-one { width: 250px; height: 250px; top: 12%; left: 12%; background: rgba(38, 118, 255, 0.13); }
.ambient-two { width: 280px; height: 280px; right: 5%; bottom: -5%; background: rgba(34, 207, 255, 0.1); }

.eyebrow {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 8vw, 3.4rem); letter-spacing: -0.04em; }
.assistant-subtitle { margin-bottom: 30px; color: var(--muted); font-size: 0.94rem; }

.voice-button {
  width: 140px;
  height: 140px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.voice-button:disabled { cursor: not-allowed; filter: grayscale(0.8); opacity: 0.55; }
.voice-button:focus-visible { outline: 3px solid rgba(80, 216, 255, 0.8); outline-offset: 8px; }

.voice-ring {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(80, 216, 255, 0.4);
  border-radius: 50%;
  box-shadow: inset 0 0 34px rgba(80, 216, 255, 0.08), 0 0 24px rgba(80, 216, 255, 0.1);
}

.ring-two { inset: 20px; border-color: rgba(80, 216, 255, 0.2); }

.voice-core {
  width: 76px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #45d6ff, #276dff);
  box-shadow: 0 10px 34px rgba(38, 135, 255, 0.36), inset 0 1px rgba(255, 255, 255, 0.45);
  transition: transform 180ms ease;
}

.voice-core svg { width: 31px; fill: currentColor; }
.voice-button:active .voice-core { transform: scale(0.94); }

.voice-button.listening .ring-one { animation: pulse 1.15s infinite ease-out; }
.voice-button.listening .ring-two { animation: pulse 1.15s 260ms infinite ease-out; }
.voice-button.listening .voice-core { background: linear-gradient(145deg, #ff6d92, #d33f75); box-shadow: 0 10px 42px rgba(255, 80, 132, 0.42); }

@keyframes pulse {
  0% { transform: scale(0.86); opacity: 0.95; }
  100% { transform: scale(1.45); opacity: 0; }
}

.transcript-wrap {
  width: min(100%, 590px);
  min-height: 84px;
  margin-top: 30px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 9, 17, 0.48);
  text-align: center;
}

.transcript-label { color: var(--muted); font-size: 0.67rem; letter-spacing: 0.12em; }
.live-transcript { margin: 7px 0 0; min-height: 1.5em; font-size: 1.04rem; line-height: 1.5; }
.live-transcript.muted { color: var(--muted); }

.voice-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.secondary-button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #c8d9e6;
  background: rgba(13, 30, 47, 0.78);
  cursor: pointer;
}
.secondary-button.enabled { color: var(--green); border-color: rgba(71, 220, 170, 0.3); background: rgba(71, 220, 170, 0.08); }

.content-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-top: 16px; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 16px 42px rgba(0, 0, 0, 0.18); backdrop-filter: blur(18px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin-bottom: 0; font-size: 1.2rem; }
.mode-badge, .count-badge { padding: 6px 10px; border-radius: 999px; color: var(--muted); background: rgba(80, 216, 255, 0.07); font-size: 0.72rem; }
.count-badge { min-width: 30px; color: var(--cyan); text-align: center; }

.messages { min-height: 190px; max-height: 430px; overflow: auto; display: flex; flex-direction: column; gap: 12px; margin: 20px 0; padding-right: 4px; }
.message { max-width: 88%; padding: 13px 15px; border-radius: 17px; background: rgba(5, 14, 24, 0.66); }
.message.user { align-self: flex-end; background: linear-gradient(145deg, rgba(35, 102, 165, 0.7), rgba(30, 77, 129, 0.72)); }
.message-role { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 0.6rem; font-weight: 800; letter-spacing: 0.14em; }
.message.user .message-role { color: #cbeeff; }
.message p { margin-bottom: 0; font-size: 0.93rem; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.composer textarea {
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(3, 10, 19, 0.7);
  outline: none;
}
.composer textarea:focus { border-color: rgba(80, 216, 255, 0.55); box-shadow: 0 0 0 3px rgba(80, 216, 255, 0.08); }
.composer button {
  min-width: 76px;
  border: 0;
  border-radius: 14px;
  color: #03111b;
  background: linear-gradient(145deg, #68e1ff, #4f9dff);
  font-weight: 800;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: wait; }

.jobs-list { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.empty-state { margin: 26px 0; color: var(--muted); font-size: 0.86rem; line-height: 1.6; text-align: center; }
.job-item { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(4, 13, 23, 0.58); }
.job-head { display: flex; justify-content: space-between; gap: 10px; }
.job-title { margin: 0; font-size: 0.9rem; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.job-state { flex: none; color: var(--cyan); font-size: 0.7rem; }
.job-state.completed { color: var(--green); }
.job-state.failed, .job-state.canceled { color: var(--danger); }
.progress-track { height: 5px; margin: 12px 0 8px; overflow: hidden; border-radius: 999px; background: rgba(137, 169, 194, 0.12); }
.progress-value { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width 300ms ease; }
.progress-track.indeterminate .progress-value { animation: job-progress 1.35s ease-in-out infinite; }
@keyframes job-progress { 0% { transform: translateX(-115%); } 100% { transform: translateX(285%); } }
.job-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.7rem; }
.job-cancel { padding: 5px 9px; border: 1px solid rgba(255, 113, 143, 0.22); border-radius: 8px; color: #ffacc0; background: rgba(255, 113, 143, 0.08); cursor: pointer; }
.job-result { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.job-result summary { color: var(--cyan); cursor: pointer; font-size: 0.78rem; }
.job-result pre { max-height: 360px; overflow: auto; margin: 10px 0; padding: 12px; border-radius: 12px; color: #d9e8f3; background: rgba(2, 8, 15, 0.72); font: 0.76rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.job-result button, .job-questions button { min-height: 36px; padding: 0 12px; border: 1px solid rgba(80, 216, 255, 0.28); border-radius: 10px; color: var(--cyan); background: rgba(80, 216, 255, 0.08); cursor: pointer; }
.job-questions { display: grid; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.job-questions fieldset { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.job-questions legend { margin-bottom: 7px; color: #dceaf4; font-size: 0.8rem; line-height: 1.5; }
.question-option { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.job-questions textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: rgba(3, 10, 19, 0.72); }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 18px 3px 26px; color: #60788a; font-size: 0.68rem; }
.toasts { position: fixed; z-index: 10; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: min(86vw, 360px); padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: #112336; box-shadow: var(--shadow); font-size: 0.84rem; }
.toast.error { border-color: rgba(255, 113, 143, 0.36); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.login-body { display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
.login-shell { width: min(100%, 430px); }
.login-card { padding: 32px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 28px; }
.login-card h1 { margin-bottom: 8px; font-size: 2rem; }
.login-hint { color: var(--muted); }
.login-form { display: grid; gap: 9px; margin-top: 28px; }
.login-form label { margin-top: 8px; color: #bdd0df; font-size: 0.78rem; }
.login-form input { min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: rgba(3, 10, 19, 0.7); outline: none; font: inherit; }
.login-form input:focus { border-color: rgba(80, 216, 255, 0.55); box-shadow: 0 0 0 3px rgba(80, 216, 255, 0.08); }
.login-form button { min-height: 50px; margin-top: 16px; border: 0; border-radius: 14px; color: #03111b; background: linear-gradient(145deg, #68e1ff, #4f9dff); font-weight: 800; cursor: pointer; }
.login-form button:disabled { opacity: 0.55; }
.login-error { min-height: 1.5em; margin: 4px 0 0; color: var(--danger); font-size: 0.8rem; }

@media (max-width: 760px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .topbar { min-height: 64px; }
  .brand small { display: none; }
  main { padding-top: 12px; }
  .assistant-panel { min-height: calc(100dvh - 92px); max-height: 730px; padding-top: 28px; border-radius: 24px; }
  .content-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; border-radius: 19px; }
  .messages { max-height: 52vh; }
  footer { flex-direction: column; gap: 4px; }
}

@media (max-width: 390px) {
  .assistant-panel { min-height: 570px; }
  .voice-button { width: 126px; height: 126px; }
  .voice-core { width: 68px; }
  .composer { grid-template-columns: 1fr; }
  .composer button { min-height: 46px; }
}

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