:root {
  --bg: #f4f0e7;
  --bg-deep: #ece6da;
  --paper: #fdfaf4;
  --paper-2: #f7f2e8;
  --paper-3: #eee7da;
  --ink: #20271f;
  --ink-soft: #566055;
  --muted: #8a9085;
  --line: rgba(31, 42, 31, 0.11);
  --line-strong: rgba(31, 42, 31, 0.2);
  --accent: #2f5d50;
  --accent-deep: #23483e;
  --accent-soft: #e2ebe4;
  --accent-warm: #bf6b4d;
  --warm-soft: #f3e1d7;
  --danger: #a24b41;
  --danger-soft: #f5dfdb;
  --gold: #a98a4e;
  --shadow-sm: 0 1px 2px rgba(31, 42, 31, 0.05), 0 6px 18px rgba(31, 42, 31, 0.04);
  --shadow-md: 0 18px 50px rgba(25, 35, 26, 0.13);
  --shadow-lg: 0 32px 80px rgba(20, 30, 22, 0.2);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "MiSans", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141916;
  --bg-deep: #101411;
  --paper: #1c231e;
  --paper-2: #202821;
  --paper-3: #273027;
  --ink: #ece7db;
  --ink-soft: #b7beb2;
  --muted: #899187;
  --line: rgba(234, 240, 228, 0.1);
  --line-strong: rgba(234, 240, 228, 0.2);
  --accent: #8fb9a6;
  --accent-deep: #b2d4c3;
  --accent-soft: #263a31;
  --accent-warm: #d68e70;
  --warm-soft: #3a2a23;
  --danger: #e09187;
  --danger-soft: #3b2522;
  --gold: #d0b174;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 22px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #141916;
    --bg-deep: #101411;
    --paper: #1c231e;
    --paper-2: #202821;
    --paper-3: #273027;
    --ink: #ece7db;
    --ink-soft: #b7beb2;
    --muted: #899187;
    --line: rgba(234, 240, 228, 0.1);
    --line-strong: rgba(234, 240, 228, 0.2);
    --accent: #8fb9a6;
    --accent-deep: #b2d4c3;
    --accent-soft: #263a31;
    --accent-warm: #d68e70;
    --warm-soft: #3a2a23;
    --danger: #e09187;
    --danger-soft: #3b2522;
    --gold: #d0b174;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 22px rgba(0, 0, 0, 0.16);
    --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 32px 80px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background:
    radial-gradient(ellipse 80% 55% at 8% -5%, rgba(191, 107, 77, 0.08), transparent 60%),
    radial-gradient(ellipse 65% 50% at 100% 5%, rgba(47, 93, 80, 0.08), transparent 62%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--accent);
}

svg {
  display: block;
}

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

::selection {
  background: var(--accent);
  color: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.mobile-only {
  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;
}

/* ---------- shared ---------- */

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-deep);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--shadow-sm);
  flex: none;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-mark.large {
  width: 76px;
  height: 76px;
  border-radius: 24px;
}

.brand-mark.large svg {
  width: 50px;
  height: 50px;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.brand-mark.small svg {
  width: 26px;
  height: 26px;
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--paper-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #f7f3e8;
  box-shadow: 0 8px 22px rgba(35, 72, 62, 0.18);
}

.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--paper-2);
  border-color: var(--line);
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 24%, transparent);
  background: var(--danger-soft);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
  min-height: 50px;
  border-radius: 13px;
  font-size: 14.5px;
}

.btn-arrow {
  margin-left: auto;
  font-size: 18px;
  font-weight: 400;
  opacity: 0.85;
}

.btn svg {
  flex: none;
}

a.btn {
  text-decoration: none;
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: var(--ink-soft);
  transition: background 0.16s ease, color 0.16s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 14%, transparent);
}

.status-dot.online {
  background: #5b9275;
  box-shadow: 0 0 0 3px rgba(91, 146, 117, 0.14);
}

.status-dot.syncing {
  background: var(--gold);
  animation: pulse 1.4s infinite;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(162, 75, 65, 0.12);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent);
}

.textarea {
  resize: none;
  line-height: 1.75;
}

.field-label {
  display: block;
  margin: 0 0 7px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
}

.field-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  margin: 2px 0 0;
}

/* ---------- boot ---------- */

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.boot-splash.done {
  opacity: 0;
  visibility: hidden;
}

.boot-name {
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--ink);
}

