/* Journal vertical — palette overrides for the 5 wellness theme presets.
   The shell layout / components come from styles.css; this file only swaps tokens. */

[data-theme="morning-light"] {
  --c-surface:   #fbf2dc;
  --c-surface-2: #f4e9c8;
  --c-surface-3: #ecdda9;
  --c-surface-rail: #f0e3bc;
  --c-canvas:    #f8eed4;

  --c-text:      #3a2c1c;
  --c-text-muted:#7a6a52;
  --c-rule:      #978765;

  --c-accent:    #ca7149;
  --c-energy:    #789166;
  --c-caution:   #d9a521;
  --c-info:      #6b8a9c;
  --c-orange:    #c97f3a;

  --c-accent-soft:  #f5d8c4;
  --c-energy-soft:  #d8e2c4;
  --c-caution-soft: #f5e3b1;
  --c-info-soft:    #cedce4;

  --shadow-paper:
    0 1px 0 rgba(0,0,0,.06),
    0 2px 0 var(--c-surface-2),
    0 4px 0 #e2cf99,
    0 6px 16px rgba(80,50,10,.12);
}

[data-theme="lunar-calm"] {
  --c-surface:   #e8e2ec;
  --c-surface-2: #ddd5e3;
  --c-surface-3: #cec3d5;
  --c-surface-rail: #ded6e3;
  --c-canvas:    #e3dce8;

  --c-text:      #3d3247;
  --c-text-muted:#685d74;
  --c-rule:      #84798c;

  --c-accent:    #99728b;
  --c-energy:    #757e91;
  --c-caution:   #d9b47e;
  --c-info:      #92a4b6;
  --c-orange:    #c69aa0;

  --c-accent-soft:  #e4d3df;
  --c-energy-soft:  #d6dde8;
  --c-caution-soft: #efddc0;
  --c-info-soft:    #d4dde5;
}

[data-theme="forest-bath"] {
  --c-surface:   #e8e6d4;
  --c-surface-2: #dcd9bf;
  --c-surface-3: #c8c4a3;
  --c-surface-rail: #ddd9bf;
  --c-canvas:    #e2dfca;

  --c-text:      #2f3a26;
  --c-text-muted:#5a664c;
  --c-rule:      #808061;

  --c-accent:    #6b7a4f;
  --c-energy:    #728355;
  --c-caution:   #c4a04a;
  --c-info:      #4f7a6a;
  --c-orange:    #a87c4a;

  --c-accent-soft:  #d2d6b8;
  --c-energy-soft:  #d8e0c0;
  --c-caution-soft: #ead9a8;
  --c-info-soft:    #c0d0c8;
}

[data-theme="tidepool"] {
  --c-surface:   #dde8e6;
  --c-surface-2: #cfddd9;
  --c-surface-3: #bbcec8;
  --c-surface-rail: #d2dfdb;
  --c-canvas:    #d6e3df;

  --c-text:      #1f3a3a;
  --c-text-muted:#51676e;
  --c-rule:      #70827e;

  --c-accent:    #c16749;
  --c-energy:    #5e896b;
  --c-caution:   #d9a548;
  --c-info:      #4a7a8c;
  --c-orange:    #b08850;

  --c-accent-soft:  #f0d3c4;
  --c-energy-soft:  #c8e0d2;
  --c-caution-soft: #f0dcb2;
  --c-info-soft:    #c2d8e0;
}

[data-theme="soft-cloud"] {
  --c-surface:   #fceaf0;
  --c-surface-2: #f6dde6;
  --c-surface-3: #efcdd9;
  --c-surface-rail: #f4d6de;
  --c-canvas:    #fde2e9;

  --c-text:      #5a3850;
  --c-text-muted:#7e5f70;
  --c-rule:      #a6798d;

  --c-accent:    #ae748a;
  --c-energy:    #708b84;
  --c-caution:   #f5c77e;
  --c-info:      #c2b6e8;
  --c-orange:    #f5b9a2;

  --c-accent-soft:  #f8d8e2;
  --c-energy-soft:  #d8efe8;
  --c-caution-soft: #fae6c2;
  --c-info-soft:    #e5dff5;
}

