:root {
  --bg: #eef4ff;
  --bg-soft: #f7faff;
  --panel: rgba(255, 255, 255, 0.58);
  --panel-strong: rgba(255, 255, 255, 0.76);
  --card: rgba(255, 255, 255, 0.68);
  --line: rgba(255, 255, 255, 0.62);
  --line-strong: rgba(10, 132, 255, 0.24);
  --text: #122542;
  --muted: #61728d;
  --soft: #34506f;
  --accent: #0a84ff;
  --accent-2: #64d2ff;
  --gold: #ffb340;
  --success: #34c759;
  --danger: #ff453a;
  --shadow: 0 20px 64px rgba(49, 74, 122, 0.16);
  --shadow-soft: 0 10px 30px rgba(88, 118, 168, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(100, 210, 255, 0.36), transparent 26%),
    radial-gradient(circle at 86% 8%, rgba(10, 132, 255, 0.24), transparent 26%),
    radial-gradient(circle at 52% 88%, rgba(175, 82, 222, 0.08), transparent 28%),
    linear-gradient(180deg, #f7fbff 0%, #eef4ff 44%, #e9f0fb 100%);
}

body.sheet-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 22%),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.72), transparent 32%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.14;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 94%);
}

a {
  color: inherit;
}

button,
a,
input,
textarea,
select,
.list-item,
.target-switch-chip,
.auth-switch,
.tab-link,
.nav-link {
  -webkit-tap-highlight-color: transparent;
}

.client-app {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 12px 14px 94px;
}

.glass-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
}

.status-card,
.signal-card,
.panel-card,
.subpanel,
.utility-panel,
.mobile-tabbar,
.profile-spotlight,
.session-box,
.status-box,
.list-item,
.quick-card,
.message {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.52));
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.panel-card,
.subpanel,
.utility-panel,
.mobile-tabbar {
  border-radius: 30px;
}

.panel-card,
.utility-panel {
  padding: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 22px;
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #58a6ff 0%, #0a84ff 48%, #7dd3fc 100%);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.38),
    0 14px 30px rgba(10, 132, 255, 0.24);
}

.desktop-link {
  display: none;
}

.eyebrow,
.panel-kicker,
.field span,
.signal-card span,
.status-card span {
  display: block;
  margin: 0 0 10px;
  color: rgba(10, 132, 255, 0.78);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: -0.05em;
}

h3,
h4 {
  margin-bottom: 10px;
}

.hero-copy,
.muted-copy,
.panel-desc,
.session-box,
.status-box {
  color: var(--muted);
  line-height: 1.68;
}

.page-main,
.signal-grid,
.split-grid,
.compact-grid,
.quick-grid,
.list-board,
.status-card-stack {
  display: grid;
  gap: 16px;
}

.signal-grid,
.page-main {
  margin-bottom: 16px;
}

.hero-card-head,
.panel-title,
.panel-actions,
.hero-actions,
.stack-actions,
.composer-actions,
.item-actions,
.pill-row,
.list-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.panel-title {
  margin-bottom: 16px;
}

.status-card,
.signal-card,
.profile-spotlight,
.session-box,
.status-box,
.list-item,
.quick-card {
  padding: 16px;
  border-radius: 24px;
}

.signal-card strong,
.status-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 700;
}

.field {
  display: block;
  margin-bottom: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 20px;
  padding: 14px 16px;
  color: var(--text);
  font: inherit;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(10, 132, 255, 0.42);
  box-shadow:
    0 0 0 4px rgba(10, 132, 255, 0.12),
    0 10px 20px rgba(10, 132, 255, 0.08);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.btn,
.nav-link,
.tab-link {
  border: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.btn:hover,
.nav-link:hover,
.tab-link:hover {
  transform: translateY(-1px);
}

.btn:active,
.nav-link:active,
.tab-link:active,
.sheet-close:active,
.desktop-link:active,
.target-switch-chip:active,
.auth-switch:active {
  transform: scale(0.985);
  filter: brightness(0.985);
}

.btn:focus,
.btn:focus-visible,
.nav-link:focus,
.nav-link:focus-visible,
.tab-link:focus,
.tab-link:focus-visible,
.sheet-close:focus,
.sheet-close:focus-visible,
.desktop-link:focus,
.desktop-link:focus-visible,
.target-switch-chip:focus,
.target-switch-chip:focus-visible,
.auth-switch:focus,
.auth-switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.62), 0 8px 18px rgba(49, 74, 122, 0.1);
}

.btn {
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(31, 60, 115, 0.1);
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(180deg, #34a1ff 0%, #0a84ff 100%);
}

.btn-secondary {
  color: #24405f;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.btn-gold {
  color: #6d4600;
  background: linear-gradient(180deg, #ffd684 0%, #ffbe4d 100%);
}

.btn:disabled {
  opacity: 0.66;
  cursor: wait;
}

.nav-strip {
  display: none;
}

.nav-link,
.tab-link {
  width: 100%;
  padding: 10px 12px;
  border-radius: 15px;
  border: 1px solid transparent;
  text-align: center;
  color: #37506e;
  background: rgba(255, 255, 255, 0.16);
  text-decoration: none;
  font-size: 13px;
}

.nav-link.active,
.tab-link.active {
  color: #274864;
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(49, 74, 122, 0.08);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.ok {
  color: #0b6b4d;
  background: rgba(52, 199, 89, 0.12);
}

.pill.warn {
  color: #8a5b00;
  background: rgba(255, 179, 64, 0.14);
}

.pill.bad {
  color: #a33752;
  background: rgba(255, 69, 58, 0.1);
}

.persona-name-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  vertical-align: middle;
}

.persona-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-builtin-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  color: #0a67c7;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  background: rgba(10, 132, 255, 0.12);
}

.list-item.active {
  border-color: rgba(255, 255, 255, 0.86);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.6),
    0 16px 28px rgba(49, 74, 122, 0.08);
}

