:root {
  color-scheme: light dark;
  --canvas: #e9e8e4;
  --canvas-deep: #dfddd8;
  --surface: rgba(248, 247, 243, 0.9);
  --surface-solid: #f8f7f3;
  --surface-strong: #fcfbf8;
  --ink: #20201d;
  --ink-muted: #6d6b66;
  --ink-soft: #96928b;
  --line: rgba(32, 32, 29, 0.09);
  --line-strong: rgba(32, 32, 29, 0.16);
  --accent-deep: #c93460;
  --action: #c93460;
  --accent: #ef5c7c;
  --accent-warm: #ff8653;
  --accent-ink: #30141c;
  --danger: #a02f45;
  --shadow-soft: 0 24px 70px rgba(77, 69, 58, 0.1);
  --shadow-card: 0 14px 36px rgba(77, 69, 58, 0.08);
  --card-radius: 32px;
  --control-radius: 999px;
  --input-radius: 24px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --z-atmosphere: 0;
  --z-content: 10;
  --z-nav: 20;
  --z-sheet: 40;
  --z-toast: 100;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #242321;
    --canvas-deep: #1d1c1a;
    --surface: rgba(49, 47, 44, 0.9);
    --surface-solid: #312f2c;
    --surface-strong: #383531;
    --ink: #f2efe8;
    --ink-muted: #b7b1a8;
    --ink-soft: #8f8981;
    --line: rgba(244, 238, 229, 0.09);
    --line-strong: rgba(244, 238, 229, 0.17);
    --accent-deep: #f36a8c;
    --action: #a12a4e;
    --accent: #f47794;
    --accent-warm: #ff9468;
    --accent-ink: #2a1118;
    --danger: #ff8da2;
    --shadow-soft: 0 28px 80px rgba(9, 8, 7, 0.28);
    --shadow-card: 0 16px 42px rgba(9, 8, 7, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Avenir Next", Avenir, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 72%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: var(--z-toast);
  padding: 10px 16px;
  border-radius: var(--control-radius);
  color: var(--surface-strong);
  background: var(--ink);
  transform: translateY(-160%);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-atmosphere {
  position: fixed;
  inset: 0;
  z-index: var(--z-atmosphere);
  pointer-events: none;
  background:
    radial-gradient(circle at 82% 2%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 26%),
    radial-gradient(circle at 8% 86%, color-mix(in srgb, var(--accent-warm) 10%, transparent), transparent 30%),
    linear-gradient(145deg, transparent 0 58%, color-mix(in srgb, var(--surface-strong) 28%, transparent));
}

.page-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image: radial-gradient(rgba(32, 32, 29, 0.18) 0.45px, transparent 0.55px);
  background-size: 5px 5px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.app-shell {
  position: relative;
  z-index: var(--z-content);
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--surface-strong) 58%, transparent);
  border-radius: 16px;
  color: var(--surface-strong);
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.72), transparent 28%),
    linear-gradient(145deg, var(--accent), var(--accent-warm));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.52),
    0 10px 22px color-mix(in srgb, var(--accent-deep) 23%, transparent);
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.06em;
}

.brand-copy {
  display: grid;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 650;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

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

.theme-button,
.connection-state {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--ink-muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  font-size: 13px;
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.theme-button {
  padding: 0 14px;
  transition:
    transform 180ms var(--ease-out),
    background-color 180ms var(--ease-out),
    color 180ms var(--ease-out);
}

.theme-button:hover {
  color: var(--ink);
  background: var(--surface-strong);
}

.theme-button:active {
  transform: scale(0.97);
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
}

.connection-state__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
}

.connection-state.is-online .connection-state__dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.welcome-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-label,
.signal-label {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(38px, 8vw, 68px);
  font-weight: 560;
  letter-spacing: -0.052em;
  line-height: 1.04;
}

.welcome-copy {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: clamp(16px, 2.4vw, 19px);
}

h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 560;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.quiet-button,
.round-button,
.primary-button,
.voice-button,
.save-button,
.nav-item {
  min-height: 44px;
  border: 0;
  transition:
    transform 180ms var(--ease-out),
    opacity 180ms var(--ease-out),
    background-color 180ms var(--ease-out),
    color 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out);
}

.quiet-button:active,
.round-button:active,
.primary-button:active,
.voice-button:active,
.save-button:active,
.nav-item:active {
  transform: scale(0.97);
}

.quiet-button {
  flex: 0 0 auto;
  padding: 0 19px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.quiet-button:hover {
  background: var(--surface);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.surface-card,
.signal-card,
.capture-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--surface-strong) 62%, var(--line));
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-card);
}

.surface-card {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
}

