:root {
  --bg: #F2F4F6; --card: #FFFFFF; --ink: #191F28; --ink2: #4E5968; --sub: #8B95A1; --line: #E5E8EB;
  --blue: #3182F6; --blue-soft: #E8F3FF; --gray-btn: #F2F4F6; --gray-btn2: #E5E8EB;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--ink); -webkit-font-smoothing: antialiased; letter-spacing: -0.01em;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 마크가 "Cram"의 C 자리에 들어간다. 마크 높이는 대문자 높이, 바닥은 글자 기준선에 맞춘다 */
.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.04em; white-space: nowrap; line-height: 1.2; }
.logo svg { display: inline-block; width: 1em; height: 1em; vertical-align: -0.11em; margin-right: -0.07em; }
.logo svg path { fill: var(--ink); }
.logo svg circle { fill: var(--blue); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 14px; padding: 15px 18px; font-size: 16px; font-weight: 700; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-soft { background: var(--gray-btn2); color: var(--ink); }
.btn-ghost { background: var(--gray-btn); color: var(--ink); }
.link-btn { color: var(--ink2); font-size: 15px; font-weight: 600; padding: 10px 4px; }
.input { width: 100%; border: 0; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); padding: 13px 14px; font: inherit; font-size: 15px; color: var(--ink); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--blue); }
textarea.input { resize: vertical; line-height: 1.6; }
.msg { color: #E5484D; font-size: 14px; line-height: 1.5; min-height: 0; }
.msg:empty { display: none; }
.hint { color: var(--sub); font-size: 13px; text-align: center; }
.chip { background: var(--blue-soft); color: var(--blue); font-weight: 600; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.chip.gray { background: var(--gray-btn); color: var(--ink2); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--sub); }

/* 잠김 */
.lock { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lock-card { width: 100%; max-width: 360px; background: #fff; border-radius: 24px; padding: 32px 24px; display: flex; flex-direction: column; gap: 14px; }
.lock-label { font-size: 17px; font-weight: 700; margin-top: 8px; }

/* 앱 */
.app { max-width: 1080px; margin: 0 auto; padding: 28px 24px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--gray-btn2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.seg button { font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 9px; color: var(--ink2); }
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.browse { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 150px); min-height: 520px; }
.list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 2px; }
.row { display: block; width: 100%; text-align: left; border-radius: 14px; padding: 14px 16px; }
.row:hover { background: rgba(255,255,255,.6); }
.row.on { background: #fff; }
.row .meta { margin-bottom: 6px; }
.row .ttl { font-size: 15px; font-weight: 700; line-height: 1.45; }
.list-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 0 2px 8px; }
.paste { display: flex; flex-direction: column; gap: 10px; }
.paste .or { font-size: 13px; color: var(--sub); text-align: center; }

.reader { background: #fff; border-radius: 18px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.reader-scroll { overflow-y: auto; padding: 28px 32px 24px; flex: 1; }
.reader .ttl { font-size: 21px; font-weight: 700; line-height: 1.4; letter-spacing: -0.03em; margin-top: 8px; }
.reader .body { font-size: 16px; line-height: 1.85; color: #333D4B; margin-top: 20px; }
.reader .body p + p { margin-top: 16px; }
.note { font-size: 13px; color: var(--sub); margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.reader-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.reader-foot .btn { flex: 1; }
.src-link { font-size: 14px; color: var(--sub); text-decoration: none; white-space: nowrap; }
.empty { margin: auto; text-align: center; padding: 40px 24px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.empty p { color: var(--ink2); font-size: 16px; line-height: 1.6; }
.back { display: none; font-size: 15px; color: var(--ink2); font-weight: 600; padding: 4px 0 12px; text-align: left; }

/* 결과 */
.result-card { background: #fff; border-radius: 20px; padding: 32px 36px 0; }
.result-card .back { display: inline-block; }
.result-card h1 { font-size: 24px; font-weight: 700; line-height: 1.4; letter-spacing: -0.03em; margin-top: 8px; }
.sec { font-size: 17px; font-weight: 700; margin: 32px 0 10px; }
.result table { width: 100%; border-collapse: collapse; font-size: 15px; }
.result td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.55; }
.result td.n { color: var(--sub); width: 36px; font-size: 13px; padding-top: 16px; }
.result td.src { width: 34%; font-weight: 600; }
.gl-sub { display: block; color: var(--sub); font-size: 13px; margin-top: 4px; }
.names { display: flex; flex-wrap: wrap; gap: 8px; }
.names span { background: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.sc { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.sc div { padding: 16px 12px; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.75; color: #333D4B; }
.sc div:nth-child(odd) { padding-left: 0; border-right: 1px solid var(--line); }
.sc b { color: var(--ink); }
.dl { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 20px 0 24px; background: linear-gradient(transparent, #fff 30%); margin-top: 8px; }
.dl .btn-primary { flex: 1; }

/* 자료 만드는 중: 시간 기준으로 차오르고, 맨 앞의 파란 점(로고의 점)이 길을 이끈다 */
.loading { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 4px 2px; }
.loading .label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.loading .label b { font-size: 15px; font-weight: 700; }
.loading .label small { font-size: 13px; color: var(--sub); }
.loading .bar { position: relative; height: 14px; margin: 0 7px; }
.loading .rail { position: absolute; left: 0; right: 0; top: 5px; height: 4px; border-radius: 2px; background: var(--line); }
.loading .fill { position: absolute; left: 0; top: 5px; height: 4px; width: 0; border-radius: 2px; background: var(--ink); }
.loading .head { position: absolute; top: 0; left: 0; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--blue); }
.loading .head::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; background: var(--blue); animation: breathe 1.6s ease-in-out infinite; }
.loading.done .fill, .loading.done .head { transition: width .4s ease-out, left .4s ease-out; }
@keyframes breathe { 0%, 100% { transform: scale(.7); opacity: .25; } 50% { transform: scale(1.15); opacity: .08; } }
@media (prefers-reduced-motion: reduce) { .loading .head::after { animation: none; opacity: .15; } }

/* 보관함 */
.arch-btn { display: inline-flex; align-items: center; gap: 6px; background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.arch-btn b { background: var(--blue-soft); color: var(--blue); border-radius: 6px; font-size: 12px; padding: 1px 7px; }
.arch-btn[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--blue); }
.arch { background: #fff; border-radius: 20px; padding: 32px 36px 24px; }
.arch .back { display: inline-block; }
.arch h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.arch-note { font-size: 14px; color: var(--sub); margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 6px; }
.filters button { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--gray-btn); color: var(--ink2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.arch-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 16px 4px; border-bottom: 1px solid var(--line); }
.arch-open { text-align: left; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.arch-open .ttl { font-size: 16px; font-weight: 700; line-height: 1.45; }
.arch-open .when { font-size: 12.5px; color: var(--sub); }
.arch-del { width: 36px; height: 36px; border-radius: 10px; color: var(--sub); display: grid; place-items: center; }
.arch-del:hover { background: #FDECEC; color: #E5484D; }
.arch-del svg { width: 18px; height: 18px; }
.arch-empty { text-align: center; color: var(--ink2); font-size: 15px; line-height: 1.7; padding: 48px 0; }
.arch-foot { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.arch-foot .hint { text-align: left; }
.clear-btn { font-size: 14px; font-weight: 600; color: var(--sub); padding: 8px 4px; }
.clear-btn:hover { color: #E5484D; }
.confirm { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.confirm .yes { background: #E5484D; color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.confirm .no { background: var(--gray-btn2); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.saved-note { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); background: var(--bg); border-radius: 8px; padding: 6px 10px; margin-top: 12px; }
.saved-note i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.row-wrap { position: relative; }
.row-wrap .row { padding-right: 40px; }
.row-x { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 8px; color: var(--sub); font-size: 17px; line-height: 28px; text-align: center; }
.row-x:hover { background: var(--gray-btn2); color: var(--ink); }
.chip.paste { background: #FFF4E5; color: #B25E00; }
.chip.new { background: var(--blue); color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 14px 11px 18px; display: flex; gap: 16px; align-items: center; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); white-space: nowrap; z-index: 10; }
.toast button { color: #7DB4FF; font-weight: 700; }
.toast button:disabled { display: none; }

@media (max-width: 760px) {
  .arch { padding: 24px 18px 18px; }
  .toast { left: 16px; right: 16px; transform: none; justify-content: space-between; }
  .app { padding: 20px 16px 32px; }
  .browse { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .browse.reading .list { display: none; }
  .browse:not(.reading) .reader { display: none; }
  .reader { min-height: 70vh; }
  .reader-scroll { padding: 22px 20px 20px; }
  .back { display: block; }
  .result-card { padding: 24px 18px 0; }
  .sc { grid-template-columns: 1fr; }
  .sc div:nth-child(odd) { border-right: 0; padding-right: 0; border-bottom: 0; padding-bottom: 4px; color: var(--ink2); }
  .sc div:nth-child(even) { padding-left: 0; padding-top: 4px; }
  .result td.src { width: 40%; }
}
