/* Daily Card app — mobile-first, minimalist.
 * Shares the document-paper aesthetic of the landing page:
 * serif body, warm off-white, gold accent, generous whitespace. */

:root {
  --paper:    #faf8f3;
  --panel:    #fffdf8;
  --ink:      #1f1b16;
  --ink-soft: #4a443c;
  --ink-faint:#8b8377;
  --rule:     #e2dccc;
  --rule-soft:#ece6d8;
  --gold:     #9c7b2a;
  --red:      #8a3221;
  --code-bg:  #f0ece2;
  --serif: "Iowan Old Style", "Charter", "Cormorant Garamond", "EB Garamond", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  --maxw: 620px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 20px env(safe-area-inset-bottom, 0px);
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top, 0px), 14px) 0 10px;
}
.brand {
  font-size: 0.82rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: none; font-weight: 600;
}
.brand span { color: var(--gold); }
.settings-btn {
  border: none; background: none; cursor: pointer;
  font-size: 1.25rem; color: var(--ink-soft); line-height: 1;
  padding: 6px; border-radius: 6px;
}
.settings-btn:hover { color: var(--ink); }

/* ---- tabs ---- */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 22px;
}
.tab {
  flex: 1; appearance: none; border: none; background: none;
  font-family: var(--serif); font-size: 0.92rem; color: var(--ink-faint);
  padding: 10px 4px 12px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  letter-spacing: 0.02em;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); font-weight: 600; }

/* ---- views ---- */
.views { flex: 1; }
.view { animation: fade 0.25s ease; padding-bottom: 40px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h2 {
  font-weight: 600; font-size: 1.2rem; margin: 0 0 0.3rem;
  letter-spacing: -0.005em;
}
.hint { color: var(--ink-soft); font-size: 0.92rem; margin: 0 0 1rem; }
.datestamp {
  font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 0.5rem;
}

/* ---- streak pill ---- */
.streak {
  display: inline-flex; align-items: baseline; gap: 0.4em;
  font-size: 0.82rem; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 4px 12px; margin-bottom: 18px;
}
.streak b { color: var(--gold); font-size: 1rem; }
.streak .next-mark { color: var(--ink-faint); }

/* ---- card face ---- */
.cardface {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 22px 20px;
  margin: 0 0 26px;
}
.cardface .glyph {
  font-size: 2.6rem; line-height: 1; letter-spacing: 0.02em; margin: 0 0 0.2rem;
}
.cardface .glyph.red { color: var(--red); }
.cardface .glyph.black { color: var(--ink); }
.cardface .cardtitle { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.15rem; }
.cardface .tagline {
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 1rem;
}
.cardface p { margin: 0 0 0.9rem; }
.cardface p:last-child { margin-bottom: 0; }
.cardface .lens { border-top: 1px solid var(--rule-soft); padding-top: 0.9rem; margin-top: 0.9rem; }
.cardface .lens .label {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-faint); display: block; margin-bottom: 0.2rem;
}
.cardface .lens.sweet .label { color: var(--gold); }
.cardface .ai-note { font-size: 0.74rem; color: var(--ink-faint); font-style: italic; }

/* ---- primitive chips (the headline single words) ---- */
.cardface .chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0.5rem 0 1rem;
}
.cardface .chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 13px;
  color: var(--ink);
}
.cardface .chip.planet {
  color: var(--gold);
  border-color: var(--gold);
  background: transparent;
}

/* ---- decoded line (the one-sentence read) ---- */
.cardface .decoded {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 0.5rem;
}
.cardface .decoded em {
  font-style: italic;
  color: var(--ink-soft);
}

/* ---- depth toggle + collapsed prose ---- */
.cardface .depth-toggle {
  display: block;
  width: 100%;
  appearance: none;
  background: none;
  border: none;
  border-top: 1px solid var(--rule-soft);
  padding: 0.85rem 0 0.1rem;
  margin-top: 0.4rem;
  font-family: var(--serif);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: left;
  cursor: pointer;
}
.cardface .depth-toggle:hover { color: var(--ink); }
.cardface .depth-toggle .chev {
  display: inline-block;
  transition: transform 0.2s ease;
  margin-right: 0.3em;
  color: var(--gold);
}
.cardface .depth-toggle.open .chev { transform: rotate(90deg); }
.cardface .depth { margin-top: 0.6rem; }
.cardface .depth .cardtitle { margin-top: 0; font-size: 1.2rem; font-weight: 600; margin-bottom: 0.1rem; }
.cardface .depth p { margin: 0.6rem 0 0.9rem; }