.boot-line {
  width: 64px;
  height: 1px;
  background: var(--line-strong);
  position: relative;
  overflow: hidden;
}

.boot-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  animation: bootline 1.2s ease-in-out infinite;
}

@keyframes bootline {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(100%); }
}

/* ---------- auth ---------- */

.auth-screen {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(440px, 0.95fr);
  min-height: 100dvh;
  background: var(--bg);
}

.auth-art {
  position: relative;
  overflow: hidden;
  margin: 18px;
  border-radius: 30px;
  padding: clamp(30px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  color: #f3eee1;
  background:
    radial-gradient(circle at 80% 16%, rgba(191, 107, 77, 0.55), transparent 34%),
    radial-gradient(circle at 18% 78%, rgba(111, 155, 133, 0.28), transparent 42%),
    linear-gradient(145deg, #244237 0%, #173129 48%, #10231d 100%);
  box-shadow: var(--shadow-md);
}

.auth-art-grain {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.auth-brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 13px;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.16em;
}

.auth-brand .brand-mark {
  background: rgba(255, 255, 255, 0.1);
  color: #f5efe2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.auth-quote {
  position: relative;
  z-index: 2;
  margin: auto 0;
  padding: 10vh 0 8vh;
}

.auth-quote p {
  font-family: var(--serif);
  font-size: clamp(32px, 3.4vw, 52px);
  line-height: 1.45;
  letter-spacing: 0.06em;
  font-weight: 400;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.auth-quote span {
  display: block;
  margin-top: 30px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: rgba(243, 238, 225, 0.55);
}

.auth-features {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 26px;
  font-size: 12.5px;
  letter-spacing: 0.18em;
  color: rgba(243, 238, 225, 0.62);
}

.auth-features span {
  position: relative;
  padding-left: 15px;
}

.auth-features span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-warm);
  transform: translateY(-50%);
}

.auth-orbit {
  position: absolute;
  border: 1px solid rgba(243, 238, 225, 0.09);
  border-radius: 50%;
  pointer-events: none;
}

.orbit-a {
  width: 56vw;
  height: 56vw;
  right: -28vw;
  top: -20vw;
}

.orbit-b {
  width: 34vw;
  height: 34vw;
  right: -8vw;
  top: -5vw;
  border-color: rgba(243, 238, 225, 0.06);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px clamp(28px, 6vw, 90px);
  gap: 22px;
}

.auth-card {
  width: 100%;
  max-width: 396px;
}

.auth-mobile-brand {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.18em;
}

.auth-card h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 3vw, 40px);
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.3;
  margin: 10px 0 10px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  max-width: 340px;
}

.auth-form {
  margin-top: 34px;
}

.auth-form .field-label {
  font-size: 12px;
  margin-bottom: 8px;
}

.password-field {
  position: relative;
  margin-bottom: 15px;
}

.password-field .input {
  height: 52px;
  padding-right: 48px;
  background: var(--paper);
  border-radius: 12px;
  font-size: 15px;
  letter-spacing: 0.06em;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.auth-form .btn-block {
  margin-top: 20px;
}

.auth-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 30px;
  font-size: 11.5px;
  color: var(--muted);
}

.auth-apk {
  display: inline-block;
  margin-top: 15px;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-apk:hover {
  color: var(--accent-warm);
}

.native-app .auth-apk {
  display: none;
}

.auth-copyright {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
}

/* ---------- app shell ---------- */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: calc(24px + var(--safe-top)) 16px 16px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 24px;
}

.sidebar-name {
  display: block;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.16em;
  line-height: 1.25;
}

.sidebar-sub {
  display: block;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-top: 3px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 45px;
  padding: 0 12px;
  border-radius: 11px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.nav-item.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  bottom: 13px;
  width: 2.5px;
  border-radius: 3px;
  background: var(--accent-warm);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 20px;
  color: currentColor;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--paper-3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-align: center;
}

.nav-badge:empty {
  display: none;
}

.nav-item.active .nav-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-note {
  position: relative;
  margin: auto 8px 22px;
  padding: 16px 14px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 0.04em;
}

.quote-mark {
  position: absolute;
  top: 9px;
  left: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--line-strong);
}

.sidebar-note p {
  padding-left: 13px;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 11px;
  color: var(--muted);
  text-align: left;
}

.sync-pill:hover {
  background: var(--paper-2);
}

