/* Paper and graphite palettes shared across the application. */
:root {
  color-scheme: light;
  --cream: #f5efdf;
  --charcoal: #2f302b;
  --blue: #426578;
  --paper: var(--cream);
  --paper-soft: #fbf6e9;
  --paper-tint: #eee2cd;
  --ink: var(--charcoal);
  --muted: #615d51;
  --soft: #70685b;
  --rule: #d5c7b2;
  --strong: #918473;
  --wine: #963f2b;
  --wine-dark: #7b3526;
  --wine-soft: #efd7ca;
  --green: #2c6248;
  --green-soft: #e0e9d9;
  --amber: #76541c;
  --amber-soft: #f1e4c4;
  --danger: #963937;
  --danger-soft: #f2d9d1;
  --action-bg: #963f2b;
  --action-ink: #fff8e9;
  --field: #fbf6e9;
  --dock: #f5efdf;
  --frame: #dfd5c2;
  --shadow: 0 8px 24px #3c322115;
  --display-font: Georgia, "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --ui-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 16px;
  font-family: var(--ui-font);
}

html:has(body[data-route=gpt] #app:not(.hidden) #dashboard:not(.hidden)),
html:has(body[data-paper-tone=graphite]) {
  color-scheme: dark;
  --paper: #343530;
  --paper-soft: #40413b;
  --paper-tint: #4b4a41;
  --ink: #f8efd9;
  --muted: #e1d7bf;
  --soft: #cbc0a8;
  --rule: #635f51;
  --strong: #9a907b;
  --wine: #f3ad90;
  --wine-dark: #ffccb5;
  --wine-soft: #583a31;
  --green: #b9dcbe;
  --green-soft: #36483b;
  --amber: #f2d493;
  --amber-soft: #4d4131;
  --danger: #fac0b4;
  --danger-soft: #573c37;
  --field: #2c2d29;
  --dock: #343530;
  --frame: #272823;
  --shadow: 0 8px 24px #18191436;
}

html, body { background: var(--frame); }
body { font-family: var(--ui-font); }
.phone-shell { border-inline-color: var(--rule); }
::selection { background: var(--wine-soft); color: var(--ink); }
* { scrollbar-color: var(--strong) transparent; }
:where(h1, h2, .work-title) { font-family: var(--display-font); }

input:not([type=checkbox], [type=radio], [type=range]),
textarea, select {
  background: var(--field);
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--soft); }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline-color: var(--wine);
}
.primary {
  color: var(--action-ink);
  background: var(--action-bg);
  border-color: var(--action-bg);
}
.primary:focus-visible { background: var(--action-bg); }
.outline, .copy-button {
  color: var(--ink);
  background: var(--paper-soft);
  border-color: var(--strong);
}
.danger { border-color: var(--danger); }
.primary, .outline, .copy-button, .danger, .entry-switcher-trigger {
  border-radius: 999px;
}
.primary:not(:disabled):active, .outline:not(:disabled):active,
.copy-button:not(:disabled):active, .home-modules .feature-card:active {
  box-shadow: inset 0 1px 6px #221f2838;
  transform: scale(.985);
}

.entry-switcher-trigger {
  color: var(--ink);
  background: var(--paper);
  font-weight: 600;
}
.entry-switcher-links a { background: var(--paper); }
.entry-switcher-links a[aria-current] { background: var(--wine-soft); }
.entry-switcher-shell { overscroll-behavior: contain; }
.bottom-nav {
  background: var(--dock);
  border-top-color: var(--rule);
  backdrop-filter: none;
}
.bottom-nav a { border-radius: 12px; }
.bottom-nav a[aria-current=page] {
  color: var(--wine);
  background: var(--wine-soft);
  font-weight: 700;
}

