:root {
  color-scheme: dark;
  --bg: #0b0e10;
  --panel: rgba(22, 27, 30, 0.9);
  --panel-strong: #171c1f;
  --panel-soft: #20262a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f6f3;
  --muted: #9ba5a2;
  --accent: #b9f67a;
  --accent-ink: #15200c;
  --danger: #ff9b9b;
  --warning: #ffd17a;
  --blue: #91caff;
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "SF Pro Display", "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(133, 190, 94, 0.14), transparent 34rem),
    radial-gradient(circle at 100% 104%, rgba(100, 142, 166, 0.13), transparent 31rem),
    var(--bg);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.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;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(3px);
  pointer-events: none;
}

.ambient-one {
  width: 24rem;
  height: 24rem;
  top: 18%;
  right: -19rem;
  border: 1px solid rgba(185, 246, 122, 0.08);
  box-shadow: 0 0 0 5rem rgba(185, 246, 122, 0.012), 0 0 0 11rem rgba(185, 246, 122, 0.009);
}

.ambient-two {
  width: 18rem;
  height: 18rem;
  left: -11rem;
  bottom: 10%;
  border: 1px solid rgba(145, 202, 255, 0.07);
  box-shadow: 0 0 0 4rem rgba(145, 202, 255, 0.012);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 980px);
  min-height: 66px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  margin: 0 auto;
  background: linear-gradient(to bottom, rgba(11, 14, 16, 0.94), rgba(11, 14, 16, 0.72), transparent);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(185, 246, 122, 0.36);
  border-radius: 12px;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(185, 246, 122, 0.16), rgba(185, 246, 122, 0.025));
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  box-shadow: inset 0 0 16px rgba(185, 246, 122, 0.06);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.connection-state::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6e7774;
  content: "";
}

.connection-state[data-state="online"]::before {
  background: var(--accent);
  box-shadow: 0 0 9px rgba(185, 246, 122, 0.75);
}

.connection-state[data-state="error"]::before {
  background: var(--danger);
}

.icon-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.mode-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 16px;
  border-top: 1px solid rgba(255, 209, 122, 0.08);
  border-bottom: 1px solid rgba(255, 209, 122, 0.08);
  color: #d8c394;
  background: rgba(255, 209, 122, 0.045);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.mode-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warning);
}

.pair-view {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 100px);
  padding: 32px 18px calc(42px + var(--safe-bottom));
}

.pair-card {
  width: min(100%, 480px);
  padding: clamp(28px, 7vw, 46px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.035), transparent 42%),
    rgba(20, 24, 27, 0.88);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
}

.pair-symbol {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 26px;
  border: 1px solid rgba(185, 246, 122, 0.25);
  border-radius: 19px;
  background: rgba(185, 246, 122, 0.07);
}

.pair-symbol::before {
  width: 18px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  content: "";
}