.nav-settings {
  height: 42px;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: calc(18px + var(--safe-top)) clamp(20px, 3.2vw, 48px) 15px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-titles {
  min-width: 0;
}

.topbar-titles h1 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 550;
  letter-spacing: 0.02em;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.view {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(20px, 2.8vw, 40px) clamp(20px, 3.2vw, 48px) 44px;
  scrollbar-gutter: stable;
}

.view:focus {
  outline: none;
}

.view.view-chat {
  padding: 0;
  overflow: hidden;
}

.view.view-chat > .chat-layout {
  height: 100%;
}

.bottom-nav {
  display: none;
}

/* ---------- chat ---------- */

.chat-layout {
  display: grid;
  grid-template-columns: 308px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.chat-loading {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.loading-spinner {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.reasoning-block {
  margin: 0 0 9px;
  border-left: 2px solid var(--line-strong);
  padding-left: 10px;
  color: var(--muted);
  font-size: 11px;
}

.reasoning-block summary {
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.06em;
  user-select: none;
}

.reasoning-block div {
  margin-top: 5px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.message-row.user .reasoning-block {
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.62);
}

.chat-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.chat-list-head {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 18px 16px 10px;
}

.conv-search {
  position: relative;
  flex: 1;
}

.conv-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.conv-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 0 10px 0 33px;
  font-size: 12.5px;
}

.conv-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.new-chat-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-deep);
  color: #f7f3e8;
  flex: none;
  transition: background 0.16s ease, transform 0.16s ease;
}

.new-chat-btn:hover {
  background: var(--accent);
}

.new-chat-btn:active {
  transform: scale(0.96);
}

.new-chat-btn svg {
  width: 18px;
  height: 18px;
}

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 10px 20px;
}

.conv-item {
  position: relative;
  display: flex;
  gap: 11px;
  width: 100%;
  padding: 11px 10px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.16s ease;
}

.conv-item:hover {
  background: var(--paper-2);
}

.conv-item.active {
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.conv-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 15px;
  margin-top: 1px;
}

.conv-item.active .conv-avatar {
  background: var(--accent-deep);
  color: var(--paper);
}

.conv-info {
  min-width: 0;
  flex: 1;
}

.conv-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.conv-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  flex: none;
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.dsh-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.5;
}

.dsh-inline-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.streaming-status {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11.5px;
  animation: pulse-soft 1.8s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.conv-preview {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

.thread-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 70%);
}

.thread-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.thread-messages {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 30px clamp(18px, 3.6vw, 40px) 24px;
}

.thread-intro {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px 80px;
  text-align: center;
}

.intro-mark {
  width: 58px;
  height: 58px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  background: var(--accent-deep);
  color: #f4efe3;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.intro-mark svg {
  width: 34px;
  height: 34px;
}

.thread-intro h2 {
  font-family: var(--serif);
  font-size: clamp(24px, 2.6vw, 33px);
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-bottom: 9px;
}

.thread-intro > p {
  color: var(--muted);
  font-size: 13px;
  max-width: 400px;
  line-height: 1.9;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(580px, 100%);
  margin-top: 30px;
}

.prompt-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--paper) 68%, transparent);
  text-align: left;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.prompt-card:hover {
  border-color: var(--line-strong);
  background: var(--paper);
  transform: translateY(-1px);
}

.prompt-card svg {
  width: 16px;
  height: 16px;
  color: var(--accent-warm);
  flex: none;
  margin-top: 2px;
}

.message-row {
  display: flex;
  gap: 11px;
  margin-bottom: 26px;
  animation: messageIn 0.26s ease both;
}

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

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  background: var(--accent-deep);
  color: var(--paper);
}

.message-avatar svg {
  width: 18px;
  height: 18px;
}

.message-row.user .message-avatar {
  display: none;
}

.message-body {
  min-width: 0;
  max-width: min(680px, 86%);
}

.message-row.user .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 6px;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.message-row.user .message-meta {
  flex-direction: row-reverse;
}

.message-bubble {
  position: relative;
  padding: 13px 16px;
  border-radius: 16px 16px 16px 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.message-row.user .message-bubble {
  background: var(--accent-deep);
  border-color: transparent;
  color: #f7f3e9;
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 8px 22px rgba(35, 72, 62, 0.15);
}

.message-row.user .message-bubble a {
  color: #f1d9b7;
}

.message-text {
  min-height: 1.8em;
}

.message-text > :first-child {
  margin-top: 0;
}

.message-text > :last-child {
  margin-bottom: 0;
}

.message-text p {
  margin: 0.55em 0;
}

.message-text h1,
.message-text h2,
.message-text h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.45;
  margin: 1em 0 0.45em;
}

