/* Morning Brief — JDS Edition. Newspaper ground, one ink per reader. */
:root {
  --paper: #FAF8F3;
  --sheet: #FFFDF8;
  --ink: #1A1A1A;
  --muted: #4A463E;
  --rule: #E4DFD3;
  --accent: #1F3A8A;
  --highlight: #AFC6FF;
  --tint: #E6EDFF;
  --serif: "Newsreader", Georgia, "Noto Serif KR", serif;
  --sans: "Inter", "Noto Sans KR", system-ui, sans-serif;
  --pad: 20px;
  --top: max(24px, calc(env(safe-area-inset-top) + 16px));
  --bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  --tabbar: calc(64px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.5;
  word-break: keep-all; -webkit-font-smoothing: antialiased;
}
::selection { background: var(--highlight); }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Page frame */
.page {
  min-height: 100dvh; width: 100%; max-width: 1200px; margin: 0 auto;
  padding: var(--top) var(--pad) var(--bottom);
  display: flex; flex-direction: column;
}
.page.has-tabs { padding-bottom: calc(var(--tabbar) + 24px); }

/* Masthead */
.mast { display: flex; flex-direction: column; gap: 8px; }
.mast .bar { width: 32px; height: 4px; background: var(--accent); }
.mast .row {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--ink); padding-bottom: 10px;
}
.mast .title { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
.mast .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; color: var(--muted); }

.h-display { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.2; }
.h-section { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.kr { font-family: var(--sans); color: var(--muted); font-size: 15px; margin-top: 8px; }
.note { font-size: 13px; color: var(--muted); }

/* Login */
.login { margin: auto 0; display: flex; flex-direction: column; gap: 20px; padding-top: 32px; }
.readers { border-top: 1px solid var(--ink); }
.reader {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: 96px; padding: 22px 4px; border: 0; border-bottom: 1px solid var(--rule);
  background: none; text-align: left; transition: background-color .15s ease;
}
.reader:hover { background: var(--sheet); }
.reader:active { transform: scale(0.99); }
.avatar {
  width: 60px; height: 60px; border-radius: 30px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--serif); font-size: 24px; font-weight: 700;
}
.reader .name { font-family: var(--serif); font-size: 24px; font-weight: 700; display: block; }
.reader .grade { font-size: 13px; color: var(--muted); }
.reader .grow { flex: 1; }
.login-foot { text-align: center; margin-top: 32px; }

