/* ============================================================
   Journal — design system
   Warm editorial palette drawn from the Claw design standard.
   Light theme by default; matching dark theme via [data-theme].
   ============================================================ */

:root {
  /* surfaces */
  --paper:      #F4EDE2;
  --surface:    #EDE4D5;
  --surface-2:  #E3D7C2;
  /* ink + lines */
  --ink:        #1F1C17;
  --ink-soft:   #3A3429;
  --muted:      #6F6759;
  --line:       rgba(31, 28, 23, 0.12);
  --line-soft:  rgba(31, 28, 23, 0.07);
  /* accents */
  --green:      #3D5042;
  --green-deep: #2A3A30;
  --sage:       #5D7062;
  --bronze:     #8A7355;
  --sand:       #C9B896;
  --on-green:   #F4EDE2;
  /* type */
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans:  'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  /* shape */
  --radius:   14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(31, 28, 23, 0.05), 0 8px 30px rgba(31, 28, 23, 0.06);
  --wrap: 780px;
}

[data-theme="dark"] {
  --paper:      #1A1712;
  --surface:    #221E18;
  --surface-2:  #2A2620;
  --ink:        #F4EDE2;
  --ink-soft:   #E3D7C2;
  --muted:      #B3A892;
  --line:       rgba(244, 237, 226, 0.14);
  --line-soft:  rgba(244, 237, 226, 0.07);
  --green:      #5D7062;
  --green-deep: #22302A;
  --sage:       #7F9484;
  --bronze:     #B9986F;
  --sand:       #C9B896;
  --on-green:   #F4EDE2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 34px rgba(0, 0, 0, 0.35);
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---- shared type ---- */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.display {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.01em;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  margin: 0.2em 0 0;
}
.accent { color: var(--green); font-style: italic; font-weight: 500; }

/* ============================================================ layout */
.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.4rem);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.6rem; margin-right: auto; }
.brand-mark { color: var(--green); font-size: 1.1rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; letter-spacing: 0.01em; }
.brand-text em { font-family: var(--mono); font-style: normal; font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

.site-nav { display: flex; gap: 1.6rem; }
.site-nav a {
  font-size: 0.9rem; color: var(--muted); position: relative; padding-bottom: 2px;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--ink); }

.site-actions { display: flex; gap: 0.4rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  font-size: 1rem; transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--muted); }

.site-main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(1.6rem, 5vw, 3.4rem) clamp(1rem, 4vw, 2rem) 4rem;
}
.site-main--centered {
  min-height: calc(100vh - 4rem);
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================ masthead */
.masthead { margin-bottom: 2.4rem; }
.masthead--tight { margin-bottom: 1.4rem; }

/* ============================================================ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 3vw, 1.8rem);
}

/* ============================================================ compose */
.compose { margin-bottom: 3rem; }
.compose--inline { margin-top: 2.6rem; margin-bottom: 0; }
.compose--inline h2 { margin: 0 0 0.8rem; }
.compose-form { display: flex; flex-direction: column; gap: 1rem; }
.compose-form textarea {
  width: 100%; resize: vertical; min-height: 8.5rem;
  border: none; background: transparent; color: var(--ink);
  font-family: var(--serif); font-size: 1.35rem; line-height: 1.5;
  padding: 0.2rem 0;
}
.compose-form textarea::placeholder { color: var(--muted); opacity: 0.75; }
.compose-form textarea:focus { outline: none; }

.compose-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line-soft);
}
.compose-hint { margin: 0; font-size: 0.82rem; color: var(--muted); }
.compose-hint code, .prose code {
  font-family: var(--mono); font-size: 0.82em;
  background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 5px;
}

/* file input */
.file-field { position: relative; overflow: hidden; display: inline-flex; }
.file-field input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius-pill);
  padding: 0.5rem 1rem; transition: border-color 0.15s, color 0.15s;
}
.file-field:hover .file-label { border-color: var(--bronze); color: var(--ink); }

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  padding: 0.6rem 1.4rem; font-size: 0.9rem; font-weight: 600;
  transition: transform 0.05s, background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn-primary:hover { background: var(--green-deep); border-color: var(--green-deep); }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 0.8rem; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.link-btn:hover { color: var(--ink); }