/* journal-specific structural tweaks */
.journal-shell .stamp {
  font-family: var(--ff-display);
  font-style: italic;
  font-weight: 500;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .18em;
  padding: 4px 12px;
  text-transform: none;
  opacity: .8;
}

.journal-shell .card--memory {
  background:
    linear-gradient(180deg, transparent 0%, color-mix(in oklab, var(--c-surface-3) 50%, transparent) 100%),
    var(--c-surface);
  background-image: var(--paper-grain);
  border-style: dashed;
}

.journal-shell .map-label { font-family: var(--ff-marker); font-size: 13px; }

/* the n-key hint — softer than the agent demo */
.journal-shell .badge { font-family: var(--ff-body); font-style: italic; letter-spacing: 0; }

/* ─── editor surface (V3-04) ─────────────────────────────────────────── */
.journal-shell .editor-body { padding-top: 4px; }

.journal-shell .lumen-question {
  font-family: var(--ff-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-energy-soft);
  border-left: 3px solid var(--c-energy);
  padding: 8px 12px;
  border-radius: 0 var(--r-2) var(--r-2) 0;
  margin: 0 0 12px;
}
.journal-shell .lumen-question::before {
  content: "拾光问： ";
  font-family: var(--ff-display);
  font-style: normal;
  font-weight: 600;
  color: var(--c-energy);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.journal-shell .journal-editor {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 6px 0;
  border: none;
  outline: none;
  background: transparent;
  /* horizontal ruled-paper lines, pure CSS */
  background-image: linear-gradient(
    transparent calc(100% - 1px),
    color-mix(in oklab, var(--c-rule) 35%, transparent) calc(100% - 1px)
  );
  background-size: 100% 32px;
  font-family: var(--ff-marker), var(--ff-body);
  font-size: 18px;
  line-height: 32px;
  color: var(--c-text);
  resize: vertical;
  caret-color: var(--c-accent);
}
.journal-shell .journal-editor::placeholder {
  color: var(--c-text-muted);
  font-style: italic;
  opacity: 0.55;
}
.journal-shell .journal-editor:read-only {
  color: var(--c-text-muted);
  font-style: italic;
  cursor: default;
}

.journal-shell .save-indicator {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--c-text-muted);
  text-align: right;
  padding: 6px 2px 0;
  font-style: italic;
  border-top: 1px dashed var(--c-rule);
  margin-top: 8px;
}
.journal-shell .save-indicator.is-saving {
  color: var(--c-caution);
  font-style: normal;
}

/* ─── mood picker ────────────────────────────────────────────────────── */
.journal-shell .mood-picker {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: -3px;
}
.journal-shell .mood-chip {
  padding: 1px 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--c-rule);
  cursor: pointer;
  font-family: var(--ff-body);
  font-size: 13px;
  color: var(--c-text-muted);
  transition: transform .08s ease;
}
.journal-shell .mood-chip:hover { color: var(--c-text); border-color: var(--c-text); transform: translateY(-1px); }
.journal-shell .mood-chip.is-active {
  background: var(--c-energy-soft);
  border-color: var(--c-energy);
  color: var(--c-text);
  font-weight: 600;
}
.journal-shell .mood-chip:disabled { opacity: 0.5; cursor: default; }
.journal-shell .mood-chip:disabled:hover { transform: none; color: var(--c-text-muted); border-color: var(--c-rule); }

/* ─── sidebar 14-day list ────────────────────────────────────────────── */
.journal-shell #week-tree { padding: 0; margin: 0; list-style: none; font-size: 13px; }
.journal-shell #week-tree .tree__item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-radius: var(--r-1);
  cursor: pointer;
  position: relative;
}
.journal-shell #week-tree .tree__item::before { display: none; }
.journal-shell #week-tree .tree__item:hover { background: var(--c-surface); }
.journal-shell #week-tree .tree__item.is-current {
  background: var(--c-surface);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--c-accent);
}
.journal-shell #week-tree .tree__item.is-today { color: var(--c-text); }
.journal-shell #week-tree .day-dot {
  display: inline-block; width: 14px; text-align: center;
  color: var(--c-rule); font-family: var(--ff-mono); font-size: 14px;
}
.journal-shell #week-tree .day-dot.is-filled { color: var(--c-energy); }
.journal-shell #week-tree .day-meta {
  margin-left: auto;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--c-text-muted);
}

