/* Psych Tea: a pressed-flower study journal.
   Layout: sticky header (lecture tabs + section pills) over one centered study column.
   Palette: Ferra #7A4854 + Parchment #F4EDDA, the user's theme, kept as a single light look. */
:root {
  color-scheme: light;
  --ferra: #7A4854;
  --ferra-deep: #5A3240;
  --ferra-soft: #EAD8D4;
  --blush: #F3E2DD;
  --rose: #B9808B;
  --parchment: #F4EDDA;
  --paper: #FBF7EC;
  --ink: #3B2229;
  --muted: #86676D;
  --line: #E0D0BF;
  --honey: #9A6E2E;
  --honey-soft: #F1E3C4;
  --ok: #4F7451;
  --ok-soft: #E1EBD9;
  --bad: #A2463F;
  --bad-soft: #F5DDD8;
  --f-display: "Fredoka", "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  --f-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --f-hand: "Caveat", "Segoe Print", cursive;
  --r: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  background: var(--parchment);
  background-image: radial-gradient(circle at 1px 1px, rgba(122, 72, 84, 0.08) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.65;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; color: var(--ferra-deep); }
h1 { font-size: clamp(2rem, 5.5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0; max-width: 68ch; }
b, strong { font-weight: 800; color: var(--ferra-deep); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; border-radius: 8px; }

.wrap { max-width: 1000px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 90px; }
.label { font-family: var(--f-display); font-size: 0.78rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--rose); }
.hand { font-family: var(--f-hand); font-size: 1.35rem; color: var(--ferra); line-height: 1.2; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--ferra); color: var(--parchment); box-shadow: 0 6px 18px rgba(90, 50, 64, 0.18); }
.top-inner { max-width: 1000px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 10px 8px; display: grid; gap: 8px; }
.row1 { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 600; font-size: 1.15rem; white-space: nowrap; flex: none; }
.brand svg { width: 26px; height: 26px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; padding: 2px; }
.tabs::-webkit-scrollbar, .pills::-webkit-scrollbar { display: none; }
.tab { flex: none; display: grid; text-align: left; line-height: 1.15; padding: 6px 12px; border-radius: 12px; border: 1.5px solid rgba(244, 237, 218, 0.35); background: transparent; color: var(--parchment); font-family: var(--f-display); font-weight: 500; font-size: 0.86rem; }
.tab small { font-family: var(--f-body); font-weight: 600; font-size: 0.68rem; opacity: 0.8; }
.tab:hover { border-color: var(--parchment); }
.tab[aria-selected="true"] { background: var(--parchment); color: var(--ferra-deep); border-color: var(--parchment); }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pill { flex: none; padding: 4px 12px; border-radius: 999px; border: 0; background: rgba(244, 237, 218, 0.14); color: var(--parchment); font-family: var(--f-display); font-size: 0.8rem; }
.pill:hover { background: rgba(244, 237, 218, 0.28); }
@media (max-width: 560px) { .brand span { display: none; } }

/* ---------- hero ---------- */
.hero { position: relative; margin-top: 28px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 28px; padding: 30px 28px; display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 22px; align-items: center; overflow: hidden; }
.hero .eyebrow { font-family: var(--f-display); color: var(--rose); font-weight: 500; letter-spacing: 0.06em; }
.hero h1 { margin-top: 4px; }
.hero .lede { margin-top: 12px; font-size: 1.08rem; color: var(--muted); }
.hero .stats { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--ferra-soft); color: var(--ferra-deep); font-family: var(--f-display); font-size: 0.82rem; font-weight: 500; }
.hero .bloom { width: 150px; height: 150px; animation: sway 7s ease-in-out infinite; transform-origin: 50% 50%; }
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.progress { margin-top: 16px; display: grid; gap: 6px; max-width: 420px; }
.bar { height: 10px; border-radius: 999px; background: var(--ferra-soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ferra); border-radius: 999px; transition: width 0.4s ease; }
.progress span { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; padding: 22px 18px; } .hero .bloom { position: absolute; right: -24px; top: -24px; width: 110px; height: 110px; opacity: 0.35; } }

/* ---------- sections ---------- */
section { padding-top: 56px; display: grid; gap: 18px; scroll-margin-top: 112px; }
.sec-head { display: grid; gap: 6px; }
.sec-head p { color: var(--muted); }
.sec-head h2 { display: flex; align-items: center; gap: 10px; }
.sec-head h2 svg { width: 28px; height: 28px; flex: none; }