/* ============================================================ entry list */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; border-bottom: 1px solid var(--line); padding-bottom: 0.9rem; }
.section-head h2 { font-family: var(--serif); font-weight: 600; font-size: 1.9rem; margin: 0; }

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-row { border-bottom: 1px solid var(--line-soft); }
.entry-link { display: grid; grid-template-columns: 88px 1fr; gap: 1.4rem; padding: 1.5rem 0.4rem; align-items: start; transition: background 0.15s; border-radius: var(--radius-sm); }
.entry-link:hover { background: var(--surface); }
.entry-date { text-align: center; padding-top: 0.2rem; }
.entry-day { display: block; font-family: var(--serif); font-size: 2.5rem; font-weight: 600; line-height: 0.9; font-feature-settings: "onum" 1, "lnum" 0; }
.entry-monthyear { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.entry-title { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0 0 0.3rem; }
.entry-excerpt { margin: 0 0 0.6rem; color: var(--ink-soft); font-size: 0.98rem; }
.entry-meta { margin: 0; }

/* ============================================================ day / prose */
.back-link { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.back-link:hover { color: var(--ink); }
.day-head { margin: 1.2rem 0 2.2rem; }

.prose { font-size: 1.08rem; color: var(--ink); }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--green);
  margin-top: 2.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line);
}
.prose h3 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; }
.prose p { margin: 0; }
.prose a { color: var(--green); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.prose a:hover { text-decoration-color: var(--green); }
.prose blockquote { margin: 1.2rem 0; padding-left: 1.2rem; border-left: 2px solid var(--bronze); color: var(--muted); font-family: var(--serif); font-size: 1.3rem; font-style: italic; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: 0.3rem 0; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose figure { margin: 1.6rem 0; }
.prose figure img, .prose p img { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ============================================================ search */
.search-form { display: flex; gap: 0.7rem; margin-bottom: 1.6rem; }
.search-input {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: var(--radius-pill);
  padding: 0.8rem 1.3rem; font-size: 1rem;
}
.search-input:focus { outline: none; border-color: var(--sage); }
.search-count { margin-bottom: 1.2rem; }

.results { display: flex; flex-direction: column; gap: 1.6rem; }
.result-day { display: grid; grid-template-columns: 78px 1fr; gap: 1.2rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--line-soft); }
.result-date { text-align: center; }
.result-hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.result-hits a { display: flex; gap: 0.7rem; align-items: baseline; color: var(--ink-soft); transition: color 0.15s; }
.result-hits a:hover { color: var(--ink); }
.hit-time { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }
.hit-snip mark { background: var(--sand); color: var(--ink); border-radius: 3px; padding: 0 2px; }
[data-theme="dark"] .hit-snip mark { background: var(--bronze); }

/* ============================================================ auth */
.auth-card { width: 100%; max-width: 400px; text-align: left; }
.auth-card .display { font-size: 3rem; }
.auth-sub { color: var(--muted); margin: 0.6rem 0 1.6rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.field input {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: var(--radius-sm); padding: 0.75rem 0.9rem; font-size: 1rem;
}
.field input:focus { outline: none; border-color: var(--sage); }
.checkbox { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; color: var(--muted); }
.form-error { background: color-mix(in srgb, #a23b2d 14%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, #a23b2d 40%, var(--line)); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; font-size: 0.9rem; margin: 0 0 1.2rem; }

/* ============================================================ misc */
.flash { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7rem 1rem; font-size: 0.9rem; margin-bottom: 1.6rem; }
.empty { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 1.2rem; padding: 1.4rem 0; }

.site-footer { border-top: 1px solid var(--line); background: var(--green-deep); color: var(--on-green); margin-top: 3rem; }
.footer-inner { max-width: var(--wrap); margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-note { margin: 0; font-family: var(--serif); font-style: italic; font-size: 1.05rem; opacity: 0.85; }
.site-footer .link-btn { color: color-mix(in srgb, var(--on-green) 75%, transparent); }
.site-footer .link-btn:hover { color: var(--on-green); }

/* ============================================================ compose controls */
.compose-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.date-field { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px dashed var(--line); border-radius: var(--radius-pill); padding: 0.35rem 0.9rem; }
.date-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.date-field input { border: none; background: transparent; color: var(--ink); font: inherit; font-size: 0.85rem; }
.date-field input::-webkit-calendar-picker-indicator { filter: grayscale(1) opacity(0.5); cursor: pointer; }

/* ============================================================ mood picker */
.mood-picker { position: relative; }
.mood-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: var(--radius-pill); padding: 0.45rem 0.9rem; font-size: 0.9rem;
  transition: border-color 0.15s;
}
.mood-trigger:hover { border-color: var(--bronze); }
.mood-trigger .chev { color: var(--muted); font-size: 0.7rem; }
.mood-trigger-inner { display: inline-flex; align-items: center; gap: 0.45rem; }
.mood-placeholder { color: var(--muted); }
.mood-optional { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }
.mo-emoji { font-size: 1.05rem; line-height: 1; }
.mo-name { font-size: 0.9rem; }

.mood-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 40;
  width: 250px; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.4rem;
}
.mood-menu[hidden] { display: none; }
.mood-band { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0.6rem 0.6rem 0.25rem; }
.mood-opt {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem; text-align: left; color: var(--ink); font-size: 0.92rem;
}
.mood-opt:hover, .mood-opt.is-focus { background: var(--surface-2); }
.mood-opt.is-active { background: color-mix(in srgb, var(--green) 16%, transparent); }
.mood-opt .mo-name { flex: 1; }
.mood-opt--none { color: var(--muted); }

/* energy dots */
.mo-energy { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.energy-low    { background: var(--sage); }
.energy-medium { background: var(--bronze); }
.energy-high   { background: var(--green); }

/* mood badge on entries */
.mood-badge { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 0.15rem 0.6rem 0.15rem 0.5rem; font-size: 0.85rem; }
.mood-badge .mo-energy { width: 7px; height: 7px; }

/* ============================================================ entries (day view) */
.entry { padding: 1.4rem 0; border-top: 1px solid var(--line); }
.entry:first-of-type { border-top: none; }
.entry-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.entry-bar-left { display: flex; align-items: center; gap: 0.7rem; }
.entry-time { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--green); }
.entry-tools { display: flex; align-items: center; gap: 0.5rem; opacity: 0; transition: opacity 0.15s; }
.entry:hover .entry-tools, .entry:focus-within .entry-tools { opacity: 1; }
.inline-form { display: inline-flex; margin: 0; }
.entry-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 0.95rem; line-height: 1;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-pill);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.entry-btn:hover { color: var(--ink); border-color: var(--muted); background: var(--surface); }
.entry-btn--danger:hover {
  color: #a23b2d;
  border-color: color-mix(in srgb, #a23b2d 45%, var(--line));
  background: color-mix(in srgb, #a23b2d 8%, transparent);
}
@media (hover: none) { .entry-tools { opacity: 1; } }

/* ============================================================ patterns */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.stat-big { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.4rem; }
.stat-sub { font-size: 0.8rem; color: var(--muted); }
.energy-bar { display: flex; height: 12px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-2); margin: 0.3rem 0; }
.energy-seg { height: 100%; }

.chart-card { padding: 1.2rem 1.3rem; }
.chart-head { display: flex; justify-content: space-between; margin-bottom: 0.8rem; }
.mood-chart { width: 100%; height: auto; display: block; }
.mood-chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.mood-chart .grid-label { fill: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 9px; }
.mood-chart .chart-area { fill: color-mix(in srgb, var(--green) 12%, transparent); stroke: none; }
.mood-chart .chart-line { stroke: var(--green); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mood-chart .chart-dot { stroke: var(--paper); stroke-width: 1.5; }
.mood-chart .chart-dot.energy-low    { fill: var(--sage); }
.mood-chart .chart-dot.energy-medium { fill: var(--bronze); }
.mood-chart .chart-dot.energy-high   { fill: var(--green); }
.chart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 0.7rem; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.chart-legend { display: flex; gap: 0.9rem; }
.lg { display: inline-flex; align-items: center; gap: 0.35rem; }
.lg::before { content: ''; width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lg.energy-low::before    { background: var(--sage); }
.lg.energy-medium::before { background: var(--bronze); }
.lg.energy-high::before   { background: var(--green); }

/* ============================================================ widget setup */
.url-row { display: flex; gap: 0.6rem; align-items: stretch; }
.url-code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-family: var(--mono); font-size: 0.8rem; color: var(--ink); }
.copy-btn { flex-shrink: 0; }
.setup-steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; color: var(--ink-soft); }
.setup-steps li { padding-left: 0.2rem; }
.footer-links { display: flex; align-items: center; gap: 1.2rem; }

/* ============================================================ responsive */
@media (max-width: 560px) {
  .site-nav { gap: 1rem; }
  .site-nav a { font-size: 0.85rem; }
  .brand-text em { display: none; }
  .entry-link { grid-template-columns: 62px 1fr; gap: 1rem; }
  .entry-day { font-size: 2rem; }
  .compose-form textarea { font-size: 1.2rem; }
  .compose-bar { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .compose-bar .btn-primary { width: 100%; }
  .mood-menu { width: min(280px, 78vw); }
  .stat-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