/* ─── lumen stream (right panel) ─────────────────────────────────────── */
.lumen-stream { padding: 4px; }
.lumen-stream .msg--streaming .msg-text::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  animation: caret-blink 1.05s step-end infinite;
  color: var(--c-energy);
  font-weight: 700;
}
@keyframes caret-blink {
  50% { opacity: 0; }
}

.lumen-actions {
  display: flex;
  gap: 6px;
  padding: 8px 0 0;
  border-top: 1px dashed var(--c-rule);
  margin-top: 8px;
}
.lumen-actions .btn { font-size: 12px; padding: 5px 10px; flex: 1; }

.patterns-result {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--c-energy-soft);
  border-left: 3px solid var(--c-energy);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  font-size: 13px;
  line-height: 1.6;
}
.patterns-title {
  margin: 0 0 6px;
  font-family: var(--ff-display);
  font-size: 13px;
  color: var(--c-energy);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.patterns-list {
  list-style: none;
  padding: 0; margin: 0;
}
.patterns-list li {
  padding: 4px 0 4px 16px;
  position: relative;
}
.patterns-list li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--c-energy);
  font-weight: 700;
}

.badge.is-warn { color: var(--c-caution); border-color: var(--c-caution); background: var(--c-caution-soft); }
.badge.is-err { color: var(--c-accent); border-color: var(--c-accent); background: var(--c-accent-soft); }

/* ─── settings drawer ─────────────────────────────────────────────────── */
.settings-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(480px, 92vw);
  height: 100vh;
  background: var(--c-surface);
  background-image: var(--paper-grain);
  border-left: 1px solid var(--c-rule);
  box-shadow: -8px 0 24px rgba(60,40,10,.18);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 9999;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.settings-drawer.is-open { transform: translateX(0); }

.settings-drawer__head {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-rule);
  background: var(--c-surface-2);
}
.settings-drawer__head h2 {
  margin: 0; flex: 1;
  font-family: var(--ff-display);
  font-size: 19px;
  font-weight: 700;
}
.settings-drawer__head .iconbtn {
  font-size: 22px;
  padding: 0 10px;
  line-height: 1;
}

.settings-drawer__body {
  padding: 18px 20px 32px;
  flex: 1;
}
.settings-drawer__body hr {
  border: 0;
  border-top: 1px dashed var(--c-rule);
  margin: 22px 0;
}
.settings-drawer h3 {
  margin: 0 0 8px;
  font-family: var(--ff-display);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--c-text-muted);
}
.settings-drawer p { margin: 4px 0 12px; line-height: 1.55; }

.settings-section--info p { font-size: 13px; line-height: 1.7; }

.settings-field {
  display: block;
  margin: 12px 0;
}
.settings-field > span {
  display: block;
  font-family: var(--ff-display);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-text-muted);
  margin-bottom: 4px;
}
.settings-field input,
.settings-field select {
  width: 100%;
  padding: 8px 10px;
  background: var(--c-surface);
  background-image: var(--paper-grain);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-2);
  font-family: var(--ff-body);
  font-size: 14px;
  color: var(--c-text);
  outline: none;
  transition: border-color .15s ease;
}
.settings-field input:focus,
.settings-field select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--c-accent) 20%, transparent);
}
.settings-field small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.settings-actions .btn--primary {
  background: var(--c-accent);
  color: var(--c-surface);
  border-color: var(--c-accent);
  font-weight: 600;
}