/* ---- milestone ---- */
.milestone {
  background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 20px; margin: 0 0 26px;
}
.milestone h3 { margin: 0 0 0.3rem; font-size: 1.1rem; color: #f3e9cf; }
.milestone .badge {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.5rem;
}
.milestone p { margin: 0.5rem 0 0; color: #ece6d8; font-size: 0.95rem; }

/* ---- journal ---- */
.journal-block { margin-top: 8px; }
.journal-head { display: flex; align-items: baseline; justify-content: space-between; }
.save-state { font-size: 0.75rem; color: var(--ink-faint); }
.save-state.saved { color: var(--gold); }
textarea {
  width: 100%; resize: vertical;
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.6;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 14px; margin-top: 4px;
}
textarea:focus { outline: none; border-color: var(--gold); }
.journal-meta { font-size: 0.78rem; color: var(--ink-faint); margin-top: 6px; }

/* ---- buttons ---- */
button.primary {
  appearance: none; width: 100%;
  padding: 13px 22px; margin-top: 4px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 8px;
  font-family: var(--serif); font-size: 1rem; letter-spacing: 0.02em;
  cursor: pointer;
}
button.primary:hover { background: transparent; color: var(--ink); }
button.ghost {
  appearance: none; padding: 10px 16px;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 8px;
  font-family: var(--serif); font-size: 0.9rem; cursor: pointer;
}
button.ghost:hover { border-color: var(--ink); color: var(--ink); }
button.danger-btn { color: var(--red); border-color: #e3c7be; }
button.danger-btn:hover { border-color: var(--red); }

/* ---- ask ---- */
#view-ask textarea { margin-bottom: 14px; }
.recent { margin-top: 26px; }
.recent h3 { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 0.6rem; }
.recent-item {
  border-top: 1px solid var(--rule-soft); padding: 10px 0;
  font-size: 0.9rem; color: var(--ink-soft);
}
.recent-item .q { color: var(--ink); }
.recent-item .c { color: var(--gold); font-weight: 600; margin-left: 0.4em; }

/* ---- compare ---- */
.compare-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.compare-form label, .field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.85rem; color: var(--ink-soft);
}
input[type="text"] {
  font-family: var(--mono); font-size: 0.95rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 8px; padding: 12px 14px;
}
input[type="text"]:focus { outline: none; border-color: var(--gold); }
.compare-result { margin-top: 22px; }
.compare-pair { display: flex; gap: 12px; margin-bottom: 18px; }
.compare-pair .mini {
  flex: 1; background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; padding: 16px; text-align: center;
}
.compare-pair .mini .glyph { font-size: 2rem; }
.compare-pair .mini .glyph.red { color: var(--red); }
.compare-pair .mini .t { font-size: 0.9rem; font-weight: 600; margin-top: 4px; }
.compare-pair .mini .s { font-size: 0.74rem; color: var(--ink-faint); }
.verdict {
  background: var(--code-bg); border-radius: 10px; padding: 18px;
  margin-bottom: 16px;
}
.verdict .score {
  font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.4rem;
}
.verdict h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.verdict p { margin: 0 0 0.7rem; font-size: 0.95rem; }
.verdict p:last-child { margin-bottom: 0; }

/* ---- people grid (expanded compare: BC + PRC for each person) ---- */
.people-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.people-grid .mini {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 12px 10px 14px;
  text-align: center;
}
.people-grid .mini-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}
.people-grid .glyph {
  font-size: 1.7rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}
.people-grid .glyph.red { color: var(--red); }
.people-grid .glyph.black { color: var(--ink); }
.people-grid .mini-chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0.45rem 0 0.35rem;
}
.people-grid .mini-chips .chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--ink);
}
.people-grid .mini-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-soft);
}
.people-grid .mini.empty .empty-note {
  color: var(--ink-faint);
  font-size: 1rem;
  padding: 1.2rem 0;
}