.pair-symbol::after {
  position: absolute;
  top: 16px;
  width: 12px;
  height: 13px;
  border: 2px solid var(--accent);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  content: "";
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.pair-card h1,
.empty-state h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.pair-card h1 {
  font-size: clamp(31px, 8vw, 42px);
}

.pair-copy {
  margin: 16px 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

code {
  color: #dcebd0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.pair-form label {
  display: block;
  margin-bottom: 8px;
  color: #c7cfcc;
  font-size: 12px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  min-width: 0;
  flex: 1;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(0, 0, 0, 0.2);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
}

.input-row input:focus {
  border-color: rgba(185, 246, 122, 0.48);
  box-shadow: 0 0 0 3px rgba(185, 246, 122, 0.07);
}

.primary-button {
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
}

.primary-button:disabled,
.send-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.form-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.security-note {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: #747f7c;
  font-size: 11px;
  line-height: 1.6;
}

.chat-view {
  width: min(100%, 900px);
  min-height: calc(100vh - 100px);
  padding: 22px max(14px, env(safe-area-inset-left)) calc(126px + var(--safe-bottom)) max(14px, env(safe-area-inset-right));
  margin: 0 auto;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.empty-state {
  min-height: calc(100vh - 310px);
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 40px 12px;
  text-align: center;
}

.empty-orbit {
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 28px;
  border: 1px solid rgba(185, 246, 122, 0.19);
  border-radius: 50%;
}

.empty-orbit::before,
.empty-orbit::after {
  position: absolute;
  border-radius: 50%;
  content: "";
}

.empty-orbit::before {
  inset: 12px;
  border: 1px dashed rgba(185, 246, 122, 0.22);
}

.empty-orbit::after {
  width: 9px;
  height: 9px;
  top: 31px;
  left: 31px;
  background: var(--accent);
  box-shadow: 0 0 20px rgba(185, 246, 122, 0.7);
}

.empty-state h1 {
  font-size: clamp(34px, 8vw, 48px);
}

.empty-state > p:not(.eyebrow) {
  max-width: 550px;
  margin: 17px auto 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.suggestion {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #bdc6c3;
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  cursor: pointer;
}

.suggestion:hover {
  color: var(--text);
  border-color: rgba(185, 246, 122, 0.25);
}

.task-entry {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: enter 240ms ease-out both;
}

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

.message {
  border-radius: var(--radius);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.user-message {
  align-self: flex-end;
  width: min(90%, 650px);
  padding: 15px 18px;
  border: 1px solid rgba(185, 246, 122, 0.13);
  border-bottom-right-radius: 7px;
  background: linear-gradient(145deg, rgba(185, 246, 122, 0.12), rgba(185, 246, 122, 0.045));
}

.user-message p {
  margin: 0;
  white-space: pre-wrap;
}

.agent-message {
  align-self: flex-start;
  width: min(100%, 760px);
  padding: 17px;
  border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
  background: rgba(24, 29, 32, 0.86);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.14);
}

.task-meta,
.task-actions,
.delivery-heading {
  display: flex;
  align-items: center;
}

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

.task-meta time {
  margin-left: auto;
  color: #727c79;
  font-size: 10px;
}

.status-pill,
.executor-badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.status-queued,
.status-running,
.status-cancel_requested {
  color: var(--blue);
  background: rgba(145, 202, 255, 0.1);
}

.status-completed {
  color: var(--accent);
  background: rgba(185, 246, 122, 0.09);
}

.status-failed,
.status-cancelled {
  color: var(--danger);
  background: rgba(255, 155, 155, 0.09);
}

.status-unknown_outcome {
  color: var(--warning);
  background: rgba(255, 209, 122, 0.09);
}

.executor-badge {
  color: #9ea8a5;
  border: 1px solid var(--line);
}

.task-detail {
  margin: 13px 0 0;
  color: #d3d9d6;
  font-size: 13px;
}

.task-actions {
  gap: 10px;
  margin-top: 14px;
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  font-size: 11px;
  cursor: pointer;
}

.text-button.danger {
  color: var(--danger);
}

.detail-button {
  margin-top: 9px;
  color: var(--accent);
}

.task-id {
  margin-left: auto;
  color: #5d6764;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.file-cards,
.delivery-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.file-card,
.delivery-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.13);
}

.file-card strong,
.delivery-card strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card span,
.delivery-card span {
  grid-column: 1;
  color: #78827f;
  font-size: 10px;
}

.delivery-heading {
  margin: 16px 0 0;
  color: #9da6a3;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.delivery-card {
  color: var(--text);
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.delivery-card:hover {
  border-color: rgba(185, 246, 122, 0.24);
  background: rgba(185, 246, 122, 0.035);
}

.download-arrow {
  grid-column: 2 !important;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--accent) !important;
  font-size: 17px !important;
}

.composer {
  position: fixed;
  z-index: 25;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 900px);
  padding: 12px max(14px, env(safe-area-inset-left)) calc(11px + var(--safe-bottom)) max(14px, env(safe-area-inset-right));
  margin: 0 auto;
  background: linear-gradient(to top, rgba(11, 14, 16, 0.98) 56%, rgba(11, 14, 16, 0.72), transparent);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(27, 32, 35, 0.96);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.composer.sending .composer-box {
  border-color: rgba(185, 246, 122, 0.22);
}

.composer-box textarea {
  min-height: 38px;
  max-height: 180px;
  min-width: 0;
  flex: 1;
  padding: 8px 3px;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  background: transparent;
  line-height: 1.45;
}

.composer-box textarea::placeholder {
  color: #727c79;
}

.attach-button,
.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  cursor: pointer;
}

.attach-button {
  border: 1px solid var(--line);
  color: #9ea8a5;
  background: rgba(255, 255, 255, 0.025);
  font-size: 24px;
  font-weight: 300;
}

.send-button {
  border: 0;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 21px;
  font-weight: 800;
}

.attachment-list {
  display: flex;
  gap: 7px;
  padding: 0 2px 8px;
  overflow-x: auto;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 270px;
  padding: 7px 8px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #c1c9c6;
  background: rgba(31, 37, 40, 0.94);
  font-size: 10px;
  white-space: nowrap;
}

.attachment-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-chip button {
  padding: 0 4px;
  border: 0;
  color: var(--muted);
  background: none;
  font-size: 16px;
  cursor: pointer;
}

.composer-hint {
  margin: 6px 0 0;
  color: #5f6966;
  font-size: 9px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(108px + var(--safe-bottom));
  left: 16px;
  width: fit-content;
  max-width: min(92vw, 480px);
  padding: 11px 14px;
  margin: auto;
  border: 1px solid rgba(185, 246, 122, 0.2);
  border-radius: 13px;
  color: #e4eadf;
  background: rgba(36, 43, 40, 0.97);
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.35);
  font-size: 12px;
}

.toast.error {
  border-color: rgba(255, 155, 155, 0.25);
  color: #ffd2d2;
}

@media (min-width: 760px) {
  .topbar {
    min-height: 74px;
  }

  .chat-view {
    padding-top: 34px;
    padding-bottom: 142px;
  }

  .user-message {
    width: min(74%, 650px);
  }

  .agent-message {
    width: min(88%, 760px);
    padding: 20px;
  }

  .composer {
    padding-bottom: 18px;
  }
}

@media (max-width: 390px) {
  .brand small,
  .connection-state {
    display: none;
  }

  .pair-card {
    padding: 26px 21px;
  }

  .input-row {
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }
}

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