:root {
  --bg: #faf5ef; --surface: #ffffff; --ink: #2b2420; --muted: #7a6d64; --line: #e8ddd1;
  --accent: #b4472f; --accent-ink: #ffffff; --accent-soft: #f6e3dc; --ok: #3f7d4e; --warn: #b7791f;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1815; --surface: #272220; --ink: #f1e9e1; --muted: #a89a8e; --line: #3a322d;
    --accent: #e0765c; --accent-ink: #1c1815; --accent-soft: #3d2a24; --ok: #7bc08a; --warn: #e0b45c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; margin: 0; }
a { color: var(--accent); }
.hidden { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: #b3261e; }
.btn.small { padding: 4px 12px; min-height: 32px; font-size: 14px; }
.btn[disabled] { opacity: .6; cursor: progress; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; width: 100%; min-height: 40px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Header */
header.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
header.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Georgia, serif; font-size: 24px; font-weight: 700; color: var(--accent); }
.brand img { width: 30px; height: 30px; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 5px 12px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* Add bar */
.addbar { display: flex; gap: 8px; margin: 18px 0 6px; }
.addbar input { flex: 1; }
.addmsg { min-height: 22px; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.addmsg.err { color: #b3261e; }
.pastebox { margin: 6px 0 12px; }
.pastebox textarea { min-height: 140px; }

/* Tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 12px; scrollbar-width: thin; }
.tab { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tab .n { opacity: .7; margin-left: 4px; font-size: 13px; }

/* Filters */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 18px; box-shadow: var(--shadow); }
.filters .row1 { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .row1 input[type=text] { flex: 1 1 200px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; margin-top: 14px; }
.fgrid.hidden { display: none; }
.fgrid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.fgroup { grid-column: 1 / -1; font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-top: 6px; }
.checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
.checks input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.count { color: var(--muted); font-size: 14px; margin: 0 0 10px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; padding-bottom: 60px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; border: 1px solid var(--line); text-align: left; padding: 0; }
.card:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 4 / 3; background: linear-gradient(135deg, var(--accent-soft), var(--line)); display: grid; place-items: center; font-size: 48px; position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; top: 10px; left: 10px; background: rgba(255, 255, 255, .92); color: #2b2420; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.heart { position: absolute; top: 8px; right: 10px; font-size: 22px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.cbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cbody h3 { font-size: 19px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.cfoot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 1px 8px; border-radius: 999px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; grid-column: 1 / -1; }
.pending { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Overlay (detail + modals) */
.overlay { position: fixed; inset: 0; background: rgba(20, 12, 8, .55); z-index: 40; overflow-y: auto; padding: 20px 12px; }
.sheet { background: var(--bg); max-width: 880px; margin: 0 auto; border-radius: 18px; overflow: hidden; position: relative; }
.sheet.narrow { max-width: 460px; padding: 22px; margin-top: 12vh; }
.sheet .close { position: absolute; top: 10px; right: 10px; z-index: 2; background: var(--surface); border-radius: 50%; width: 40px; height: 40px; border: 1px solid var(--line); cursor: pointer; font-size: 18px; }
.hero { aspect-ratio: 16 / 7; background: linear-gradient(135deg, var(--accent-soft), var(--line)); display: grid; place-items: center; font-size: 72px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.dbody { padding: 20px 22px 26px; display: flex; flex-direction: column; gap: 18px; }
.dbody h1 { font-size: 30px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; min-width: 96px; }
.fact b { display: block; font-size: 18px; }
.fact span { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 26px; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } .hero { aspect-ratio: 16 / 9; } }
.ings { list-style: none; padding: 0; margin: 8px 0 0; }
.ings li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.ings .amt { min-width: 64px; font-weight: 600; white-space: nowrap; }
.steps { padding-left: 22px; margin: 8px 0 0; }
.steps li { margin-bottom: 12px; padding-left: 4px; }
.scaler { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; }
.scaler button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.ntable { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 6px; }
.ntable td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.ntable td:last-child { text-align: right; font-weight: 600; }
.note { font-size: 13px; color: var(--muted); }
.stars button { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--line); padding: 0 1px; }
.stars button.on { color: #e0a82e; }
.react { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.coursepick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.coursepick .btn { padding: 14px; font-size: 17px; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; background: var(--surface); padding: 26px; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.login h1 { color: var(--accent); text-align: center; }
.login .seg { align-self: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }
