/* 9 · Righteousness — "ledger" design: forest green, gold leaf, warm paper */
:root {
  --paper: #f4eedf;
  --card: #fbf8ef;
  --ink: #14231f;
  --ink-2: #4a5b54;
  --line: #dcd2b8;
  --green: #0f3b2f;
  --green-2: #1d5c4b;
  --gold: #c9972e;
  --gold-soft: #f3e4b4;
  --clay: #b4533a;
  --shadow: 0 1px 0 rgba(20,35,31,.04), 0 10px 28px -14px rgba(20,35,31,.28);
  --t-assignment: #c9972e;
  --t-activity: #2f8a6e;
  --t-note: #4a6fa5;
  --t-memo: #8a4f7d;
  --t-quiz: #b4533a;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1916;
    --card: #14251f;
    --ink: #f1ead8;
    --ink-2: #a8b8b0;
    --line: #2a3f37;
    --green: #0a2a22;
    --green-2: #4fbf9a;
    --gold: #e0b457;
    --gold-soft: #3a3016;
    --clay: #e0795f;
    --shadow: 0 10px 28px -14px rgba(0,0,0,.7);
    --t-assignment: #e0b457;
    --t-activity: #4fbf9a;
    --t-note: #7fa2d6;
    --t-memo: #c58bb8;
    --t-quiz: #e0795f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.5;
  background-image:
    radial-gradient(1200px 400px at 85% -10%, rgba(201,151,46,.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(29,92,75,.10), transparent 60%);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); margin: 0; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  background: var(--green); color: #f4eedf;
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 12px; background: none; border: 0; color: inherit; padding: 0; text-align: left; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--serif); font-weight: 800; font-size: 20px; line-height: 1; }
.brand-sub { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #e5c77c; margin-top: 4px; font-family: var(--sans); font-weight: 600; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.edit-pill { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; background: rgba(224,180,87,.18); color: #f0d48f; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px;
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1c1503; }
.btn.green { background: var(--green-2); border-color: var(--green-2); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.green { color: #06231a; } }
.btn.danger { color: var(--clay); border-color: color-mix(in srgb, var(--clay) 45%, var(--line)); }
.btn.ghost { background: transparent; border-color: transparent; }
.topbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #f4eedf; }
.topbar .btn.gold { background: var(--gold); border-color: var(--gold); color: #1c1503; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- layout ---------- */
.content { max-width: 880px; margin: 0 auto; padding: 22px 18px 120px; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 14px; margin-bottom: 16px; font-size: 14px; border: 1.5px solid var(--line); background: var(--card); }
.banner.warn { border-color: color-mix(in srgb, var(--clay) 55%, var(--line)); background: color-mix(in srgb, var(--clay) 9%, var(--card)); }
.banner strong { display: block; font-family: var(--serif); font-size: 15px; }
.banner span { color: var(--ink-2); }

.hero { padding: 8px 0 18px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.hero h2 { font-size: clamp(34px, 8vw, 54px); font-weight: 800; line-height: 1.02; margin-top: 6px; }
.hero h2 em { font-style: italic; font-weight: 500; color: var(--green-2); }
.hero p { color: var(--ink-2); max-width: 46ch; margin: 10px 0 0; }
.stats { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stat { flex: 1 1 100px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1.5px solid var(--line); }
.stat b { display: block; font-family: var(--serif); font-size: 26px; line-height: 1; }
.stat span { font-size: 12px; color: var(--ink-2); letter-spacing: .04em; }

/* ---------- filters ---------- */
.filters { margin: 6px 0 20px; display: grid; gap: 12px; }
.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink);
}
.search .input { padding-left: 42px; border-radius: 99px; }
.textarea { resize: vertical; min-height: 84px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: transparent; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.chip.on { background: var(--green); border-color: var(--green); color: #f4eedf; }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--green-2); border-color: var(--green-2); color: #06231a; } }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
details.range { border: 1.5px dashed var(--line); border-radius: 14px; padding: 10px 14px; }
details.range summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.range-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.toolbar .grp { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- timeline of days ---------- */
.timeline { position: relative; display: grid; gap: 14px; }
.timeline::before { content: ""; position: absolute; left: 41px; top: 8px; bottom: 8px; width: 2px; background: repeating-linear-gradient(to bottom, var(--line) 0 6px, transparent 6px 12px); }
.day {
  position: relative; display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: start;
  text-align: left; background: none; border: 0; padding: 0; width: 100%;
}
.day-date {
  position: relative; z-index: 1; width: 82px; padding: 10px 0 9px; text-align: center; border-radius: 16px;
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
}
.day-date .mon { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.day-date .num { font-family: var(--serif); font-size: 32px; font-weight: 800; line-height: 1.05; }
.day-date .dow { font-size: 12px; color: var(--ink-2); }
.day.today .day-date { background: var(--green); border-color: var(--green); }
.day.today .day-date .num, .day.today .day-date .dow { color: #f4eedf; }
.day-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 16px;
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s; cursor: pointer;
}
.day:hover .day-card { border-color: var(--gold); transform: translateY(-1px); }
.day-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.day-rel { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.day-count { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.day-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.day-lines li { display: flex; gap: 9px; align-items: baseline; font-size: 14.5px; min-width: 0; }
.day-lines .sub { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tc, var(--gold)); min-width: 58px; }
.day-lines .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.day-more { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.day-admin { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* ---------- entries ---------- */
.entries { display: grid; gap: 14px; }
.date-head { font-family: var(--serif); font-size: 20px; margin: 18px 0 2px; display: flex; align-items: center; gap: 10px; }
.date-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.entry {
  position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px;
  padding: 16px 16px 14px 20px; box-shadow: var(--shadow); overflow: hidden;
}
.entry::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--tc); }
.entry.sel { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.entry-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.entry-sub { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tc); }
.entry h3 { font-size: 20px; line-height: 1.2; margin-top: 3px; font-weight: 700; }
.tag { flex: none; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 99px; color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tc) 35%, transparent); }
.entry-desc { white-space: pre-wrap; margin: 10px 0 0; color: var(--ink); }
.marks { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.mark { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 8px; background: var(--gold-soft); color: var(--ink); border-bottom: 2px solid var(--gold); }
.entry-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--ink-2); align-items: center; }
.entry-meta a { color: var(--green-2); font-weight: 600; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1.5px solid var(--line); cursor: zoom-in; display: block; }
.entry-actions { display: flex; gap: 8px; margin-top: 14px; }
.check { position: absolute; right: 14px; top: 14px; width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; background: var(--paper); color: #1c1503; }
.entry.sel .check { background: var(--gold); border-color: var(--gold); }
.entry.pick { cursor: pointer; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { font-size: clamp(26px, 6vw, 38px); font-weight: 800; line-height: 1.08; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.day-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { text-align: center; padding: 46px 18px; border: 1.5px dashed var(--line); border-radius: 20px; color: var(--ink-2); }
.empty h3 { color: var(--ink); font-size: 22px; margin-bottom: 6px; }
.empty .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- floating action ---------- */
.fab-wrap { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 45; display: grid; gap: 10px; justify-items: end; }
.fab { width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--gold); color: #1c1503; display: grid; place-items: center; box-shadow: 0 12px 26px -10px rgba(0,0,0,.5); }
.fab .icon { width: 26px; height: 26px; transition: transform .2s; }
.fab.open .icon { transform: rotate(45deg); }
.fab-menu { display: grid; gap: 8px; justify-items: end; }
.fab-menu .btn { box-shadow: var(--shadow); }

/* ---------- sheets & modals ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8,20,16,.55); backdrop-filter: blur(3px); display: grid; align-items: end; justify-items: center; animation: fade .18s ease; }
.sheet {
  width: min(680px, 100%); max-height: 92vh; overflow: auto; background: var(--paper);
  border-radius: 24px 24px 0 0; border: 1.5px solid var(--line); border-bottom: 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: rise .22s ease;
}
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 24px; border-bottom: 1.5px solid var(--line); } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { font-size: 24px; }
.x { width: 36px; height: 36px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 20px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.sheet-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1.5px solid var(--line); }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--clay); color: #fff; font-size: 14px; line-height: 1; }
.inline { display: flex; gap: 8px; }
.note { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.err { color: var(--clay); font-size: 13px; min-height: 18px; margin-top: 6px; }

.bulk-grid { display: grid; gap: 14px; }
.preview { display: grid; gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.pv { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line); border-left: 5px solid var(--tc, var(--gold)); font-size: 14px; }
.pv b { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--tc, var(--gold)); }
.pv.unknown { border-style: dashed; }
.spin { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); margin-right: 6px; animation: pulse 1s infinite; }

.confirm { text-align: center; padding: 6px 4px; }
.confirm h3 { font-size: 22px; }
.confirm p { color: var(--ink-2); }
.confirm .sheet-foot { justify-content: center; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 90; padding: 11px 18px; border-radius: 14px; background: var(--green); color: #f4eedf; font-weight: 600; font-size: 14px; box-shadow: 0 14px 30px -12px rgba(0,0,0,.5); max-width: calc(100% - 32px); animation: rise .2s ease; border: 1.5px solid var(--gold); }
.toast.error { background: var(--clay); border-color: transparent; color: #fff; }

.install { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 70; width: min(420px, calc(100% - 28px)); background: var(--card); border: 1.5px solid var(--gold); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.install.show { display: flex; }
.install strong { display: block; font-family: var(--serif); }
.install span { color: var(--ink-2); font-size: 13px; }
.install-actions { display: flex; gap: 6px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pulse { 50% { opacity: .3; } }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .timeline::before { left: 37px; }
  .day { grid-template-columns: 76px 1fr; gap: 10px; }
  .day-date { width: 74px; }
}
@media print {
  .topbar, .fab-wrap, .toolbar, .filters, .entry-actions, .install { display: none !important; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
