/* Matric Memories: one phone-width column, warm paper ground, teal + marigold. */
:root {
  --ground: #F6F4EF;
  --card: #FFFFFF;
  --ink: #17181C;
  --ink-2: #33363D;
  --muted: #5B5F6A;
  --line: #E4E0D6;
  --line-2: #C9C4B7;
  --teal: #0E6B66;
  --teal-dark: #0A4F4B;
  --teal-soft: #D7ECEA;
  --marigold: #F2B33D;
  --marigold-soft: #FBE7BC;
  --amber-ink: #4A3300;
  --danger: #A12A2A;
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--ground); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.app { max-width: 460px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.screen { padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: 32px; display: flex; flex-direction: column; gap: 16px; }
.with-tabs { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.title { font-size: 26px; line-height: 1.1; }
.sub { color: var(--muted); font-size: 14px; }
.hero { background: var(--teal); color: #FFFFFF; border-radius: 24px; padding: 22px 20px; display: flex; flex-direction: column; gap: 8px; }
.hero .eyebrow { color: var(--marigold); }
.hero h1 { font-size: 30px; line-height: 1.08; }
.hero p { color: #E3F2F0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tip { background: var(--marigold-soft); color: var(--amber-ink); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.tip h2 { font-size: 18px; color: var(--amber-ink); }
.tip ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.input, .textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 14px; background: var(--card); padding: 0 14px; min-height: 50px; font-size: 16px; }
.textarea { padding: 12px 14px; min-height: 100px; resize: vertical; line-height: 1.45; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--teal); flex-shrink: 0; }

.btn { min-height: 54px; border: none; border-radius: 16px; background: var(--teal); color: #FFFFFF; font-weight: 600; font-size: 16px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; text-decoration: none; }
.btn:hover { background: var(--teal-dark); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }
.btn.dark { background: var(--ink); }
.btn.small { min-height: 44px; font-size: 14px; border-radius: 12px; width: auto; }
.btn.danger { background: var(--card); color: var(--danger); border: 1px solid #E3C3C3; }
.linkbtn { background: none; border: none; color: var(--teal); font-weight: 600; padding: 10px 0; min-height: 44px; text-align: left; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.msg { border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 600; }
.msg.ok { background: var(--teal-soft); color: var(--teal-dark); }
.msg.bad { background: #F6DADA; color: #7A1F1F; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; border-radius: 999px; padding: 0 15px; border: 1px solid var(--line-2); background: var(--card); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.seg .chip { border-radius: 12px; }

/* Tabs */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 10; }
.tabbar-inner { max-width: 460px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tab { font-size: 11px !important; }

/* Matric hub */
.hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hub-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 108px; }
.hub-card:hover { border-color: var(--teal); }
.hub-card .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); display: flex; align-items: center; justify-content: center; }
.hub-card.warm .ic { background: var(--marigold-soft); color: var(--amber-ink); }
.hub-card strong { font-size: 14px; line-height: 1.25; }
.hub-card span { font-size: 12px; color: var(--muted); }
.upnext { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; width: 100%; }
.upnext b { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.upnext small { display: block; color: var(--muted); font-size: 12px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.item-row { display: flex; gap: 10px; align-items: flex-start; }
.item-row > .grow { flex: 1; min-width: 0; }
.tick { width: 28px; height: 28px; flex-shrink: 0; accent-color: var(--teal); margin-top: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 9px; background: var(--teal-soft); color: var(--teal-dark); }
.pill.warn { background: var(--marigold-soft); color: var(--amber-ink); }
.pill.late { background: #F6DADA; color: #7A1F1F; }
.iconbtn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.photo-slot { position: relative; border-radius: 16px; background: var(--marigold-soft); min-height: 150px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--amber-ink); font-weight: 600; font-size: 14px; overflow: hidden; padding: 10px; }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-slot .cap { position: absolute; left: 8px; top: 8px; background: rgba(23,24,28,0.8); color: #FFFFFF; border-radius: 999px; padding: 3px 9px; font-size: 12px; z-index: 1; }
.sealed { background: var(--ink); color: #FFFFFF; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.sealed p { color: #C9CBD1; font-size: 14px; }
.helpline { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.helpline b { font-family: var(--font-display); font-size: 18px; white-space: nowrap; }
.helpline a { color: var(--ink); text-decoration: none; }
.tab { height: 66px; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 500; color: var(--muted); position: relative; }
.tab[aria-current="page"] { color: var(--teal); font-weight: 700; }
.tab svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--marigold); color: var(--ink); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* Year */
.stats { background: var(--marigold); border-radius: 20px; padding: 14px 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats small { display: block; font-size: 13px; font-weight: 600; color: var(--amber-ink); }
.stats b { font-family: var(--font-display); font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.timeline { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 14px; }
.rail { display: flex; flex-direction: column; align-items: center; }
.dot { width: 16px; height: 16px; border-radius: 50%; margin-top: 3px; border: 2px solid #9A9EA8; background: var(--card); flex-shrink: 0; }
.dot.has { background: var(--teal); border-color: var(--teal); }
.bar { width: 2px; flex: 1; background: #D3CEC2; }
.step:last-child .bar { background: transparent; }
.step-body { padding-bottom: 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.step-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.step-head strong { font-size: 15px; }
.step-head span { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.step-note { font-size: 13px; color: var(--muted); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; background: var(--teal-soft); border: none; padding: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: var(--teal); text-align: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.add-to { align-self: flex-start; min-height: 40px; border: 1px dashed var(--teal); color: var(--teal); background: transparent; border-radius: 12px; padding: 0 12px; font-size: 13px; font-weight: 600; }

/* Add */
.photo-pick { position: relative; min-height: 200px; border-radius: 20px; background: var(--marigold); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; overflow: hidden; color: var(--amber-ink); font-weight: 600; text-align: center; padding: 16px; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.play-badge { position: absolute; left: 12px; bottom: 12px; background: rgba(23,24,28,0.8); color: #FFFFFF; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.voice { gap: 10px; }
.voice-row { display: flex; align-items: center; gap: 12px; }
.mic { width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; border: none; background: var(--teal); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.mic.rec { background: #C0392B; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(192,57,43,0.18); } }
@media (prefers-reduced-motion: reduce) { .mic.rec { animation: none; } }
.voice audio { width: 100%; }
.thumb { position: relative; }
.thumb .tb { position: absolute; right: 3px; bottom: 3px; background: rgba(23,24,28,0.8); color: #FFFFFF; border-radius: 6px; padding: 1px 4px; font-size: 9px; font-weight: 700; }
.progress { height: 8px; border-radius: 4px; background: var(--teal-soft); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--teal); transition: width 0.2s; }

/* Friends */
.note { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; }
.note.pending { border: 1px dashed var(--teal); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.note p { color: var(--ink-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .tag { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.linkbox { font-size: 13px; background: var(--ground); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }

/* Book */
.cover-stage { background: #E9E5DB; border-radius: 22px; padding: 22px 0; display: flex; justify-content: center; }
.cover { width: 200px; max-width: 100%; aspect-ratio: 148 / 210; position: relative; border-radius: 4px 10px 10px 4px; overflow: hidden; box-shadow: -5px 0 0 rgba(0,0,0,0.25), 0 14px 28px rgba(23,24,28,0.22); }
.cover-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-inner { position: absolute; inset: 0; padding: 18px 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.cover-top { display: flex; align-items: center; gap: 8px; }
.cover-logo { width: 30px; height: 36px; object-fit: contain; flex-shrink: 0; }
.cover-school { font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.9; }
.cover-title { font-weight: 700; line-height: 1; overflow-wrap: anywhere; }
.cover-name { font-size: 13px; font-weight: 600; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); }
.swatch[aria-pressed="true"] { border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px #FFFFFF; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Sheet */
.sheet-back { position: fixed; inset: 0; background: rgba(23,24,28,0.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px max(16px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.sheet img { border-radius: 14px; width: 100%; max-height: 50vh; object-fit: contain; background: var(--ground); }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--teal-soft); border-top-color: var(--teal); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 60vh; text-align: center; }

/* Upload limits, always visible on the Add screen */
.limits { background: var(--teal-soft); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ink-2); }
.limits strong { font-size: 14px; color: var(--ink); margin-bottom: 2px; }
.meter { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.meter > div { height: 100%; background: var(--teal); }
.meter.warn > div { background: var(--marigold); }

/* Unlock screen */
.pw-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }
.hero-mark { width: 56px; height: 56px; display: block; margin-bottom: 2px; }

/* Offline bar and pop-up messages */
.offline-bar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #FFFFFF; font-size: 13px; font-weight: 600; text-align: center; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 60; max-width: min(92vw, 420px); background: var(--ink); color: #FFFFFF; border-radius: 14px; padding: 12px 16px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.thumb .tb.wait { background: var(--marigold); color: var(--amber-ink); }

/* Photos from friends */
.item.drop img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; display: block; }
.drop-info { display: flex; flex-direction: column; gap: 4px; }
.drop-info p { margin: 0; }

/* Badges */
.badges-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.medal-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 6px; }
.medal { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; color: var(--line-2); --medal-star: var(--card); }
.medal.on { color: var(--marigold); --medal-star: #FFFFFF; }
.medal.on .medal-ic svg path:first-child { color: var(--teal); }
.medal-name { font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.medal:not(.on) .medal-name { color: var(--muted); }
.medal-how { font-size: 11px; color: var(--muted); line-height: 1.25; }
@media (max-width: 360px) { .medal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tip a { color: var(--amber-ink); font-weight: 700; }
.getown { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.4; }
.getown img { border-radius: 11px; flex: none; }
.getown strong { font-size: 15px; }
.getown:hover { border-color: var(--teal); }
