/* lifeOS journal — interface styles.
   Same method as src/radar/web/static/app.css: CSS custom properties, a
   three-state theme (system/light/dark), and a fixed-order categorical
   palette for the six entry types — reusing radar's validated slot colours
   rather than inventing a new palette for a second product. */

:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f2f1ed;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --ink-muted:   #898781;
  --rule:        #e1e0d9;
  --rule-strong: #c3c2b7;

  /* type slots, fixed order: work, trading, health, idea, win, vent */
  --t-work:    #2a78d6;
  --t-trading: #eb6834;
  --t-health:  #1baf7a;
  --t-idea:    #eda100;
  --t-win:     #e87ba4;
  --t-vent:    #6d6a63;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
}

/* Three states, not two — an explicit choice stamps data-theme on <html>;
   the default "system" stamps nothing, so only the media query applies. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:        #0d0d0d;
    --surface:     #1a1a19;
    --surface-2:   #232322;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #898781;
    --rule:        #2c2c2a;
    --rule-strong: #383835;
    --t-work:    #3987e5;
    --t-trading: #d95926;
    --t-health:  #199e70;
    --t-idea:    #c98500;
    --t-win:     #d55181;
    --t-vent:    #9b9890;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #232322;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-muted:   #898781;
  --rule:        #2c2c2a;
  --rule-strong: #383835;
  --t-work:    #3987e5;
  --t-trading: #d95926;
  --t-health:  #199e70;
  --t-idea:    #c98500;
  --t-win:     #d55181;
  --t-vent:    #9b9890;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- header ---------- */

header.top {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.top-inner {
  max-width: 720px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 14px; min-height: 54px;
  flex-wrap: wrap;
}
.brand { font-weight: 620; letter-spacing: -0.01em; font-size: 15px; color: var(--ink); }
.brand span { color: var(--ink-muted); font-weight: 420; }
.loop-counter {
  margin-left: auto; font-size: 13px; color: var(--ink-2);
  background: var(--surface-2); border-radius: 999px; padding: 5px 11px;
}
.theme-btn {
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px;
}
.theme-btn:hover { background: var(--surface-2); }
.signout { color: var(--ink-muted); font-size: 13px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-top: 16px;
}
.card h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 620; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--ink-muted);
}
.empty { color: var(--ink-muted); font-size: 14px; margin: 0; }

/* ---------- loops ---------- */

.loops-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.loop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--surface-2); border-radius: 8px; flex-wrap: wrap;
}
.loop-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.loop-text { font-size: 14px; word-break: break-word; }
.loop-when { font-size: 12px; color: var(--ink-muted); }

.btn {
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 9px 14px; font-size: 13px; cursor: pointer;
  min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn-close { border-color: var(--t-vent); color: var(--t-vent); white-space: nowrap; }

/* ---------- goals ---------- */

.goals-form { display: flex; flex-direction: column; gap: 10px; }
.goals-form textarea {
  width: 100%; resize: vertical; font: inherit; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--page); color: var(--ink);
}
.btn-save { align-self: flex-start; border-color: var(--t-work); color: var(--t-work); }

/* ---------- filters (chips) ---------- */

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; min-height: 32px;
  display: inline-flex; align-items: center;
}
.chip:hover { border-color: var(--rule-strong); text-decoration: none; }
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* ---------- feed ---------- */

.feed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed-item {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 11px 0; border-bottom: 1px solid var(--rule);
}
.feed-item:last-child { border-bottom: none; }
.feed-text { font-size: 14px; flex: 1 1 220px; min-width: 0; word-break: break-word; }
.feed-when { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

.type-chip {
  font-size: 11px; font-weight: 620; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.type-work    { background: var(--t-work); }
.type-trading { background: var(--t-trading); }
.type-health  { background: var(--t-health); }
.type-idea    { background: var(--t-idea); }
.type-win     { background: var(--t-win); }
.type-vent    { background: var(--t-vent); }

.loop-marker {
  font-size: 11px; color: var(--t-work); border: 1px solid var(--t-work);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.loop-marker.closed { color: var(--ink-muted); border-color: var(--rule-strong); }

/* ---------- pagination ---------- */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule);
}
.pager-link { font-size: 13px; padding: 8px 4px; min-height: 32px; display: inline-flex; align-items: center; }
.pager-link.disabled { color: var(--ink-muted); pointer-events: none; }
.pager-status { font-size: 12px; color: var(--ink-muted); }

/* ---------- sign-in ---------- */

.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(1100px 520px at 50% -8%, var(--surface-2), transparent 70%),
    var(--page);
}

.login-shell { width: 100%; max-width: 384px; }

.login-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  box-shadow: var(--shadow); padding: 34px 32px 30px;
}

.login-mark {
  width: 46px; height: 46px; border-radius: 11px;
  display: grid; place-items: center; margin-bottom: 20px;
  background: var(--surface-2); color: var(--t-work);
  border: 1px solid var(--rule);
}

.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 640; letter-spacing: -0.02em; }
.login-sub { margin: 0 0 24px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }

.login-error {
  background: var(--surface-2); border-left: 3px solid var(--t-vent);
  border-radius: 0 7px 7px 0; padding: 10px 13px; margin-bottom: 20px;
  font-size: 13.5px; color: var(--ink);
}

.login-card label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}

.login-card input {
  width: 100%; padding: 10px 12px; margin-bottom: 17px;
  background: var(--page); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 8px;
  font: inherit; font-size: 14.5px;
}
.login-card input:focus {
  outline: none; border-color: var(--t-work);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-work) 22%, transparent);
}

.login-card button {
  width: 100%; padding: 11px 14px; margin-top: 4px;
  background: var(--t-work); color: #fff;
  border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 600;
}
.login-card button:hover { filter: brightness(1.08); }
.login-card button:focus-visible { outline: 2px solid var(--t-work); outline-offset: 2px; }

/* ---------- mobile ---------- */

@media (max-width: 480px) {
  .top-inner { min-height: 48px; }
  .brand span { display: none; }
  .card { padding: 14px; }
  .loop-item { flex-direction: column; align-items: stretch; }
  .btn-close { width: 100%; }
  .feed-item { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