/* PIN */
.pin { width: 100%; max-width: 400px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; padding-top: 8px; }
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-left: -4px;
  border: 0; background: none; font-size: 15px; align-self: flex-start;
}
.pin-head { display: flex; flex-direction: column; align-items: center; gap: 8px; border-bottom: 3px double var(--accent); padding-bottom: 16px; text-align: center; }
.pin-head p { font-size: 15px; color: var(--muted); }
.slots { display: flex; justify-content: center; gap: 14px; }
.slot { width: 56px; height: 64px; border-bottom: 2px solid var(--rule); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.slot.filled { border-bottom-color: var(--ink); }
.slot.next { border-bottom: 3px solid var(--accent); }
.pin-msg { min-height: 22px; text-align: center; font-size: 14px; color: #9A2A1A; }
.pin-msg.ok { color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.key {
  height: 58px; border-radius: 12px; border: 0; background: var(--sheet); font-size: 24px;
  font-variant-numeric: tabular-nums; transition: transform .1s ease, background-color .15s ease;
}
.key:hover { background: #F3EFE6; }
.key:active { transform: scale(0.97); }
.key.plain { background: transparent; display: flex; align-items: center; justify-content: center; }
.key:disabled { opacity: .4; cursor: default; }
.shake { animation: shake .3s cubic-bezier(0.23,1,0.32,1); }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none;
  transition: transform .1s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.btn.danger { background: transparent; color: #9A2A1A; border: 1px solid #9A2A1A; }

/* Today */
.today { display: flex; flex-direction: column; gap: 40px; padding-top: 40px; flex: 1; }
.snap {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 172px; border-radius: 20px; border: 0; width: 100%;
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.10);
  transition: transform .12s ease;
}
.snap:active { transform: scale(0.98); }
.snap .big { font-size: 20px; font-weight: 600; }
.snap .small { font-size: 13px; opacity: .85; }
.empty-box {
  border: 1.5px dashed var(--rule); border-radius: 16px; padding: 32px 20px; text-align: center; color: var(--muted); font-size: 14px;
}
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 40px); z-index: 30;
}

/* Settings */
.settings { display: flex; flex-direction: column; gap: 40px; padding-top: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 16px; }
.inks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.ink {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0;
  border: 0; background: none; font-size: 11px; color: var(--muted); border-radius: 12px; min-height: 44px;
}
.ink .dot { width: 36px; height: 36px; border-radius: 18px; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.ink[aria-pressed="true"] { background: var(--tint); color: var(--ink); font-weight: 600; }
.ink[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.placeholder { padding-top: 40px; display: flex; flex-direction: column; gap: 12px; }

/* Tabs: bottom bar on phones and tablets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: var(--tabbar); padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--sheet); border-top: 1px solid var(--ink);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; border: 0; background: none; border-radius: 12px;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.tab[aria-current="page"] { background: var(--tint); color: var(--ink); font-weight: 600; }

/* Tablet: 600–1023 */
@media (min-width: 600px) {
  :root { --pad: 40px; }
  .login, .today, .settings, .placeholder { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }
  .login { margin-top: 96px; margin-bottom: auto; }
  .tabs { padding-left: max(8px, calc(50% - 320px)); padding-right: max(8px, calc(50% - 320px)); }
}

/* Laptop: 1024+ — two columns, tabs move to a left rail */
@media (min-width: 1024px) {
  :root { --pad: 48px; }
  .mast .title { font-size: 40px; }
  .login {
    max-width: none; margin-top: 96px;
    display: grid; grid-template-columns: 5fr 7fr; grid-template-rows: auto 1fr; column-gap: 64px; row-gap: 16px; align-items: start;
  }
  .login .h-display { font-size: 44px; }
  .login-foot { grid-column: 1; text-align: left; margin-top: 16px; }
  .readers { grid-column: 2; grid-row: 1 / span 2; }
  .page.has-tabs { padding-bottom: var(--bottom); padding-left: calc(var(--pad) + 208px); }
  .tabs {
    top: 0; bottom: 0; right: auto; width: 208px; height: auto;
    padding: 120px 16px 24px; grid-template-columns: 1fr; align-content: start; gap: 4px;
    border-top: 0; border-right: 1px solid var(--rule); background: var(--paper);
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 15px; }
  .today { display: grid; grid-template-columns: 7fr 5fr; column-gap: 48px; align-items: start; max-width: none; }
  .today .lead { grid-column: 1; }
  .today .side { grid-column: 2; }
  .settings, .placeholder { max-width: 720px; margin-left: 0; }
  .toast { bottom: 24px; }
}


/* Lists */
.listpage { gap: 16px; }
.alist { display: flex; flex-direction: column; }
.arow {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 16px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; min-height: 64px;
}
.arow:hover .atitle { text-decoration: underline; text-underline-offset: 3px; }
.arow .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--ink); white-space: nowrap; }
.atitle { font-family: "Noto Serif KR", var(--serif); font-size: 16px; font-weight: 700; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search {
  font: inherit; font-size: 16px; min-height: 44px; padding: 0 14px; border-radius: 12px; width: 100%;
  border: 1px solid #CFC8B9; background: #F5F2EA; color: var(--ink);
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.fchip { font-size: 12px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--sheet); }
.fchip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg3 button { min-height: 44px; border: 0; background: none; font-size: 14px; font-weight: 500; }
.seg3 button + button { border-left: 1px solid var(--ink); }
.seg3 button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.cnt { font-variant-numeric: tabular-nums; opacity: .7; }
.wlist { display: flex; flex-direction: column; }
.wrow { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.wtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wword { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.wen { font-size: 14px; margin-top: 2px; }
.wkr { font-size: 14px; color: var(--muted); }

/* Learning card */
.cardview { width: 100%; max-width: 640px; margin: 0 auto; padding-top: 16px; display: flex; flex-direction: column; gap: 24px; }
.chead { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.ctitle { font-family: "Noto Serif KR", var(--serif); font-size: 22px; font-weight: 700; line-height: 1.45; }
.ctabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--ink); }
.ctabs button { min-height: 44px; border: 0; background: none; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.ctabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.glance { background: var(--sheet); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.glance dl { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.glance dl div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; font-size: 15px; }
.glance dt { color: var(--muted); font-weight: 500; }
.glance dd { margin: 0; }
.whybox { background: var(--tint); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.whyq { font-size: 15px; }
.whybox textarea {
  font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid #CFC8B9; background: #fff; resize: vertical; min-height: 64px;
}
.whybox textarea::placeholder { color: #9A948A; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--rule); background: #fff; min-height: 48px; }
.choice:hover { border-color: var(--ink); }
.verdict { font-weight: 600; }
.verdict.good { color: var(--accent); }
.fb { font-size: 14px; color: var(--muted); }
.model { background: #fff; border-radius: 10px; padding: 12px; font-size: 15px; }
.model .lbl { display: block; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.kwlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.kwlist li { display: flex; flex-direction: column; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.kw { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.ken { font-size: 14px; }
.kkr { font-size: 14px; color: var(--muted); }
.more { border: 0; background: none; color: var(--ink); font-weight: 600; min-height: 44px; text-align: left; padding: 0; text-decoration: underline; text-underline-offset: 4px; }
.orig p { font-family: "Noto Serif KR", var(--serif); font-size: 17px; line-height: 1.85; margin-bottom: 16px; }
.orig mark { background: var(--highlight); color: inherit; padding: 0 2px; border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pager .btn { min-height: 44px; }
.pager .btn:disabled { opacity: .35; }
.qlist { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.reveal { border: 0; background: none; padding: 0; min-height: 36px; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.qa { color: var(--muted); font-size: 15px; }
.talk { background: var(--tint); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 1024px) {
  .cardview { max-width: 720px; }
  .listpage { max-width: 760px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