/* ---- compare timing line ---- */
.compare-timing {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-align: center;
  margin: 0 0 1.4rem;
}

/* ---- compare section header ---- */
.compare-section {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.7rem;
  font-weight: 600;
}

/* ---- connection findings table ---- */
.findings {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.4rem;
}
.finding {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--rule-soft);
}
.finding:first-child { border-top: 0; padding-top: 4px; }
.finding-pos {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--ink-soft);
  min-width: 70px;
  text-align: center;
}
.finding-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
}

/* ---- archive ---- */
.archive-item {
  border-bottom: 1px solid var(--rule-soft); padding: 14px 0;
}
.archive-item .d {
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); display: flex; justify-content: space-between;
}
.archive-item .d .card { color: var(--gold); }
.archive-item .body { margin-top: 6px; white-space: pre-wrap; font-size: 0.95rem; }
.archive-empty, .recent-empty { color: var(--ink-faint); font-style: italic; }

/* ---- footer ---- */
.appfoot {
  border-top: 1px solid var(--rule); padding: 12px 0 18px;
  font-size: 0.72rem; color: var(--ink-faint); text-align: center;
}

/* ---- error ---- */
.err { color: var(--red); font-size: 0.88rem; margin-top: 0.6rem; }

/* ---- settings field helpers ---- */
.field-help {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: 0.74rem;
  margin-top: 6px;
  line-height: 1.4;
  display: block;
}
.field-error {
  color: var(--red);
  font-weight: 500;
  font-size: 0.76rem;
  margin-top: 6px;
  display: block;
}

/* ---- iOS one-time install hint ---- */
.ios-install-hint {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 30; margin: 0 auto;
  max-width: var(--maxw);
  background: var(--ink); color: var(--paper);
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 0.88rem; line-height: 1.4;
  display: flex; align-items: center; gap: 12px;
  border-top-left-radius: 12px; border-top-right-radius: 12px;
  box-shadow: 0 -10px 30px rgba(31,27,22,0.18);
  animation: ios-rise 0.3s ease;
}
.ios-install-hint b { color: #f3e9cf; font-weight: 600; }
.ios-install-hint .ios-dismiss {
  appearance: none; background: transparent; color: inherit;
  border: 1px solid #4a443c; border-radius: 999px;
  width: 30px; height: 30px;
  cursor: pointer; font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ios-install-hint .ios-dismiss:hover { border-color: var(--paper); }
@keyframes ios-rise {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---- settings drawer ---- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(31,27,22,0.35);
  z-index: 20; animation: fade 0.2s ease;
}
.drawer {
  position: fixed; z-index: 21; top: 0; right: 0; bottom: 0;
  width: min(92vw, 420px); background: var(--paper);
  border-left: 1px solid var(--rule);
  padding: max(env(safe-area-inset-top,0px),20px) 22px 28px;
  overflow-y: auto; box-shadow: -10px 0 40px rgba(31,27,22,0.12);
  animation: slidein 0.25s ease;
}
@keyframes slidein { from { transform: translateX(100%); } to { transform: none; } }
.drawer h2 { margin-bottom: 1.2rem; }
.drawer .field, .drawer .toggle { margin-bottom: 1.4rem; }
.drawer small { color: var(--ink-faint); font-weight: 400; }
.toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer; }
.toggle input { margin-top: 4px; }
.stats {
  font-size: 0.85rem; color: var(--ink-soft);
  background: var(--code-bg); border-radius: 8px; padding: 14px; margin-bottom: 1.4rem;
}
.stats div { display: flex; justify-content: space-between; padding: 2px 0; }
.stats b { color: var(--ink); }
.danger { display: flex; gap: 10px; margin-bottom: 1.6rem; }
.danger button { flex: 1; }

/* ---- larger screens ---- */
@media (min-width: 640px) {
  body { font-size: 18px; }
  .app { padding: 0 28px; }
  .compare-form { flex-direction: row; }
  .compare-form label { flex: 1; }
}
@media (max-width: 380px) {
  body { font-size: 16px; }
  .cardface .glyph { font-size: 2.2rem; }
  .tab { font-size: 0.85rem; }
}
