/* ============ Cedar Valley High — core styles ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100vh; max-width: 1100px; margin: 0 auto; box-shadow: var(--app-shadow); background: var(--bg); }

/* ---------- Top bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  z-index: 5; flex-wrap: wrap;
}
.tb-left { min-width: 150px; }
.tb-date { font-weight: 700; font-size: 14px; }
.tb-block { font-size: 12px; color: var(--ink-soft); }
.tb-stats { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.tb-stat { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; position: relative; }
.tb-stat .ico { font-size: 15px; }
.tb-stat .bar { width: 54px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.tb-stat .fill { height: 100%; width: 0%; border-radius: 3px; transition: width .4s ease; }
.fill.happy { background: var(--c-happy); }
.fill.pop { background: var(--c-pop); }
.tb-stat.small { font-size: 12.5px; color: var(--ink-soft); }
.tb-stat .delta { position: absolute; top: -14px; right: 0; font-size: 11px; font-weight: 800; animation: floatUp 1.6s ease forwards; pointer-events: none; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }
@keyframes floatUp { from { opacity: 1; transform: translateY(4px);} to { opacity: 0; transform: translateY(-10px);} }
.iconbtn { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 10px; font-size: 15px; }
.iconbtn:hover { background: var(--hover); }

/* ---------- Main screen ---------- */
#screen { flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth; }
#screen::-webkit-scrollbar { width: 8px; }
#screen::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---------- Tab bar ---------- */
#tabbar { display: flex; background: var(--panel); border-top: 1px solid var(--line); }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--ink-soft); padding: 8px 0 9px; font-size: 11px; font-weight: 600;
  border-top: 2px solid transparent; position: relative;
}
.tab .t-ico { font-size: 19px; }
.tab.active { color: var(--accent); border-top-color: var(--accent); background: var(--hover); }
.tab .badge {
  position: absolute; top: 4px; right: calc(50% - 22px); background: var(--bad); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 800;
}