.settings-result {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--r-2);
  font-size: 13px;
  line-height: 1.5;
  min-height: 1em;
}
.settings-result:empty { display: none; }
.settings-result.is-ok {
  background: var(--c-energy-soft);
  color: var(--c-text);
  border-left: 3px solid var(--c-energy);
}
.settings-result.is-err {
  background: var(--c-accent-soft);
  color: var(--c-text);
  border-left: 3px solid var(--c-accent);
}

/* Mode badge + Keychain migration block (V3-12-13/14) */
.settings-mode-badge {
  margin: 4px 0 14px;
  font-size: 12px;
}
.settings-mode-badge .badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--c-text), transparent 80%);
  background: color-mix(in oklab, var(--c-text), transparent 96%);
  color: var(--c-text);
  font-style: normal;
  letter-spacing: 0.02em;
}
.settings-mode-badge .badge--ok {
  border-color: color-mix(in oklab, var(--c-energy), transparent 50%);
  background: var(--c-energy-soft);
  color: var(--c-text);
}
.settings-mode-badge .badge--mode {
  border-style: dashed;
}

.settings-migration {
  margin: 6px 0 16px;
  padding: 12px 14px;
  border-radius: var(--r-2);
  background: color-mix(in oklab, var(--c-caution, #c89344), transparent 90%);
  border-left: 3px solid var(--c-caution, #c89344);
}
.settings-migration[hidden] { display: none; }
.settings-migration p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
}

/* ─── Theme Studio overlays (V3-02) ─────────────────────────────────────── */

:root {
  --studio-paper-tint: 0;       /* -1 ↔ 0 ↔ 1 — saturate/brightness filter on body */
  --studio-corner: 1;           /* 0.5 ↔ 1 ↔ 1.5 — multiplier on border-radius */
  --studio-density: 1;          /* 0.7 ↔ 1 ↔ 1.3 — multiplier on padding/gap */
  --studio-font-scale: 1;       /* 0.9 ↔ 1 ↔ 1.15 — multiplier on body font-size */
}

/* Paper tint — global filter on the journal shell.
   Negative tint = desaturated + slightly darker (cool/calm).
   Positive tint = saturated + slightly brighter (warm/vivid).
   Filter on body affects everything visually but not text legibility. */
body.journal-shell {
  filter:
    saturate(calc(1 + var(--studio-paper-tint) * 0.25))
    brightness(calc(1 + var(--studio-paper-tint) * 0.04));
  transition: filter 220ms ease;
}

/* Roundness — apply to most-visible interactive surfaces */
.card,
.panel,
.btn,
.iconbtn,
.swatch,
.mood-chip,
.journal-editor,
.settings-drawer,
.settings-field input,
.settings-field select,
.lumen-stream .msg {
  border-radius: calc(var(--r-2) * var(--studio-corner));
  transition: border-radius 200ms ease;
}

/* Density — paddings on cards + panels + table rows */
.card { padding: calc(18px * var(--studio-density)); }
.panel { padding: calc(14px * var(--studio-density)); }
.plan th, .plan td, .tt td {
  padding: calc(7px * var(--studio-density)) calc(10px * var(--studio-density));
}
.studio-sliders { gap: calc(10px * var(--studio-density)); }

/* Font scale — body + key headings + editor */
body.journal-shell { font-size: calc(15px * var(--studio-font-scale)); }
.card__title, .panel__title { font-size: calc(15px * var(--studio-font-scale)); }
.journal-editor { font-size: calc(18px * var(--studio-font-scale)); }
.lumen-question { font-size: calc(17px * var(--studio-font-scale)); }

/* ─── Slider UI (paper-on-paper aesthetic) ─────────────────────────────── */

.studio-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--c-rule);
}
.studio-slider {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--c-text-muted);
  cursor: pointer;
}
.studio-slider__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  letter-spacing: 0.04em;
}
.studio-slider__val {
  font-family: var(--ff-mono);
  font-size: 10px;
  color: var(--c-text);
  font-style: normal;
  letter-spacing: 0;
}
.studio-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--c-surface-2);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
}
.studio-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-energy);
  border: 2px solid var(--c-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.20);
  cursor: grab;
  transition: transform 120ms ease;
}
.studio-slider input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  background: var(--c-text);
  transform: scale(1.15);
}
.studio-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-energy);
  border: 2px solid var(--c-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.20);
  cursor: grab;
}
.studio-reset {
  align-self: flex-end;
  font-size: 11px;
  padding: 4px 12px;
  margin-top: 4px;
}