.messages {
  min-height: 340px;
  max-height: 640px;
  overflow: auto;
  padding-top: 4px;
}

.message {
  margin-bottom: 12px;
  padding: 16px 18px;
  border-radius: 24px;
}

.message-role {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-role.user {
  color: #ffffff;
  background: linear-gradient(180deg, #34a1ff 0%, #0a84ff 100%);
}

.message-role.assistant {
  color: #24537a;
  background: rgba(255, 255, 255, 0.82);
}

.message-content {
  white-space: pre-wrap;
  line-height: 1.72;
}

.compact-detail-card {
  align-self: start;
}

.persona-spotlight-stack,
.target-switcher,
.target-switcher-block {
  display: grid;
  gap: 14px;
}

.persona-spotlight-head,
.target-switcher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.persona-inline-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.persona-inline-card {
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.54);
  box-shadow: var(--shadow-soft);
}

.persona-inline-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.persona-inline-card strong {
  display: block;
  color: var(--text);
  font-size: 16px;
}

.target-switcher-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-snap-type: x proximity;
}

.target-switcher-list::-webkit-scrollbar {
  height: 6px;
}

.target-switcher-list::-webkit-scrollbar-thumb {
  background: rgba(52, 94, 158, 0.24);
  border-radius: 999px;
}

.target-switch-chip {
  min-width: 144px;
  max-width: 188px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  color: var(--text);
  text-align: left;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(239, 246, 255, 0.72));
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.target-switch-chip.active {
  border-color: rgba(10, 132, 255, 0.38);
  box-shadow:
    0 0 0 1px rgba(10, 132, 255, 0.12),
    0 12px 24px rgba(49, 74, 122, 0.08);
  background: linear-gradient(180deg, rgba(236, 247, 255, 0.98), rgba(255, 255, 255, 0.9));
}

.target-switch-main,
.target-switch-detail {
  border: 0;
  border-radius: 14px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.target-switch-main {
  padding: 2px 3px;
  text-align: left;
}

.target-switch-detail {
  justify-self: start;
  padding: 7px 10px;
  color: #0a67c7;
  font-size: 12px;
  font-weight: 800;
  background: rgba(10, 132, 255, 0.1);
}

.target-switch-main:active,
.target-switch-detail:active {
  transform: scale(0.985);
}

.target-switch-chip-name,
.target-switch-chip-meta {
  display: block;
}

.target-switch-chip-name {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 800;
}

.target-switch-chip-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.target-switcher-empty {
  padding: 14px 16px;
  border-radius: 20px;
  color: var(--muted);
  line-height: 1.7;
  border: 1px dashed rgba(126, 153, 196, 0.38);
  background: rgba(255, 255, 255, 0.4);
}

.account-action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.me-grid,
.compact-target-grid {
  grid-template-columns: 1fr;
}

.target-summary-strip {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-status-card {
  padding: 14px 16px;
}

.compact-desktop-link {
  min-width: auto;
  padding: 10px 14px;
}

.compact-status-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tech-details {
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.48);
  padding: 8px 10px 12px;
}

.tech-summary {
  padding: 10px 12px;
  color: var(--soft);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.tech-summary::-webkit-details-marker {
  display: none;
}

.tech-details-body {
  padding: 0 6px 6px;
}

.my-signal-grid {
  margin-bottom: 0;
}

.debug-output {
  min-height: 180px;
  max-height: 380px;
  overflow: auto;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.68);
  color: #35506f;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 20px;
  border: 1px dashed rgba(126, 153, 196, 0.35);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.34);
}

.hidden {
  display: none !important;
}

.top-gap {
  margin-top: 16px;
}

.mobile-tabbar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  z-index: 20;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(224, 233, 246, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  align-items: end;
  padding: 18px 14px;
  background: rgba(198, 212, 236, 0.34);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.sheet-card {
  width: min(100%, 680px);
  max-height: min(88vh, 820px);
  margin: 0 auto;
  padding: 20px;
  overflow: auto;
  border-radius: 32px 32px 24px 24px;
  animation: sheet-rise 220ms ease both;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.sheet-close {
  border: 0;
  padding: 10px 14px;
  border-radius: 999px;
  color: #37506e;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.78);
}

.sheet-pane {
  display: grid;
  gap: 16px;
}

.modal-card {
  width: min(100%, 420px);
  padding: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

.modal-head {
  margin-bottom: 14px;
}

.modal-message {
  color: var(--soft);
  line-height: 1.72;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.panel-card,
.subpanel,
.utility-panel {
  animation: rise-in 380ms ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sheet-rise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 768px) {
  .client-app {
    padding: 14px 20px 94px;
  }

  .desktop-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    padding: 12px 18px;
    border-radius: 999px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-soft);
  }

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

  .me-grid,
  .compact-target-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-status-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .compact-grid.triple,
  .split-grid.two-up,
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }

  .sheet-card {
    border-radius: 32px;
  }
}

@media (min-width: 1080px) {
  .client-app {
    padding-bottom: 24px;
  }

  .nav-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }
}

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