.message-text h1 { font-size: 1.35em; }
.message-text h2 { font-size: 1.2em; }
.message-text h3 { font-size: 1.08em; }

.message-text ul,
.message-text ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.message-text li {
  margin: 0.22em 0;
}

.message-text code {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
  background: var(--paper-3);
  border-radius: 5px;
  padding: 0.14em 0.36em;
}

.message-text pre {
  margin: 0.7em 0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  background: #17211c;
  color: #e5eadf;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.message-text pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 12.2px;
  line-height: 1.7;
}

.message-text blockquote {
  margin: 0.7em 0;
  padding: 4px 0 4px 13px;
  border-left: 2px solid var(--accent-warm);
  color: var(--ink-soft);
}

.message-text hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1em 0;
}

.message-text a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-row.user .message-text code {
  background: rgba(255, 255, 255, 0.12);
}

.message-row.user .message-text pre {
  background: rgba(0, 0, 0, 0.24);
}

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.message-row:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}

.message-actions button {
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 10px;
  color: var(--muted);
}

.message-actions button:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.organize-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 4px 0;
  min-height: 24px;
  font-size: 10px;
  color: var(--muted);
}

.organize-panel.pending {
  gap: 7px;
}

.organize-spinner {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent-warm);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}

.organize-panel.done {
  color: var(--accent);
}

.organize-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 650;
  letter-spacing: 0.03em;
  margin-right: 3px;
}

.organize-panel.done button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  line-height: 1.4;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.organize-panel.done button:hover {
  background: var(--paper);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.organize-panel.done .organize-undo {
  margin-left: auto;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.organize-panel.done .organize-undo:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.organize-panel.failed {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 7px;
  padding: 4px 7px;
  gap: 5px;
}

.organize-panel.failed button {
  margin-left: 2px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  color: var(--danger);
  font-size: 9.5px;
}

.organize-panel.undone {
  color: var(--muted);
  opacity: 0.8;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.attachment-card:hover {
  border-color: var(--line-strong);
  background: var(--paper);
}

.message-row.user .attachment-card {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f7f3e9;
}

.attachment-thumb {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--paper-3);
  display: grid;
  place-items: center;
  color: var(--accent);
  overflow: hidden;
}

.attachment-thumb svg {
  width: 17px;
  height: 17px;
}

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

.attachment-info {
  min-width: 0;
}

.attachment-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  display: block;
  font-size: 9.5px;
  color: var(--muted);
  margin-top: 1px;
}

.message-row.user .attachment-size {
  color: rgba(247, 243, 233, 0.55);
}

.message-status-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 7px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10.5px;
  line-height: 1.55;
}

.message-status-error svg {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 1px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: dot 1.2s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.typing-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 18px;
  width: min(700px, 100%);
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  background: color-mix(in srgb, var(--gold) 10%, var(--paper));
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.chat-notice svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--gold);
}

.chat-notice span {
  flex: 1;
}

.composer-wrap {
  flex: none;
  width: 100%;
  padding: 8px clamp(14px, 3.6vw, 40px) calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}

.composer-inner {
  width: min(820px, 100%);
  margin: 0 auto;
}

.pending-files {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 4px 8px;
}

.pending-file {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 240px;
  padding: 6px 7px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  font-size: 10.5px;
}

.pending-file .file-icon {
  color: var(--accent);
  flex: none;
}

.pending-file .file-icon svg {
  width: 14px;
  height: 14px;
}

.pending-file-name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-file-status {
  color: var(--muted);
  font-size: 9.5px;
}

.pending-file-remove {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: var(--muted);
}

.pending-file-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.pending-file-remove svg {
  width: 12px;
  height: 12px;
}

.composer {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-md);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: var(--shadow-md), 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 190px;
  padding: 15px 17px 7px;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.65;
  outline: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 8px 10px;
}

.composer-hint {
  margin-left: auto;
  padding-right: 8px;
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.send-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-deep);
  color: #f7f3e8;
  transition: background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.send-btn:hover {
  background: var(--accent);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  background: var(--paper-3);
  color: var(--muted);
  opacity: 1;
}

.send-btn svg {
  width: 17px;
  height: 17px;
}

.upload-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--paper-3);
}

.upload-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.chat-drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 20;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.chat-drop-overlay.visible {
  opacity: 1;
}

/* ---------- common pages ---------- */