/* plan */
.plan { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.slot { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.slot .t { font-family: var(--f-display); font-weight: 600; color: var(--ferra); font-variant-numeric: tabular-nums; }
.slot .w { font-weight: 800; }
.slot .d { font-size: 0.9rem; color: var(--muted); }
@media (max-width: 760px) { .plan { grid-template-columns: 1fr 1fr; } }

/* tree */
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--ferra); background: transparent; color: var(--ferra); font-family: var(--f-display); font-weight: 500; font-size: 0.9rem; }
.btn:hover { background: var(--ferra-soft); }
.btn.solid { background: var(--ferra); color: var(--parchment); }
.btn.solid:hover { background: var(--ferra-deep); }
.tree { background: var(--paper); border: 1.5px solid var(--line); border-radius: 22px; padding: 16px 16px 16px 10px; }
.tree details { margin-left: 18px; padding-left: 14px; border-left: 2px dashed var(--line); }
.tree > details { margin-left: 4px; border-left: 3px solid var(--ferra); margin-bottom: 10px; }
.tree summary { list-style: none; cursor: pointer; padding: 5px 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "✿"; color: var(--rose); flex: none; transition: transform 0.2s; display: inline-block; }
.tree details[open] > summary::before { color: var(--ferra); transform: rotate(45deg); }
.tree .n { font-weight: 800; }
.tree > details > summary .n { font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; color: var(--ferra-deep); }
.tree .g { color: var(--muted); font-size: 0.93rem; }
.tree ul { margin: 2px 0 8px 18px; padding: 0 0 0 14px; list-style: none; border-left: 2px dashed var(--line); }
.tree li { padding: 2px 0; font-size: 0.95rem; }
.tree li::before { content: "• "; color: var(--rose); font-weight: 800; }
.mn { display: inline-block; font-family: var(--f-display); font-size: 0.75rem; font-weight: 500; background: var(--honey-soft); color: var(--honey); padding: 1px 9px; border-radius: 999px; }
.go { border: 0; background: var(--ferra-soft); color: var(--ferra-deep); font-family: var(--f-display); font-size: 0.72rem; padding: 1px 9px; border-radius: 999px; }
.go:hover { background: var(--ferra); color: var(--parchment); }