/* ---------- Cards & layout ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 13px; margin: 10px 0 6px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--ink-soft); font-size: 12.5px; }
.small { font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--hover); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.accent { color: var(--accent); border-color: var(--accent); }
.hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 10px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 700; transition: transform .06s ease, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--hover); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { width: 100%; padding: 13px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn .sub { font-size: 11px; font-weight: 500; opacity: .85; }

/* ---------- Action choice list (day flow) ---------- */
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  color: var(--ink); transition: border-color .12s, background .12s, transform .05s;
}
.choice:hover { border-color: var(--accent); background: var(--hover); }
.choice:active { transform: scale(.99); }
.choice.locked { opacity: .55; }
.choice.locked:hover { border-color: var(--bad); }
.choice .c-ico { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
.choice .c-body { flex: 1; }
.choice .c-title { font-weight: 700; font-size: 13.5px; }
.choice .c-desc { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.choice .c-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.choice.highlight { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- Block header in day view ---------- */
.block-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.block-head .bh-ico { font-size: 28px; }
.block-head .bh-name { font-size: 18px; font-weight: 800; }
.block-head .bh-sub { font-size: 12px; color: var(--ink-soft); }
.timeline { display: flex; gap: 4px; margin-bottom: 14px; }
.timeline .seg { flex: 1; height: 7px; border-radius: 4px; background: var(--line); position: relative; }
.timeline .seg.done { background: var(--accent); opacity: .45; }
.timeline .seg.now { background: var(--accent); }
.timeline .seg.curfew { background: var(--bad); opacity: .5; }
.tl-labels { display: flex; gap: 4px; margin: 3px 0 12px; }
.tl-labels span { flex: 1; font-size: 9.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); text-align: center; }

/* ---------- Outcome / story text ---------- */
.story { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.story p { font-size: 13.5px; line-height: 1.55; margin-bottom: 8px; }
.story p:last-child { margin-bottom: 0; }
.story .effects { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.effect-chip { font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 2px 9px; background: var(--hover); border: 1px solid var(--line); }
.effect-chip.up { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.effect-chip.down { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }

/* ---------- Modal ---------- */
#modal-root:not(:empty) { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto; padding: 20px; animation: pop .18s ease; }
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { font-size: 17px; margin-bottom: 4px; }
.modal .m-sub { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 12px; }
.modal .m-body { font-size: 13.5px; line-height: 1.55; }
.modal .m-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 99px; font-size: 12.5px; font-weight: 600; animation: toastIn .25s ease, toastOut .4s ease 2.6s forwards; max-width: 90vw; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Phone ---------- */
.phone-frame { max-width: 420px; margin: 0 auto; background: var(--phone-bg); border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: var(--app-shadow); }
.phone-top { display: flex; justify-content: space-between; padding: 8px 18px 4px; font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.phone-apps { display: flex; border-bottom: 1px solid var(--line); }
.phone-apps button { flex: 1; background: none; border: none; color: var(--ink-soft); padding: 9px 0; font-size: 12px; font-weight: 700; border-bottom: 2px solid transparent; position: relative; }
.phone-apps button.active { color: var(--accent); border-bottom-color: var(--accent); }
.phone-apps .badge { position: absolute; top: 2px; right: 8px; background: var(--bad); color: #fff; font-size: 9.5px; min-width: 15px; height: 15px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 800; }
.phone-body { min-height: 420px; max-height: 56vh; overflow-y: auto; padding: 10px; }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
.post .p-head { display: flex; align-items: center; gap: 9px; padding: 9px 12px; }
.post .p-img { background: var(--hover); min-height: 110px; display: flex; align-items: center; justify-content: center; font-size: 44px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.post .p-cap { padding: 9px 12px 4px; font-size: 12.5px; line-height: 1.45; }
.post .p-foot { display: flex; gap: 14px; padding: 6px 12px 10px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: #fff; flex-shrink: 0; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.dm-row { display: flex; gap: 10px; padding: 10px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.dm-row:hover { background: var(--hover); }
.dm-row .d-name { font-weight: 700; font-size: 13px; }
.dm-row .d-prev { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.dm-row .d-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 16px; font-size: 13px; line-height: 1.4; }
.bubble.them { background: var(--hover); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .b-meta { font-size: 10px; opacity: .7; margin-top: 2px; }

/* ---------- Wardrobe / shop ---------- */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; position: relative; transition: border-color .12s; }
.item-card:hover { border-color: var(--accent); }
.item-card .i-ico { font-size: 34px; margin: 4px 0; }
.item-card .i-name { font-size: 12.5px; font-weight: 700; line-height: 1.25; min-height: 30px; }
.item-card .i-sub { font-size: 11px; color: var(--ink-soft); margin: 2px 0 6px; }
.item-card .i-tier { position: absolute; top: 7px; left: 8px; font-size: 10px; font-weight: 800; }
.item-card .i-tag { position: absolute; top: 7px; right: 8px; font-size: 9.5px; font-weight: 800; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 1px 5px; }
.item-card.equipped { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.stars { color: var(--warn); letter-spacing: 1px; font-size: 11px; }

/* ---------- People ---------- */
.npc-row { display: flex; align-items: center; gap: 11px; padding: 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.npc-row:hover { background: var(--hover); }
.npc-row .n-name { font-weight: 700; font-size: 13.5px; }
.npc-row .n-sub { font-size: 11.5px; color: var(--ink-soft); }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 100%; margin-top: 4px; }
.meter .m-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }
.meter .m-fill.heart { background: var(--c-heart); }

/* ---------- Grades table ---------- */
table.grades { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grades th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.grades td { padding: 8px; border-bottom: 1px solid var(--line); }
.grade-letter { font-weight: 800; font-size: 15px; }
.gl-A { color: var(--good); } .gl-B { color: #7cb342; } .gl-C { color: var(--warn); } .gl-D { color: #ef6c00; } .gl-F { color: var(--bad); }

/* ---------- Summary / end of day ---------- */
.summary-stat { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.summary-stat:last-child { border-bottom: none; }
.sumval.up { color: var(--good); font-weight: 800; }
.sumval.down { color: var(--bad); font-weight: 800; }

/* ---------- Score / graph ---------- */
.scorebox { text-align: center; padding: 18px; }
.scorebox .big-rank { font-size: 64px; font-weight: 900; line-height: 1; }
.scorebox .score-num { font-size: 22px; font-weight: 800; color: var(--accent); margin-top: 6px; }
.graph { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding: 8px 0; }
.graph .gcol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; }
.graph .gbar { border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---------- Setup screen ---------- */
.setup-hero { text-align: center; padding: 28px 14px 10px; }
.setup-hero h1 { font-size: 28px; font-weight: 900; letter-spacing: -.02em; }
.setup-hero .tagline { color: var(--ink-soft); margin-top: 6px; font-size: 13.5px; }
.input { width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; }
.input:focus { outline: none; border-color: var(--accent); }
label.field { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin: 12px 0 4px; }

/* ---------- Debug ---------- */
#debug-panel { position: fixed; right: 10px; top: 60px; width: 300px; background: var(--panel); border: 2px solid var(--warn); border-radius: 12px; padding: 12px; z-index: 70; max-height: 80vh; overflow-y: auto; font-size: 12px; }
#debug-panel h3 { margin-bottom: 8px; }
#debug-panel .row { margin-bottom: 6px; }
#debug-panel input { width: 70px; }

.hidden { display: none !important; }
.tac { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; }