.page-enter {
  animation: pageIn 0.36s ease both;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-note {
  font-size: 11.5px;
  color: var(--muted);
}

.search-box {
  position: relative;
  width: min(300px, 100%);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  height: 40px;
  padding-left: 37px;
  border-radius: 11px;
  font-size: 13px;
  background: var(--paper);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-art {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--accent);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.empty-art svg {
  width: 28px;
  height: 28px;
}

.empty-state h2 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 7px;
}

.empty-state p {
  font-size: 12.5px;
  line-height: 1.8;
  max-width: 330px;
}

.empty-state .btn {
  margin-top: 20px;
}

/* ---------- notes ---------- */

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 14px;
}

.note-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 178px;
  padding: 18px 18px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-align: left;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 1px rgba(31, 42, 31, 0.03);
}

.note-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.tone-sand { background: #f3ead8; color: #3d3527; }
.tone-sage { background: #e5ece1; color: #2d3b2e; }
.tone-rose { background: #f4e3dd; color: #462f29; }
.tone-sky { background: #e2ebee; color: #293a3f; }
.tone-lilac { background: #eae5ef; color: #36303e; }

:root[data-theme="dark"] .tone-sand { background: #322d22; color: #e9dfcb; }
:root[data-theme="dark"] .tone-sage { background: #25332a; color: #dbe6da; }
:root[data-theme="dark"] .tone-rose { background: #352724; color: #ecd9d3; }
:root[data-theme="dark"] .tone-sky { background: #223034; color: #d4e3e8; }
:root[data-theme="dark"] .tone-lilac { background: #2c2835; color: #e2dbec; }

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .tone-sand { background: #322d22; color: #e9dfcb; }
  :root[data-theme="auto"] .tone-sage { background: #25332a; color: #dbe6da; }
  :root[data-theme="auto"] .tone-rose { background: #352724; color: #ecd9d3; }
  :root[data-theme="auto"] .tone-sky { background: #223034; color: #d4e3e8; }
  :root[data-theme="auto"] .tone-lilac { background: #2c2835; color: #e2dbec; }
}

.note-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.note-tag {
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  opacity: 0.5;
}

.note-pin {
  margin-left: auto;
  opacity: 0.55;
}

.note-pin svg {
  width: 13px;
  height: 13px;
}

.note-title {
  font-family: var(--serif);
  font-size: 17.5px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  margin-bottom: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.note-title.untitled {
  opacity: 0.42;
  font-weight: 500;
}

.note-excerpt {
  font-size: 12px;
  line-height: 1.75;
  opacity: 0.68;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 15px;
  font-size: 9.5px;
  opacity: 0.48;
  letter-spacing: 0.03em;
}

.note-card.new-note-card {
  min-height: 120px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 12px;
  flex-direction: row;
}

.note-card.new-note-card:hover {
  background: var(--paper-2);
  color: var(--ink);
}

/* note editor modal */

.note-editor {
  display: flex;
  flex-direction: column;
  min-height: min(70dvh, 640px);
}

.editor-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 12px;
}

.editor-title {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: clamp(23px, 2.4vw, 30px);
  font-weight: 550;
  line-height: 1.4;
  padding: 4px 2px;
  outline: none;
}

.editor-title::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.editor-body {
  flex: 1;
  width: 100%;
  min-height: 300px;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14.5px;
  line-height: 1.95;
  padding: 8px 2px 20px;
}

.editor-body::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.color-swatches {
  display: flex;
  gap: 6px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.color-swatch.active {
  border-color: var(--ink);
}

.save-state {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
  min-height: 16px;
}

.save-state.saving::before {
  content: "●";
  color: var(--gold);
  margin-right: 5px;
  animation: pulse 1s infinite;
}

.save-state.saved::before {
  content: "✓";
  color: var(--accent);
  margin-right: 4px;
}

/* ---------- tasks ---------- */

.task-board {
  width: min(920px, 100%);
  margin: 0 auto;
}

.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.quick-add input {
  flex: 1;
  height: 48px;
  border-radius: 13px;
  padding: 0 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.quick-add button {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-deep);
  color: #f7f3e8;
}

.quick-add button svg {
  width: 18px;
  height: 18px;
}

.task-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--paper-3);
}

.segmented button {
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.segmented button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.task-group {
  margin-bottom: 28px;
}

.task-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 8px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.task-group-head .count {
  padding: 0 6px;
  border-radius: 20px;
  background: var(--paper-3);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0;
}

.task-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

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

.task-item:hover {
  background: var(--paper-2);
}

.task-check {
  width: 21px;
  height: 21px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 2px;
  color: transparent;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.task-check:hover {
  border-color: var(--accent);
}

.task-check svg {
  width: 12px;
  height: 12px;
}

.task-item.done .task-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

.task-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.task-title {
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.55;
  word-break: break-word;
}

.task-item.done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.task-item.just-done {
  animation: taskDone 0.35s ease;
}

@keyframes taskDone {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
}

.task-meta .tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--paper-3);
  line-height: 1.5;
}

.task-meta .tag svg {
  width: 10px;
  height: 10px;
}

.task-meta .tag.overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

.task-meta .tag.today {
  background: var(--warm-soft);
  color: var(--accent-warm);
}

.task-meta .tag.notes-tag {
  background: transparent;
  padding-left: 0;
}

.priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}

.priority-3 { background: #b45745; }
.priority-2 { background: #c5964e; }
.priority-1 { background: var(--accent); }
.priority-0 { background: var(--muted); opacity: 0.4; }

.task-delete {
  opacity: 0;
  color: var(--muted);
  padding: 3px;
  border-radius: 6px;
}

.task-item:hover .task-delete {
  opacity: 1;
}

.task-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.task-delete svg {
  width: 14px;
  height: 14px;
}

/* task editor */

.priority-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.priority-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.priority-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- ledger ---------- */

.ledger-wrap {
  width: min(1000px, 100%);
  margin: 0 auto;
}

.ledger-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.month-picker {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--ink);
}

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

.summary-card {
  position: relative;
  padding: 20px 20px 18px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.summary-card.balance {
  background:
    radial-gradient(circle at 100% 0%, rgba(191, 107, 77, 0.22), transparent 55%),
    var(--accent-deep);
  border-color: transparent;
  color: #f7f3e9;
}

.summary-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-card.balance .summary-label {
  color: rgba(247, 243, 233, 0.62);
}

.summary-value {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: clamp(21px, 2.4vw, 30px);
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.summary-value .currency {
  font-size: 0.58em;
  margin-right: 3px;
  opacity: 0.65;
  font-family: var(--sans);
}

.summary-sub {
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
}

.summary-card.balance .summary-sub {
  color: rgba(247, 243, 233, 0.5);
}

.ledger-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.ledger-list-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ledger-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 18px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.ledger-day-sum {
  font-variant-numeric: tabular-nums;
}

.ledger-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.ledger-item:hover {
  background: var(--paper-2);
}

.ledger-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--paper-3);
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 13px;
}

.ledger-icon.income {
  background: var(--accent-soft);
  color: var(--accent);
}

.ledger-info {
  flex: 1;
  min-width: 0;
}

.ledger-cat {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.ledger-note {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-amount {
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.ledger-amount.expense {
  color: var(--ink);
}

.ledger-amount.income {
  color: var(--accent);
}

.ledger-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--ink);
}

.category-row {
  margin-bottom: 13px;
}

.category-row:last-child {
  margin-bottom: 0;
}

.category-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 10.5px;
  color: var(--ink-soft);
}

.category-meta span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.category-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--paper-3);
  overflow: hidden;
}

.category-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.45s ease;
}

.category-row:nth-child(3n+1) .category-bar i { background: var(--accent); }
.category-row:nth-child(3n+2) .category-bar i { background: var(--accent-warm); }
.category-row:nth-child(3n) .category-bar i { background: var(--gold); }

.ledger-tip {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 17px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 11.5px;
  line-height: 1.9;
}

/* amount modal */

.amount-input-wrap {
  position: relative;
}

.amount-input-wrap .currency-symbol {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-size: 22px;
  color: var(--muted);
  pointer-events: none;
}

.amount-input {
  height: 66px;
  padding-left: 39px;
  font-family: var(--serif);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  border-radius: 13px;
  letter-spacing: 0.01em;
}

.kind-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--paper-3);
  margin-bottom: 16px;
}

.kind-toggle button {
  height: 37px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.kind-toggle button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kind-toggle button.active.expense {
  color: var(--accent-warm);
}

.kind-toggle button.active.income {
  color: var(--accent);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chip {
  padding: 6px 11px;
  border-radius: 20px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--paper);
  transition: all 0.15s ease;
}

.category-chip.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* ---------- settings ---------- */

.settings-wrap {
  width: min(820px, 100%);
  margin: 0 auto;
}

.settings-section {
  margin-bottom: 30px;
}

.settings-section > h2 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0 2px 10px;
  letter-spacing: 0.03em;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 17px 19px;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-label {
  flex: 0 0 150px;
  padding-top: 2px;
}

.setting-label strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.setting-label span {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--muted);
}

.setting-control {
  flex: 1;
  min-width: 0;
}

.setting-control .input,
.setting-control .select {
  height: 40px;
  font-size: 13px;
  background: var(--bg);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.warn {
  background: var(--warm-soft);
  color: var(--accent-warm);
}

.badge.neutral {
  background: var(--paper-3);
  color: var(--muted);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--paper-3);
  border: 1px solid var(--line);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent-warm);
  outline-offset: 2px;
}

.server-url-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qr-panel {
  display: flex;
  align-items: center;
  gap: 18px;
}

.qr-image {
  width: 148px;
  height: 148px;
  flex: none;
  border-radius: 12px;
  background: #f7f2e8;
  padding: 7px;
  border: 1px solid var(--line);
}

.qr-info {
  flex: 1;
  min-width: 0;
}

.qr-info p {
  margin-top: 9px;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--muted);
}

.server-url {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10.5px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.server-url span {
  flex: 1;
  min-width: 0;
}

.server-url .icon-btn {
  width: 28px;
  height: 28px;
}

.storage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.storage-item {
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.storage-item strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.storage-item span {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--muted);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  background: var(--bg);
  font-size: 11px;
  color: var(--ink-soft);
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent);
}

.theme-preview {
  height: 30px;
  border-radius: 6px;
  margin-bottom: 7px;
  border: 1px solid var(--line);
}

.theme-preview.light { background: #f4f0e7; }
.theme-preview.dark { background: #151a17; }
.theme-preview.auto { background: linear-gradient(90deg, #f4f0e7 50%, #151a17 50%); }

.about-block {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.9;
}

.about-block .brand-mark {
  margin: 0 auto 10px;
}

.about-block strong {
  display: block;
  font-family: var(--serif);
  color: var(--ink);
  font-size: 16px;
  letter-spacing: 0.15em;
}

/* ---------- modal ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.modal-root.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 20, 16, 0.45);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}

.modal-card {
  position: relative;
  width: min(500px, 100%);
  max-height: min(86dvh, 820px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  pointer-events: auto;
  animation: modalIn 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}

.modal-card.wide {
  width: min(720px, 100%);
}

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

.modal-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 21px 22px 14px;
}

.modal-head-text {
  flex: 1;
  min-width: 0;
}

.modal-head h2 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.modal-head p {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
}

.modal-close {
  margin: -4px -6px 0 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 22px 20px;
}

.modal-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px calc(17px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}

.modal-foot .spacer {
  flex: 1;
}

.confirm-text {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  padding: 4px 0 2px;
}

.confirm-text strong {
  color: var(--ink);
}

/* ---------- toast ---------- */

.toast-root {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 480px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 10px 15px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.24s ease both;
  pointer-events: auto;
}

.toast.error {
  background: var(--danger);
  color: #fff8f5;
}

.toast.success {
  background: var(--accent-deep);
  color: #f7f3e9;
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.toast.out {
  animation: toastOut 0.2s ease both;
}

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

@keyframes toastOut {
  to { opacity: 0; transform: translateY(4px); }
}

.offline-banner {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(10px + var(--safe-top));
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
  font-size: 10.5px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---------- scrollbars ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- responsive ---------- */

@media (min-width: 1500px) {
  .app {
    grid-template-columns: 262px minmax(0, 1fr);
  }

  .chat-layout {
    grid-template-columns: 344px minmax(0, 1fr);
  }

  .thread-messages {
    width: min(880px, 100%);
  }
}

@media (max-width: 1100px) {
  .ledger-main {
    grid-template-columns: 1fr;
  }

  .ledger-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

@media (max-width: 900px) {
  .mobile-only {
    display: inline-grid !important;
  }

  .app {
    display: block;
    height: 100dvh;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    height: 100%;
    padding-bottom: calc(62px + var(--safe-bottom));
  }

  .topbar {
    min-height: 0;
    padding: calc(11px + var(--safe-top)) 16px 11px;
    gap: 10px;
  }

  .topbar-titles .eyebrow {
    display: none;
  }

  .topbar-titles h1 {
    font-size: 20px;
  }

  .topbar-actions .btn {
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }

  .topbar-actions .btn-label {
    display: none;
  }

  .view {
    padding: 18px 16px 28px;
  }

  .view.view-chat {
    padding: 0;
  }

  .bottom-nav {
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: calc(60px + var(--safe-bottom));
    padding: 4px 8px var(--safe-bottom);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(20px);
  }

  .bottom-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    max-width: 88px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.03em;
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .bottom-nav-item.active {
    color: var(--accent);
  }

  .bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 1px;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-warm);
  }

  .chat-layout {
    display: block;
    height: 100%;
  }

  .chat-list-pane {
    height: 100%;
    border-right: 0;
  }

  .thread-pane {
    display: none;
    height: 100%;
  }

  .chat-layout.has-active .chat-list-pane {
    display: none;
  }

  .chat-layout.has-active .thread-pane {
    display: flex;
  }

  .thread-messages {
    padding: 20px 15px 14px;
  }

  .thread-intro {
    padding: 34px 20px 56px;
  }

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

  .message-body {
    max-width: 88%;
  }

  .message-bubble {
    font-size: 13.5px;
    padding: 11px 14px;
  }

  .message-actions {
    opacity: 1;
  }

  .composer-wrap {
    padding: 6px 12px calc(10px + var(--safe-bottom));
  }

  .composer textarea {
    font-size: 16px;
    min-height: 48px;
  }

  .composer-hint {
    display: none;
  }

  .notes-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }

  .note-card {
    min-height: 164px;
    padding: 15px;
  }

  .note-title {
    font-size: 16px;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-card {
    padding: 14px 13px;
  }

  .summary-value {
    font-size: 19px;
  }

  .summary-label {
    font-size: 9px;
    letter-spacing: 0.06em;
  }

  .summary-sub {
    font-size: 9px;
  }

  .ledger-side {
    grid-template-columns: 1fr;
  }

  .settings-wrap {
    width: 100%;
  }

  .setting-row {
    flex-direction: column;
    gap: 9px;
    padding: 15px 16px;
  }

  .setting-label {
    flex: none;
    width: 100%;
  }

  .setting-control {
    width: 100%;
  }

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

  .qr-panel {
    align-items: flex-start;
  }

  .qr-image {
    width: 126px;
    height: 126px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card,
  .modal-card.wide {
    width: 100%;
    max-height: 90dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    animation: sheetIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  }

  @keyframes sheetIn {
    from { transform: translateY(40px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
  }

  .note-editor {
    min-height: 64dvh;
  }

  .modal-head {
    padding: 18px 18px 10px;
  }

  .modal-body {
    padding: 2px 18px 16px;
  }

  .modal-foot {
    padding: 12px 18px calc(14px + var(--safe-bottom));
  }

  .toast-root {
    bottom: calc(84px + var(--safe-bottom));
  }

  .auth-screen {
    display: block;
  }

  .auth-art {
    display: none;
  }

  .auth-panel {
    min-height: 100dvh;
    padding: 30px 24px calc(28px + var(--safe-bottom));
    justify-content: center;
  }

  .auth-mobile-brand {
    display: flex;
  }

  .auth-copyright {
    margin-top: auto;
  }
}

@media (max-width: 560px) {
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .note-card {
    min-height: 130px;
  }

  .note-excerpt {
    -webkit-line-clamp: 3;
  }

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

  .summary-card.balance {
    grid-column: 1 / -1;
    order: -1;
  }

  .summary-card.balance .summary-value {
    font-size: 28px;
  }

  .ledger-day-head {
    padding: 10px 14px;
  }

  .ledger-item {
    padding: 11px 13px;
  }

  .task-item {
    padding: 12px 13px;
  }

  .topbar-actions .icon-btn {
    width: 36px;
    height: 36px;
  }

  .priority-options {
    grid-template-columns: 1fr 1fr;
  }

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

  .theme-options {
    grid-template-columns: 1fr;
  }

  .theme-card {
    display: flex;
    align-items: center;
    gap: 9px;
  }

  .theme-preview {
    width: 48px;
    height: 24px;
    margin: 0;
    flex: none;
  }

  .auth-quote p {
    font-size: 32px;
  }

  .auth-card h1 {
    font-size: 30px;
  }
}

@media (max-height: 620px) and (max-width: 900px) {
  .auth-panel {
    justify-content: flex-start;
    padding-top: 40px;
  }

  .auth-mobile-brand {
    margin-bottom: 18px;
  }

  .auth-form {
    margin-top: 20px;
  }
}

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

[hidden] {
  display: none !important;
}