.signal-card {
  min-height: 360px;
  padding: 30px;
  color: var(--accent-ink);
  background:
    radial-gradient(circle at 84% 28%, rgba(255, 255, 255, 0.3), transparent 19%),
    radial-gradient(circle at 67% 82%, rgba(255, 255, 255, 0.18), transparent 22%),
    linear-gradient(145deg, #f7a5b6 0%, var(--accent) 48%, var(--accent-warm) 116%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.44),
    0 26px 70px color-mix(in srgb, var(--accent-deep) 22%, transparent);
}

.signal-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: calc(var(--card-radius) - 1px);
  pointer-events: none;
}

.signal-card__copy {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 298px;
  flex-direction: column;
  align-items: flex-start;
}

.signal-label {
  color: color-mix(in srgb, var(--accent-ink) 68%, transparent);
}

.signal-card h2 {
  max-width: 13ch;
  font-size: clamp(34px, 8vw, 54px);
}

.signal-card p:not(.signal-label) {
  max-width: 34ch;
  margin: 14px 0 0;
  color: color-mix(in srgb, var(--accent-ink) 74%, transparent);
}

.primary-button {
  margin-top: auto;
  padding: 0 20px;
  border-radius: var(--control-radius);
  color: #fff8f5;
  background: var(--accent-ink);
  box-shadow: 0 8px 22px rgba(48, 20, 28, 0.2);
  font-weight: 650;
}

.primary-button:hover {
  box-shadow: 0 12px 30px rgba(48, 20, 28, 0.26);
}

.signal-orbit {
  position: absolute;
  right: -36px;
  bottom: -44px;
  width: 230px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.signal-orbit__ring,
.signal-orbit__core {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.signal-orbit__ring {
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.1);
}

.signal-orbit__ring--outer {
  width: 100%;
  height: 100%;
}

.signal-orbit__ring--middle {
  width: 56%;
  height: 56%;
}

.signal-orbit__core {
  width: 23%;
  height: 23%;
  background: var(--accent-ink);
  box-shadow:
    0 0 0 13px rgba(255, 255, 255, 0.24),
    0 18px 42px rgba(48, 20, 28, 0.18);
}

.focus-panel,
.memory-panel,
.budget-panel {
  padding: 26px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-header--compact h2 {
  font-size: 25px;
}

.round-button {
  display: grid;
  width: 48px;
  min-width: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface-strong);
  font-size: 25px;
  font-weight: 400;
}

.round-button:hover {
  background: color-mix(in srgb, var(--accent) 11%, var(--surface-strong));
}

.focus-list {
  display: grid;
  gap: 4px;
  margin-top: 26px;
}

.focus-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 76px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}

.focus-item:last-child {
  border-bottom: 0;
}

.focus-item h3 {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 620;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-item p {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.focus-score {
  min-width: 48px;
  color: var(--accent-deep);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: right;
}

.empty-focus {
  display: grid;
  min-height: 206px;
  place-items: center;
  padding: 26px 8px 8px;
  text-align: center;
}

.empty-focus p {
  max-width: 28ch;
  margin: 8px auto 18px;
  color: var(--ink-muted);
}

.text-button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--control-radius);
  color: var(--accent-deep);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 650;
}

.skeleton-row {
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(100deg, var(--line) 18%, color-mix(in srgb, var(--surface-strong) 65%, transparent) 42%, var(--line) 68%);
  background-size: 220% 100%;
}

.insight-column {
  display: grid;
  gap: 16px;
}

.status-word {
  flex: 0 0 auto;
  padding-top: 3px;
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 650;
}

.memory-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.memory-sources span {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--ink-muted);
  background: color-mix(in srgb, var(--surface-strong) 68%, transparent);
  font-size: 12px;
}

.panel-note {
  margin: 18px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.budget-value {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-top: 18px;
}

.budget-value strong {
  font-size: 64px;
  font-weight: 520;
  letter-spacing: -0.07em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.budget-value span {
  color: var(--ink-muted);
  font-size: 13px;
}

.capture-panel {
  display: grid;
  gap: 26px;
  padding: 28px;
  background:
    radial-gradient(circle at 92% 12%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 27%),
    var(--surface-strong);
}

.capture-panel__intro p:not(.section-label) {
  max-width: 34ch;
  margin: 10px 0 0;
  color: var(--ink-muted);
}

.capture-form {
  display: grid;
  gap: 10px;
}

.capture-form label,
.access-card label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

textarea,
.access-card input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: var(--input-radius);
  color: var(--ink);
  background: color-mix(in srgb, var(--canvas) 52%, var(--surface-strong));
}

textarea {
  min-height: 118px;
  padding: 17px 18px;
  resize: vertical;
  line-height: 1.5;
}

textarea::placeholder,
input::placeholder {
  color: var(--ink-soft);
}

.field-help,
.field-error {
  min-height: 20px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.field-error {
  color: var(--danger);
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.voice-button,
.save-button {
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--control-radius);
  font-weight: 650;
}

.voice-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: transparent;
}

.voice-button:hover {
  background: var(--surface);
}

.save-button {
  color: #fff8f5;
  background: var(--action);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--action) 20%, transparent);
}