/* Today row in weekly rhythm table (V3-07 polish) */
.plan tr.is-today td {
  background: var(--c-energy-soft);
  font-weight: 600;
}

/* ─── Lockscreen overlay (V3-09) ────────────────────────────────────────── */

.lockscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-canvas);
  background-image: var(--paper-grain);
  padding: 20px;
}
.lockscreen__card {
  max-width: 480px;
  width: 100%;
  padding: 36px 32px 28px;
  background: var(--c-surface);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-paper, 0 8px 30px rgba(40,30,10,.18));
  text-align: center;
}
.lockscreen__seal {
  margin: 0 auto 16px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lockscreen__title {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--c-text);
  letter-spacing: 0.02em;
}
.lockscreen__lede {
  font-size: 13px;
  line-height: 1.6;
  color: var(--c-text-muted);
  margin: 0 0 24px;
}
.lockscreen__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.lockscreen__form input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--ff-body);
  font-size: 15px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-2);
  color: var(--c-text);
  text-align: center;
  letter-spacing: 0.5em;
}
.lockscreen__form input[type="password"]:focus {
  outline: none;
  border-color: var(--c-energy);
  box-shadow: 0 0 0 3px var(--c-energy-soft);
}
.lockscreen__form button[type="submit"] {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
}
.lockscreen__hint {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--r-1);
  margin-bottom: 12px;
  min-height: 1em;
}
.lockscreen__hint.is-ok {
  background: var(--c-energy-soft);
  color: var(--c-text);
}
.lockscreen__hint.is-err {
  background: var(--c-accent-soft);
  color: var(--c-text);
}
.lockscreen__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}
.lockscreen__warn {
  font-size: 11px;
  line-height: 1.7;
  color: var(--c-text-muted);
  margin: 18px 0 0;
  font-style: italic;
}
body.is-locked > *:not(.lockscreen) {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

/* ─── Encryption section in settings drawer (V3-09) ─────────────────────── */

.settings-encryption-status {
  margin: 6px 0 12px;
  font-size: 12px;
}
.settings-encryption-status .badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--c-text), transparent 80%);
  background: color-mix(in oklab, var(--c-text), transparent 96%);
  color: var(--c-text);
  font-style: normal;
  letter-spacing: 0.02em;
}
.settings-encryption-status .badge--ok {
  border-color: color-mix(in oklab, var(--c-energy), transparent 50%);
  background: var(--c-energy-soft);
}
.settings-encryption-status .badge--mode {
  border-style: dashed;
}

/* ─── Passphrase modal (V3-09 slice 2) ──────────────────────────────────── */

.pp-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pp-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 8, 0.55);
}
.pp-modal__card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  padding: 22px 22px 16px;
  background: var(--c-surface);
  border-radius: var(--r-3);
  box-shadow: 0 16px 50px rgba(20, 15, 8, .4);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pp-modal__title {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--c-text);
  letter-spacing: 0.02em;
}
.pp-modal__lede {
  font-size: 12px;
  line-height: 1.55;
  color: var(--c-text-muted);
  margin: 0;
}
.pp-modal__card input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--ff-body);
  font-size: 14px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-rule);
  border-radius: var(--r-2);
  color: var(--c-text);
  letter-spacing: 0.3em;
}
.pp-modal__card input[type="password"]:focus {
  outline: none;
  border-color: var(--c-energy);
  box-shadow: 0 0 0 3px var(--c-energy-soft);
}
.pp-modal__hint {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--r-1);
}
.pp-modal__hint.is-err {
  background: var(--c-accent-soft);
  color: var(--c-text);
}
.pp-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
