/* Shared tokens, reset and topbar for every Valunium screen. */
:root {
  --paper: #FBFAF7;
  --ink: #1B1A17;
  --muted: #6F6A61;
  --line: #E7E3D9;
  --accent: #E0A400;
  --accent-strong: #8A6A00;
  --accent-soft: #FBF0CF;
  --on-accent: #1A1500;
  --positive: #00A300;
  --negative: #FF0000;
  --upcoming-in: #0000FF;
  --upcoming-out: #FF7F00;
  --danger: #FF0000;
  --danger-soft: #F6E9E6;
  --sk-base: #ECE8DF;
  --sk-shine: #F6F3EB;

  --topbar-h: 56px;
  --gutter: clamp(16px, 4vw, 40px);
  --amount-col: 104px;

  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-brand: 'Readex Pro', var(--font-ui);
}

/* Dark palette — applied when the OS asks for it (and the user hasn't forced
   light), or when the user explicitly picks dark via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #16150F;
    --ink: #ECEAE3;
    --muted: #918B7F;
    --line: #2A2720;
    --accent: #E9BE38;
    --accent-strong: #EBCB6B;
    --accent-soft: #2C2610;
    --on-accent: #17130A;
    --positive: #6FBF8E;
    --negative: #E3846F;
    --upcoming-in: #7CB3E8;
    --upcoming-out: #E5A25C;
    --danger: #E08472;
    --danger-soft: #2A1C19;
    --sk-base: #221F17;
    --sk-shine: #2C2820;
  }
}

:root[data-theme='dark'] {
  --paper: #16150F;
  --ink: #ECEAE3;
  --muted: #918B7F;
  --line: #2A2720;
  --accent: #E9BE38;
  --accent-strong: #EBCB6B;
  --accent-soft: #2C2610;
  --on-accent: #17130A;
  --positive: #6FBF8E;
  --negative: #E3846F;
  --upcoming-in: #7CB3E8;
  --upcoming-out: #E5A25C;
  --danger: #E08472;
  --danger-soft: #2A1C19;
  --sk-base: #221F17;
  --sk-shine: #2C2820;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over component display rules (e.g. .field). */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* The signed-in app is a fixed shell; each view scrolls its own content. */
body.app {
  height: 100dvh;
  overflow: hidden;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* On navigation only the view content animates — the top bar never does. */
@media (prefers-reduced-motion: no-preference) {
  .view-animate > * { animation: view-fade-in 0.26s ease both; }
}

@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(8px); }
}

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

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

:where(a, button):focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---- Topbar ---- */
.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar::-webkit-scrollbar { display: none; }
/* Nudge the whole row a little below the vertical centre. */
.topbar > * { flex: none; margin-top: 4px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
}

img.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 0;
  object-fit: cover;
  background: none;
}

.brand-suffix {
  color: var(--muted);
  font-weight: 500;
}

.nav {
  position: relative;
  display: flex;
  gap: 22px;
  padding-bottom: 6px;
}

.nav-link {
  padding: 4px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-link:hover { color: var(--ink); }
.nav-link.is-active { color: var(--ink); }

/* The one moving underline — it slides between nav items. */
.nav-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

@media (max-width: 560px) {
  .nav-indicator { display: none; }
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.account {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.linkbtn {
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.linkbtn:hover { color: var(--ink); }

/* Top-bar selects (account + language) */
.chrome-select {
  font: inherit;
  font-size: 12px;
  max-width: 190px;
  padding: 5px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chrome-select--lang {
  max-width: 108px;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .nav-link { transition: none; }
}

/* ---- Hamburger + mobile drawer ---- */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 0 7px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: var(--ink);
}

.drawer {
  height: 100dvh;
  max-height: 100dvh;
  width: min(300px, 82vw);
  max-width: none;
  margin: 0 0 0 auto;
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  transform: translateX(100%);
  transition:
    transform 0.24s ease,
    overlay 0.24s ease allow-discrete,
    display 0.24s ease allow-discrete;
}

.drawer[open] { transform: none; }
.drawer:not([open]) { display: none; }

@starting-style {
  .drawer[open] { transform: translateX(100%); }
}

.drawer::backdrop {
  background: rgba(15, 17, 15, 0);
  transition:
    background 0.24s ease,
    overlay 0.24s ease allow-discrete,
    display 0.24s ease allow-discrete;
}

.drawer[open]::backdrop { background: rgba(15, 17, 15, 0.4); }

@starting-style {
  .drawer[open]::backdrop { background: rgba(15, 17, 15, 0); }
}

.drawer-inner {
  display: flex;
  flex-direction: column;
  padding: 16px 18px 24px;
}

.drawer-close {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
}

.drawer-link {
  padding: 13px 2px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.drawer-link.is-active {
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: 10px;
}

.drawer-section {
  display: flex;
  align-items: center;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}

.drawer-row { justify-content: space-between; }

.drawer-label {
  font-size: 13px;
  color: var(--muted);
}

.drawer-item {
  width: 100%;
  padding: 0;
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}

.drawer-row .chrome-select { max-width: 140px; }

@media (max-width: 700px) {
  .chrome-select { max-width: 128px; }
}

@media (max-width: 560px) {
  .topbar { gap: 14px; overflow-x: visible; }
  .nav,
  .topbar-end { display: none; }
  .hamburger { display: flex; }
}
