:root {
  --paper: #f5f0e7;
  --paper-deep: #ebe2d5;
  --surface: #fffdf8;
  --ink: #2e2b27;
  --muted: #7f786e;
  --line: #ded5c8;
  --terracotta: #a55c45;
  --moss: #66735c;
  --gold: #9b793e;
  --blue: #647887;
  --shadow: 0 18px 50px rgba(67, 55, 40, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.7), transparent 30rem),
    var(--paper);
}

button, input { font: inherit; }
a { color: inherit; }

.shell {
  width: min(100% - 32px, 820px);
  margin: 0 auto;
  padding-bottom: 72px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  border-bottom: 1px solid color-mix(in srgb, var(--line), transparent 35%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 5px solid var(--terracotta);
  border-radius: 50% 50% 48% 52%;
  box-shadow: inset 0 0 0 2px var(--paper);
}

.brand-mark.large { width: 34px; height: 34px; border-width: 8px; }

.primary-nav { display: flex; align-items: center; gap: 22px; }
.primary-nav a,
.primary-nav button {
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  background: none;
  font-size: .88rem;
  text-decoration: none;
  cursor: pointer;
}
.primary-nav a:hover,
.primary-nav button:hover,
.primary-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--terracotta); }
.primary-nav form { margin: 0; }

.page { padding-top: 52px; }
.day-heading,
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.day-heading { margin-bottom: 36px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--terracotta);
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1, h2 {
  font-family: Georgia, "Times New Roman", "AppleMyungjo", serif;
  font-weight: 600;
  letter-spacing: -.035em;
}
h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 6vw, 2.65rem); line-height: 1.18; }
h2 { margin-bottom: 0; font-size: 1.55rem; }
.day-summary { margin: 0; color: var(--muted); font-size: .86rem; }

.date-nav { display: flex; gap: 8px; padding-top: 5px; }
.date-nav a, .date-nav span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.38);
  text-decoration: none;
}
.date-nav a:hover { border-color: var(--terracotta); color: var(--terracotta); }
.date-nav span { opacity: .35; }

.journal-card {
  padding: clamp(25px, 5vw, 40px);
  border: 1px solid rgba(222, 213, 200, .8);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section-heading { margin-bottom: 26px; }
.section-heading > time { padding-top: 5px; color: var(--muted); font-size: .72rem; }
.journal-content {
  color: #3d3933;
  font-family: Georgia, "Times New Roman", "AppleMyungjo", serif;
  font-size: 1.08rem;
  line-height: 2;
  white-space: pre-wrap;
}

.moments-section { padding-top: 52px; }
.timeline { margin: 0; padding: 0; list-style: none; }
.moment {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 20px;
  padding: 0 0 32px;
}
.moment:not(:last-child)::after {
  position: absolute;
  top: 28px;
  bottom: 5px;
  left: 65px;
  width: 1px;
  background: var(--line);
  content: "";
}
.moment > time { padding-top: 3px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.moment-time { padding-top: 3px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.moment-time small { display: block; margin-top: 5px; font-size: .64rem; }
.moment-loose { border-top: 1px dashed var(--line); padding-top: 22px; }
.moment-loose + .moment-loose { border-top: 0; padding-top: 0; }
.moment-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; color: var(--muted); font-size: .72rem; }
.moment-original { margin-top: 14px; color: var(--muted); font-size: .8rem; }
.moment-original summary { cursor: pointer; width: fit-content; }
.moment-original > p { padding: 12px; border-radius: 8px; background: rgba(0,0,0,.025); }
.moment-original > a { display: inline-block; margin-top: 10px; }
.moment-body { position: relative; padding-left: 22px; }
.moment-body::before {
  position: absolute;
  top: 7px;
  left: 4px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--terracotta);
  box-shadow: 0 0 0 1px var(--terracotta);
  content: "";
}
.moment-body p { margin: 10px 0 0; line-height: 1.75; white-space: pre-wrap; }
.kind {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--terracotta);
  background: #f5e7df;
  font-size: .68rem;
  font-weight: 700;
}
.kind-meal { color: #8b6930; background: #f3ead2; }
.kind-thought, .kind-work { color: #526877; background: #e2e9ed; }
.kind-activity { color: #54664c; background: #e3eadf; }
.kind-purchase { color: #765a75; background: #ece2eb; }

.empty-state {
  display: grid;
  justify-items: center;
  padding: 48px 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}
.empty-state.compact { padding: 26px 18px; }
.empty-state p { margin-bottom: 6px; color: var(--ink); }
.empty-state span { max-width: 420px; font-size: .8rem; line-height: 1.6; }
.empty-dot { width: 8px; height: 8px; margin-bottom: 14px; border-radius: 50%; background: var(--terracotta); }

.page-title { margin-bottom: 34px; }
.page-title > p:last-child { max-width: 560px; color: var(--muted); line-height: 1.7; }
.raw-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.raw-entry { padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.68); }
.raw-entry > p { margin: 13px 0 0; line-height: 1.7; white-space: pre-wrap; }
.raw-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .72rem; }
.status { padding: 4px 8px; border-radius: 999px; font-weight: 700; }
.status.processed { color: var(--moss); background: #e3eadf; }
.status.pending { color: var(--gold); background: #f3ead2; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 410px);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 36px; }
.login-brand .brand-mark { margin-bottom: 28px; }
.login-brand h1 { margin-bottom: 7px; font-size: 2.5rem; }
.login-brand > p:last-child { color: var(--muted); }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: .78rem; font-weight: 700; }
.login-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.login-form input:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(165, 92, 69, .12); }
.login-form button, .button-link {
  display: inline-grid;
  min-height: 48px;
  margin-top: 8px;
  padding: 0 20px;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--terracotta);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.login-form button:hover, .button-link:hover { background: #8f4e3a; }
.form-error { margin: 2px 0 0; color: #a13e32; font-size: .8rem; }

.error-page { padding-top: 100px; text-align: center; }
.error-page > p { color: var(--muted); }
.error-code { margin-bottom: 8px; color: var(--terracotta) !important; font-size: .74rem; font-weight: 800; letter-spacing: .12em; }
.button-link { min-width: 160px; margin-top: 18px; }

.htmx-swapping { opacity: .25; transition: opacity 120ms ease; }

@media (max-width: 600px) {
  .shell { width: min(100% - 24px, 820px); }
  .app-header { min-height: 68px; }
  .primary-nav { gap: 14px; }
  .primary-nav a, .primary-nav button { font-size: .8rem; }
  .page { padding-top: 36px; }
  .day-heading { margin-bottom: 28px; }
  .journal-card { border-radius: 18px; }
  .section-heading { display: block; }
  .section-heading > time { display: block; margin-top: 8px; }
  .moment { grid-template-columns: 44px 1fr; gap: 12px; }
  .moment:not(:last-child)::after { left: 51px; }
  .moment-body { padding-left: 18px; }
  .login-card { padding: 32px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
