/* 레이아웃: 로고 줄 → 제목 → 저장 안 됨 안내 → 계산 카드 → 홍보 카드 → 바닥글. 한 줄 세로 흐름, 휴대폰 우선 */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1b2332;
  --muted: #5b6577;
  --line: #dde2ec;
  --brand: #2f55d4;
  --brand-soft: #e7edfd;
  --orange: #ff8a4c;
  --orange-soft: #fff1e8;
  --warn: #a5520a;
  --band: #c7d5f7;
  --font: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d; --panel: #1a202b; --ink: #e7ebf3; --muted: #9ba6b8; --line: #2c3442;
    --brand: #86a6ff; --brand-soft: #1f2a42; --orange: #ffa274; --orange-soft: #33241b;
    --warn: #f3b26a; --band: #2f4677; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.65; font-size: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(32px, env(safe-area-inset-bottom, 0px));
}
.wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2 { margin: 0; text-wrap: balance; line-height: 1.35; }
h1 { font-size: 1.55rem; }
.lead { margin: 6px 0 0; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 8px; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: .8rem; color: var(--muted); }

.privacy {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 10px;
  background: var(--orange-soft); border: 1px solid var(--orange);
}
.privacy strong { color: var(--ink); font-size: 1.02rem; }
.privacy span { color: var(--muted); font-size: .9rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .add, .cta {
  font: inherit; font-size: .92rem; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--panel); font-weight: 700; }
.add { border-style: dashed; color: var(--brand); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.note { margin: 0; color: var(--muted); font-size: .88rem; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
input[type=number], input[type=text], select {
  font: inherit; font-size: .92rem; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input[type=number] { width: 5em; font-family: var(--mono); }
#avgIn { width: 8em; }
select { max-width: 11em; }
input.own { margin-top: 4px; width: 9em; }

.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 6px; text-align: left; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; white-space: nowrap; }
td.n { font-family: var(--mono); }
tr.bad td { background: var(--orange-soft); }
.chip { display: inline-block; font-family: var(--mono); font-size: .78rem; padding: 1px 7px; border-radius: 5px; background: var(--brand-soft); color: var(--brand); margin: 1px 4px 1px 0; white-space: nowrap; }
.warn { color: var(--warn); }
.small { font-size: .76rem; line-height: 1.35; margin-top: 3px; max-width: 15em; }
.x { font: inherit; border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; }

.result { display: flex; flex-direction: column; gap: 6px; }
.big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.big .v { font-family: var(--mono); font-size: 2.5rem; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }
.range { position: relative; height: 30px; border-bottom: 1px solid var(--line); margin-top: 6px; }
.range .b { position: absolute; top: 8px; height: 14px; background: var(--band); border-radius: 4px; }
.range .m { position: absolute; top: 2px; width: 3px; height: 26px; background: var(--brand); border-radius: 2px; }
.ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .74rem; color: var(--muted); }

details { font-size: .9rem; color: var(--muted); }
details p { margin: 8px 0 0; }
summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.caution { margin: 0; font-size: .85rem; color: var(--warn); }

.promo { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.photo { border-radius: 50%; flex: none; }
.promo-body { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.promo h2 { font-size: 1.12rem; }
.promo p { margin: 0; color: var(--muted); font-size: .93rem; }
.cta { align-self: flex-start; background: var(--orange); border-color: var(--orange); color: #1b1208; font-weight: 700; text-decoration: none; }
.links { display: flex; gap: 14px; font-size: .9rem; }
.links a { color: var(--brand); }

.foot { font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.foot p { margin: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* 휴대폰: 과목 표를 줄마다 카드로. 1줄=학기·과목·지우기, 2줄=학점·등급·바꾼 등급 */
@media (max-width: 600px) {
  #subBox thead { display: none; }
  #subRows tr { display: grid; grid-template-columns: auto auto 1fr auto; gap: 6px 10px; align-items: end; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  #subRows td { border: none; padding: 0; }
  #subRows td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #subRows td:nth-child(2) { grid-column: 2 / 4; grid-row: 1; }
  #subRows td:nth-child(6) { grid-column: 4; grid-row: 1; }
  #subRows td:nth-child(3) { grid-column: 1; grid-row: 2; }
  #subRows td:nth-child(4) { grid-column: 2; grid-row: 2; }
  #subRows td:nth-child(5) { grid-column: 3 / 5; grid-row: 2; }
  #subRows td[data-label]::before { content: attr(data-label); display: block; font-size: .74rem; color: var(--muted); }
  #subRows select { max-width: 100%; }
  #subBox .tbl { overflow-x: visible; }
}