.save-button:hover {
  background: color-mix(in srgb, var(--action) 90%, #2a1118);
}

.save-button:disabled,
.voice-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.bottom-nav {
  position: fixed;
  right: 16px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: var(--z-nav);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(calc(100% - 32px), 520px);
  min-height: 62px;
  margin: 0 auto;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--surface-strong) 62%, var(--line));
  border-radius: var(--control-radius);
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(28px) saturate(145%);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
}

.nav-item {
  border-radius: var(--control-radius);
  color: var(--ink-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 620;
}

.nav-item.is-active {
  color: var(--surface-strong);
  background: var(--ink);
}

.access-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(34, 31, 28, 0.54);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.access-sheet[hidden] {
  display: none;
}

.access-card {
  display: grid;
  width: min(100%, 420px);
  gap: 14px;
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--card-radius);
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

.access-card p:not(.section-label, .field-error) {
  margin: 0 0 6px;
  color: var(--ink-muted);
}

.access-card input {
  padding: 0 17px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: var(--z-toast);
  width: min(calc(100% - 32px), 480px);
  margin: 0 auto;
  padding: 14px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  color: var(--surface-strong);
  background: color-mix(in srgb, var(--ink) 94%, transparent);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.toast[hidden] {
  display: none;
}

.is-error .connection-state__dot {
  background: var(--danger);
}

@media (min-width: 768px) {
  :root {
    --card-radius: 40px;
  }

  .app-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .topbar {
    margin-bottom: 44px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 20px;
  }

  .signal-card {
    grid-column: span 7;
    min-height: 430px;
    padding: 40px;
  }

  .signal-card__copy {
    min-height: 348px;
  }

  .focus-panel {
    grid-column: span 5;
    padding: 32px;
  }

  .insight-column {
    grid-column: span 4;
  }

  .memory-panel,
  .budget-panel {
    padding: 30px;
  }

  .capture-panel {
    grid-column: span 8;
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
    align-items: start;
    gap: 42px;
    padding: 36px;
  }

  .capture-form {
    min-width: 0;
  }
}

@media (min-width: 1080px) {
  .welcome-row {
    margin-bottom: 34px;
  }

  .signal-orbit {
    right: -22px;
    bottom: -54px;
    width: 300px;
  }

  .bottom-nav {
    right: 28px;
    left: auto;
    width: 390px;
  }
}

@media (max-width: 520px) {
  .brand-copy small {
    display: none;
  }

  .connection-state {
    padding: 0 12px;
  }

  .welcome-row {
    display: grid;
    align-items: start;
  }

  .quiet-button {
    justify-self: start;
  }

  .signal-card {
    min-height: 400px;
  }

  .signal-card__copy {
    min-height: 338px;
  }

  .signal-card h2 {
    max-width: 11ch;
  }

  .signal-orbit {
    right: -70px;
    bottom: -20px;
  }

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

@media (max-width: 420px) {
  .connection-state {
    width: 44px;
    justify-content: center;
    padding: 0;
  }

  #connection-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .welcome-row,
  .signal-card,
  .focus-panel,
  .insight-column,
  .capture-panel {
    opacity: 0;
    animation: enter-panel 420ms var(--ease-out) forwards;
  }

  .signal-card {
    animation-delay: 45ms;
  }

  .focus-panel {
    animation-delay: 90ms;
  }

  .insight-column {
    animation-delay: 135ms;
  }

  .capture-panel {
    animation-delay: 180ms;
  }

  .connection-state.is-online .connection-state__dot {
    animation: state-breathe 2.8s ease-in-out infinite;
  }

  .skeleton-row {
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
  }
}

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

@media (prefers-reduced-transparency: reduce) {
  .surface-card,
  .theme-button,
  .connection-state,
  .bottom-nav,
  .access-sheet {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .surface-card,
  .theme-button,
  .connection-state,
  .bottom-nav {
    background: var(--surface-solid);
  }
}

@keyframes enter-panel {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes state-breathe {
  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent);
  }
}

#draft-recovery { padding: 24px; margin: 24px 0; }
#draft-recovery h2 { font-size: 22px; letter-spacing: -.035em; }
#draft-recovery .ml-checkbox { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.draft-item { padding: 16px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.draft-item > p { margin: 0 0 8px; }

@keyframes skeleton-shimmer {
  from {
    background-position: 110% 0;
  }
  to {
    background-position: -110% 0;
  }
}