/* concept index + cards */
.index { display: flex; flex-wrap: wrap; gap: 6px; }
.index button { border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font-family: var(--f-display); font-size: 0.82rem; padding: 4px 12px; border-radius: 999px; }
.index button:hover { border-color: var(--ferra); color: var(--ferra); }
.index button.done { background: var(--ferra-soft); border-color: var(--ferra-soft); color: var(--ferra-deep); }
.index button.done::before { content: "✓ "; }
.group-title { margin-top: 18px; display: flex; align-items: center; gap: 10px; font-family: var(--f-hand); font-size: 1.8rem; color: var(--ferra); }
.group-title::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--rose) 0 6px, transparent 6px 12px); opacity: 0.6; }
.concept { background: var(--paper); border: 1.5px solid var(--line); border-radius: 24px; padding: 22px; display: grid; gap: 14px; scroll-margin-top: 118px; position: relative; }
.concept.done { border-color: var(--rose); }
.c-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.c-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-num { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--ferra); color: var(--parchment); display: grid; place-items: center; font-family: var(--f-display); font-weight: 600; }
.c-title h3 { font-size: 1.35rem; }
.learned { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-display); font-size: 0.85rem; color: var(--ferra); cursor: pointer; user-select: none; }
.learned input { width: 20px; height: 20px; accent-color: var(--ferra); cursor: pointer; }
.tea { background: var(--blush); border-radius: 18px; padding: 16px 18px; display: grid; gap: 6px; }
.tea .hand { font-size: 1.5rem; }
.c-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.c-box { border: 1.5px dashed var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.c-box.ex { grid-column: 1 / -1; border-style: solid; border-color: var(--ferra-soft); background: #FFFDF7; }
.c-box .label { color: var(--ferra); }
.scn { background: var(--ferra); color: var(--parchment); border-radius: 18px; padding: 16px 18px; display: grid; gap: 10px; }
.scn .label { color: var(--blush); }
.scn p { color: var(--parchment); }
.scn b, .scn strong { color: #FFF6E6; }
.scn .reveal { justify-self: start; border: 1.5px solid var(--parchment); background: transparent; color: var(--parchment); font-family: var(--f-display); padding: 6px 16px; border-radius: 999px; font-size: 0.9rem; }
.scn .reveal:hover { background: rgba(244, 237, 218, 0.15); }
.scn .ans { background: var(--parchment); color: var(--ink); border-radius: 14px; padding: 14px 16px; display: grid; gap: 6px; }
.scn .ans b, .scn .ans strong { color: var(--ferra-deep); }
.scn .ans p { color: var(--ink); }
ul.tight { margin: 0; padding-left: 1.2em; display: grid; gap: 3px; }
@media (max-width: 640px) { .c-grid { grid-template-columns: 1fr; } .concept { padding: 18px 16px; } }

/* flowcharts */
.flows { display: grid; gap: 16px; }
.flow { background: var(--paper); border: 1.5px solid var(--line); border-radius: 22px; padding: 18px; display: grid; gap: 12px; }
.flow .note { color: var(--muted); font-size: 0.93rem; }
.steps { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.step { flex: 1 0 130px; min-width: 130px; background: var(--ferra-soft); border-radius: 16px; padding: 12px; display: grid; gap: 4px; align-content: start; }
.step:nth-child(4n+1) { background: var(--ferra-soft); }
.step:nth-child(4n+3) { background: var(--blush); }
.step .k { font-family: var(--f-display); font-weight: 600; color: var(--ferra-deep); }
.step .d { font-size: 0.86rem; color: var(--ink); }
.arrow { flex: none; width: 26px; display: grid; place-items: center; color: var(--ferra); font-weight: 800; font-size: 1.2rem; }
.steps.vertical { flex-direction: column; }
.steps.vertical .step { flex: none; min-width: 0; }
.steps.vertical .arrow { width: auto; height: 22px; transform: rotate(90deg); }
.pyramid { display: grid; gap: 6px; justify-items: center; }
.pyramid div { background: var(--ferra); color: var(--parchment); border-radius: 12px; padding: 8px 12px; text-align: center; font-family: var(--f-display); font-size: 0.92rem; max-width: 100%; }
.pyramid div small { display: block; font-family: var(--f-body); font-size: 0.78rem; opacity: 0.85; }

/* tables */
.tables { display: grid; gap: 22px; }
.tables h3 { margin-bottom: 8px; }
.tbl { overflow-x: auto; background: var(--paper); border: 1.5px solid var(--line); border-radius: 18px; }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.94rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px dashed var(--line); }
th { background: var(--ferra); color: var(--parchment); font-family: var(--f-display); font-weight: 500; font-size: 0.85rem; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 800; color: var(--ferra-deep); }
tbody tr:nth-child(even) { background: rgba(234, 216, 212, 0.3); }

/* mnemonics */
.mwall { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mcard { background: var(--honey-soft); border-radius: 20px; padding: 16px; display: grid; gap: 6px; align-content: start; position: relative; }
.mcard .what { font-family: var(--f-display); font-size: 0.78rem; color: var(--honey); letter-spacing: 0.08em; text-transform: uppercase; }
.mcard .phrase { font-family: var(--f-hand); font-size: 1.7rem; color: var(--ferra-deep); line-height: 1.1; }
.mcard .map { font-size: 0.9rem; }

/* quiz */
.quiz { background: var(--paper); border: 1.5px solid var(--line); border-radius: 24px; padding: 20px; display: grid; gap: 14px; }
.quiz .meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-family: var(--f-display); color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz .sit { font-size: 1.12rem; font-weight: 700; min-height: 3.2em; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: #FFFDF7; color: var(--ink); font-family: var(--f-display); font-size: 0.92rem; }
.opt:hover { border-color: var(--ferra); }
.opt.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.fb { min-height: 1.6em; font-size: 0.96rem; }
.fb.good { color: var(--ok); }
.fb.bad { color: var(--bad); }

/* flashcards */
.fc { display: grid; gap: 12px; }
.fc-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.fc-filters .btn[aria-pressed="true"] { background: var(--ferra); color: var(--parchment); }
.card { perspective: 1200px; cursor: pointer; }
.card-inner { position: relative; min-height: 260px; transition: transform 0.5s ease; transform-style: preserve-3d; }
.card.flipped .card-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 26px; padding: 26px; display: grid; align-content: center; gap: 10px; overflow-y: auto; }
.face.front { background: var(--paper); border: 1.5px solid var(--line); }
.face.back { background: var(--ferra); color: var(--parchment); transform: rotateY(180deg); }
.face.back .label { color: var(--blush); }
.face .fq { font-family: var(--f-display); font-weight: 600; font-size: 1.4rem; line-height: 1.25; color: var(--ferra-deep); }
.face .fa { font-size: 1.02rem; white-space: pre-line; }
.face .corner { position: absolute; right: 18px; bottom: 14px; width: 34px; height: 34px; opacity: 0.5; }
.fc-ctrl { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.fc-ctrl .grp { display: flex; flex-wrap: wrap; gap: 8px; }
.fc-count { font-family: var(--f-display); color: var(--muted); font-variant-numeric: tabular-nums; }

footer { padding-top: 56px; text-align: center; color: var(--muted); font-size: 0.88rem; display: grid; gap: 6px; justify-items: center; }
#footFlower { display: block; width: 30px; height: 30px; opacity: 0.7; }
.bloom svg, .corner svg, #footFlower svg { display: block; width: 100%; height: 100%; }