.screen .masthead {
  padding-bottom: 12px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--rule);
}
.masthead .brand-block { flex: 1; }
.brand-mark {
  flex: 0 0 36px;
  color: var(--action-ink);
  border: 0;
  border-radius: 50%;
  background: var(--action-bg);
  font: 700 24px/1 var(--display-font);
}
.brand-block h1 {
  font-family: var(--display-font);
  font-size: 19px;
  color: var(--ink);
}
.auth-screen {
  padding-top: max(62px, calc(env(safe-area-inset-top) + 60px));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.login-cover { text-align: center; }
.login-illustration {
  display: block;
  width: min(52vw, 172px);
  height: auto;
  margin: 0 auto 13px;
}
.login-cover h1 {
  margin: 0;
  font: 700 clamp(34px, 10vw, 46px)/1.15 var(--display-font);
  letter-spacing: -.04em;
}
.auth-screen .lead {
  margin: 13px auto 7px;
  max-width: 29ch;
  text-align: center;
  font-size: 14px;
}
.auth-screen .editorial-form { width: 100%; max-width: 344px; margin: 0 auto; }
.auth-screen input { border-radius: 12px; }

.home-view { display: block; }
.home-view .home-hero {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 4px;
  padding-block: 18px 20px;
  margin: 0;
}
.home-hero h2 {
  margin: 0;
  color: var(--ink);
  font: 700 clamp(38px, 12vw, 54px)/1.02 var(--display-font);
  letter-spacing: -.06em;
}
.home-hero h2 span { font-size: 1.18em; }
.home-hero p { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.home-hero img { display: block; width: 100%; max-width: 225px; height: auto; justify-self: end; }
.home-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.home-modules .feature-card {
  margin: 0;
  padding: 13px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 7px;
  align-items: center;
  border-radius: 16px;
  min-height: 86px;
  background: var(--paper-soft);
  border-color: var(--strong);
  color: var(--ink);
  transition: transform .14s ease-out, box-shadow .14s ease-out;
}
.home-modules .feature-content > strong {
  font: 700 clamp(17px, 5vw, 22px)/1.2 var(--display-font);
}
.home-modules .feature-content > small { color: inherit; opacity: .82; margin-top: 5px; }
.home-modules .feature-arrow { color: inherit; }
.home-modules #open-gpt {
  grid-column: 1 / -1;
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: var(--cream);
  border-radius: 16px;
  padding: 14px 16px;
}
.home-modules #open-gpt::after { content: none; }
.home-modules #open-gpt .feature-content > strong { font-size: 24px; }
.home-modules #open-media { background: var(--blue); color: var(--action-ink); border-color: var(--blue); }
.home-modules .home-signal {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #eadcc0;
  margin: 4px 0 0;
  padding: 7px 0 0;
  border-top: 1px solid #ffffff34;
}
.home-modules .home-signal-dot { background: #f4c291; }
.home-modules .home-signal-dot.available { background: #b9dcbe; }
.home-devices-section { margin-top: 20px; }
.home-devices-section:has(#home-devices:empty) { display: none; }
.home-devices-section h3, .attention-list h3 {
  font: 700 18px/1.35 var(--display-font);
  margin-bottom: 8px;
}
.home-view .device-slot { background: var(--paper-soft); border-color: var(--rule); color: var(--ink); }
.home-view .device-slot-name { color: var(--muted); }
.home-view .device-slot-account { color: var(--ink); }
.home-view .device-slot-quota { color: var(--green); }
.home-view .attention-list { margin-top: 20px; }
.home-view .attention-list button { min-height: 46px; }
.home-view .attention-list button > span { flex-shrink: 0; }
.home-view .attention-list b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#view-settings .page-heading h2 { font: 700 34px/1.2 var(--display-font); }
#view-settings .setting-card, #view-settings .danger-zone { box-shadow: none; }
#view-settings .setting-card-head h3 { font-size: 15px; }
#view-settings .my-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  font-weight: 600;
}
#view-settings .my-group > summary::-webkit-details-marker { display: none; }
#view-settings .my-group > summary::after {
  content: "";
  flex: 0 0 7px;
  height: 7px;
  border-inline-end: 1px solid var(--wine);
  border-block-end: 1px solid var(--wine);
  transform: rotate(45deg);
}
#view-settings .my-group[open] > summary::after { transform: rotate(225deg); }
body[data-route=me] .masthead { margin-bottom: 22px; }
.setup-panel { margin-top: 18px; }
.settings-form input { background: var(--field); }

#flash, #reader-toast { background: var(--paper-soft); border-color: var(--strong); }
#flash[data-tone=error] { background: var(--danger-soft); border-color: var(--danger); }
dialog::backdrop { background: #22231eba; }
.dialog-head h2 { font-family: var(--display-font); }
dialog .reset-preview { background: var(--paper-tint); color: var(--ink); border-color: var(--rule); }
#quota-undo { background: var(--green-soft); border-color: var(--green); color: var(--ink); }

@media (hover: hover) and (pointer: fine) {
  .outline:hover, .copy-button:hover { background: var(--paper-tint); }
  .primary:not(:disabled):hover { background: #7b3526; border-color: #7b3526; }
  .home-modules .feature-card:hover { box-shadow: 0 3px 0 #2f302b45; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .login-illustration { width: 84px; }
  .home-hero img { max-width: 145px; }
}

@media (prefers-reduced-motion: reduce) {
  .home-modules .feature-card { transition: none; }
  .home-modules .feature-card:active, .primary:not(:disabled):active,
  .outline:not(:disabled):active, .copy-button:not(:disabled):active { transform: none; }
}
