:root {
  --paper: #faf8f3; --card: #ffffff; --line: #e5e5e0; --ink: #1f2328; --muted: #7a776f;
  --sepia: #a8977c; --sage: #5F7A61; --amber: #D97757; --sage-bg: #e8eee8; --amber-bg: #f8e9e3;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.6 -apple-system, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 4px 10px; }
button.primary { background: var(--sage); border-color: var(--sage); color: #fff; }
button.ghost { background: transparent; }
button.warn { color: var(--amber); border-color: var(--amber); }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
textarea { min-height: 72px; resize: vertical; }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .08em; }
.brand span { font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 4px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: none; background: none; color: var(--muted); }
.tabs button.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--sage); border-radius: 0; }
.vt { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.vt label { color: var(--muted); font-size: 15px; }
.vt #vt-today { font-variant-numeric: tabular-nums; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .vt { margin-left: 0; } }
.pane { min-width: 0; }
.detail { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; align-self: start; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
@media (max-width: 900px) { .detail { position: static; max-height: none; } }
.empty { color: var(--muted); }

/* 달력 */
.month-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.month-head h2 { margin: 0 8px; font-size: 20px; }
.month-head .stat { color: var(--muted); font-size: 15px; margin-left: auto; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { text-align: center; font-size: 14px; color: var(--muted); }
.day { min-height: 100px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 14px; cursor: pointer; overflow: hidden; }
.day.blank { background: transparent; border: none; cursor: default; }
.day.none { background: transparent; color: var(--muted); }
.day.sel { outline: 2px solid var(--sage); }
.day.vt-today { box-shadow: inset 0 0 0 1px var(--amber); }
.day.sub { opacity: .45; }
.day.erase { opacity: .45; text-decoration: line-through; }
.day .n { font-weight: 600; display: flex; justify-content: space-between; }
.day .n .dots { letter-spacing: -1px; color: var(--sepia); }
.day .t { color: var(--sage); word-break: keep-all; line-height: 1.3; }
.day .p { margin-top: 2px; display: flex; gap: 2px; }
.day .p i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.legend { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* 상세 */
.d-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.d-head h2 { margin: 0; font-size: 22px; }
.badge { font-size: 14px; padding: 1px 8px; border-radius: 999px; background: var(--sage-bg); color: var(--sage); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.section { margin-top: 16px; }
.section h3 { margin: 0 0 6px; font-size: 15px; color: var(--muted); font-weight: 600; }
.tg { display: inline-block; font-size: 15px; padding: 1px 9px; border-radius: 999px; background: var(--sage-bg); color: var(--sage); margin: 0 4px 4px 0; }
.meta { font-size: 14px; color: var(--muted); }
.field { white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 14px; padding: 2px 10px; border-radius: 999px; background: #E5E5E0; color: var(--muted); }
.chip.sched { color: #fff; }
.chip.done::before { content: "✓ "; }
.chip.done:not(.sched) { color: var(--ink); }
.chip-note { font-size: 14px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .cols { grid-template-columns: 1fr; } }
.col { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.col-h { margin-bottom: 6px; }
.col-h small { color: var(--muted); }
.lbl { font-size: 14px; color: var(--muted); margin-top: 8px; }
.changes { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); }
.ch-k { font-size: 14px; color: var(--muted); margin-top: 6px; }
.ch { padding: 2px 0; }
.ch.add { color: var(--ink); font-weight: 600; }
.ch.del { color: var(--sepia); text-decoration: line-through; }
.layer { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 8px 0; }
.units { display: flex; gap: 4px; flex-wrap: wrap; }
.units button.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.card.sel { outline: 2px solid var(--sage); }
.pcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.phead { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.tagedit { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--card); cursor: text; }
.tagedit input { border: none; flex: 1; min-width: 140px; padding: 4px; }
.tagedit input:focus { outline: none; }
.tchip { display: inline-flex; align-items: center; gap: 2px; font-size: 15px; padding: 1px 4px 1px 9px; border-radius: 999px; background: var(--sage-bg); color: var(--sage); }
.tchip button { border: none; background: none; padding: 0 4px; color: var(--sage); line-height: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.banner { padding: 8px 12px; border-radius: 8px; background: var(--amber-bg); color: var(--amber); font-size: 16px; }

form.lag { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border: 1px dashed var(--sage); border-radius: 10px; }
form.lag label { font-size: 14px; color: var(--muted); display: grid; gap: 3px; }
form.lag .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { form.lag .row { grid-template-columns: 1fr; } }
form.lag legend { font-size: 15px; font-weight: 600; }
form.lag fieldset { border: none; padding: 0; margin: 0; display: grid; gap: 8px; }

/* 리스트 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.card .meta { font-size: 14px; color: var(--muted); }
.card.done { opacity: .6; }
.tagrow { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.tagrow b { font-weight: 400; color: var(--sage); }
.tagrow { padding: 4px 6px; border-radius: 6px; }
.tagrow:hover { background: var(--sage-bg); }
.tagrow.on { background: var(--amber); }
.tagrow.on b, .tagrow.on span { color: #fff; font-weight: 700; }
.tg.hit { background: var(--amber); color: #fff; }
.cols h3 { margin: 0 0 4px; font-size: 15px; }

.toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 10; max-width: 90vw; white-space: pre-wrap; }
button.chip { border: none; cursor: pointer; font-size: 14px; }
form.lag details summary { cursor: pointer; }
[data-notes] { display: grid; gap: 6px; margin-top: 6px; }

/* 프로젝트 */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
form.lag .daypick { display: inline-flex; font-size: 16px; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); cursor: pointer; color: var(--ink) !important; }
.daypick input { width: auto; margin: 0; }
.addrow { display: flex; gap: 6px; margin-bottom: 8px; }
.addrow button { white-space: nowrap; }
@media (max-width: 600px) { .addrow { flex-wrap: wrap; } }

/* 원문 | 최종 표: 행 구분선만 */
table.ver { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.ver th, table.ver td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); word-break: keep-all; overflow-wrap: anywhere; }
table.ver thead th { border-bottom: 2px solid var(--line); font-weight: 400; }
table.ver thead th b { display: block; font-size: 17px; }
table.ver thead th small { color: var(--muted); font-size: 14px; }
table.ver tbody th { width: 64px; font-size: 14px; color: var(--muted); font-weight: 600; }
table.ver thead th:first-child { width: 64px; }
table.ver td.f { background: #fbfaf6; }
table.ver tr.same td.f { background: transparent; }
table.ver .gone { color: var(--sepia); }
table.ver .new { font-weight: 700; background: var(--sage-bg); border-radius: 4px; padding: 0 2px; }
table.ver .tg.gone { background: transparent; border: 1px dashed var(--sepia); }
table.ver .tg.new { background: var(--sage); color: #fff; }
.same-m { display: none; }
.m-only { display: none; }
.pcard.open { border-color: var(--sage); }
.d-head [data-close] { margin-left: auto; }

/* 휴대폰: 원문을 접고 최종만. 고치지 않은 줄은 최종 칸에 원문을 그대로 보여 준다 */
@media (max-width: 600px) {
  .m-only { display: inline-block; }
  table.ver.multi:not(.show-orig) td.o, table.ver.multi:not(.show-orig) thead th:nth-child(2) { display: none; }
  table.ver.multi:not(.show-orig) .same-m { display: inline; color: var(--muted); }
  table.ver tbody th, table.ver thead th:first-child { width: 48px; }
}

/* 책 표지 */
table.spec { border-collapse: collapse; width: 100%; font-size: 15px; }
table.spec th, table.spec td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.spec th { width: 120px; color: var(--muted); font-weight: 600; }
.prompt { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--card); }
.prompt pre { white-space: pre-wrap; font: 14px/1.5 ui-monospace, Consolas, monospace; margin: 6px 0 0; max-height: 220px; overflow: auto; }
.bp { position: relative; width: 100%; background: #eee9df; border-radius: 4px; overflow: hidden; container-type: inline-size; }
.bp-img { position: absolute; top: 0; bottom: 0; background-size: cover; background-position: center; }
.bp-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.bp-cut { position: absolute; border: 1px dashed #d33; pointer-events: none; }
.bp-safe { position: absolute; border: 1px dashed #36c; pointer-events: none; opacity: .7; }
.bp-spine { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #d33; border-right: 1px dashed #d33; display: grid; place-items: center; overflow: hidden; }
.bp-spine span { writing-mode: vertical-rl; font-size: 2cqw; color: #222; white-space: nowrap; text-shadow: 0 0 4px #fff; }
.bp-title { position: absolute; top: 14%; text-align: center; display: grid; gap: .6cqw; color: #222; text-shadow: 0 0 6px rgba(255,255,255,.8); }
.bp-title b { font-size: 3.4cqw; } .bp-title span { font-size: 1.8cqw; } .bp-title small { font-size: 1.5cqw; margin-top: 1cqw; }
.uprow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.btnlike { border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; background: var(--card); cursor: pointer; }
.secret { display: flex !important; align-items: center; gap: 6px; font-size: 15px !important; color: var(--ink) !important; }
.secret input { width: auto; }
a.btnlike { color: var(--ink); text-decoration: none; }

/* 태그 후보 · 모델 · 나의 감정 */
.suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.suggest .chip { border: none; cursor: pointer; background: var(--sage-bg); color: var(--sage); }
select.model { width: auto; max-width: 240px; }
#emo-mine { min-height: 60px; }

/* 출력 */
.covers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
form.lag label.cv { display: grid; gap: 2px; justify-items: center; cursor: pointer; padding: 4px; border: 2px solid transparent; border-radius: 8px; font-size: 13px; }
form.lag label.cv.on { border-color: var(--sage); }
.cv .thumb { width: 70px; height: 98px; background-size: cover; background-position: center; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.cv .none { width: 70px; height: 98px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 3px; color: var(--muted); }
.toc { padding-left: 20px; } .toc li { padding: 4px 0; }

/* 나의 감정: 가나다 목록 */
.jump { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.jump a { min-width: 28px; text-align: center; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; background: var(--card); }
.emo-g h3 { margin: 10px 0 2px; font-size: 15px; color: var(--sage); border-bottom: 2px solid var(--sage-bg); }
.emo-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 5px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.emo-row:hover { background: var(--sage-bg); }
.emo-row.sel { outline: 2px solid var(--sage); border-radius: 6px; }
.emo-row .tg { margin: 0; white-space: nowrap; }
.emo-row .d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--muted); }

a.brand { color: var(--ink); text-decoration: none; }

/* 태그 = 나의 감정 */
.tagrow b { display: inline-flex; align-items: center; gap: 4px; }
i.has { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); vertical-align: middle; }
.tagrow small.to { color: var(--muted); font-size: 13px; margin-left: 6px; flex: 1; }
ol.hist { margin: 0; padding-left: 18px; } ol.hist li { margin-bottom: 6px; } ol.hist li.now div { font-weight: 700; }
.tg .x { border: none; background: none; padding: 0 0 0 4px; color: var(--sage); cursor: pointer; }
#tg-mean { min-height: 70px; }

/* 책 탭 색감 풀다운 */
.palpick { position: relative; }
.palpick summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
.palpick summary::-webkit-details-marker { display: none; }
.palpick summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.palmenu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 360px; overflow: auto; }
.palmenu button { display: flex; align-items: center; gap: 10px; width: 100%; border: none; border-radius: 6px; text-align: left; padding: 6px 8px; }
.palmenu button:hover, .palmenu button.on { background: var(--sage-bg); }
.sw { display: inline-flex; flex: none; width: 96px; height: 20px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.sw i { flex: 1; }

/* 설정: 기능 켜기·끄기 */
.feats { display: grid; gap: 8px; }
.feat { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }
.feat.sub { margin-left: 28px; }
.feat.dim { opacity: .6; }
.feat input { width: 20px; height: 20px; margin: 3px 0 0; flex: none; accent-color: var(--sage); }
.feat .d { display: block; font-size: 15px; }
#settings.on { color: var(--ink); font-weight: 600; }

/* 지출 */
.stars { color: #c98a2b; letter-spacing: 1px; } .stars i { font-style: normal; color: #ddd6c8; }
.exp { margin: 2px 0; } .exp .meta { font-size: 15px; }
.exp.gone, .exp.chg.orig { color: var(--sepia); } .exp.chg.final .meta { color: var(--ink); font-weight: 700; } .exp.gone b { font-weight: 400; text-decoration: line-through; }
table.ver .exp.new { background: transparent; padding: 0; } table.ver .exp.new b { background: var(--sage-bg); border-radius: 4px; padding: 0 2px; }
.exprow { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto minmax(0, 2fr) auto; gap: 6px; align-items: center; margin-bottom: 6px; }
@media (max-width: 700px) { .exprow { grid-template-columns: 1fr 1fr auto; } .exprow [data-k=note] { grid-column: 1 / 3; } }
.rate { display: inline-flex; }
.rate button { border: none; background: none; padding: 0 1px; font-size: 20px; color: #ddd6c8; }
.rate button.on { color: #c98a2b; }
.linkish { border: none; background: none; padding: 0; color: var(--sage); text-decoration: underline; margin-right: 6px; }
.exp-item .field { margin-top: 2px; }

/* 특별한 날 */
.badge.sd { background: #f6ecdf; color: #8a5a2b; margin-right: 6px; }
.badge.sd small { margin-left: 6px; color: #b08a63; font-size: 13px; }
.sdblock { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 10px; }
.sdblock .ghost { font-size: 14px; padding: 2px 10px; color: var(--muted); }
.sdform { flex: 1 1 100%; }
.day.sd { box-shadow: inset 0 3px 0 #d9a066; }
.day .sdl { font-size: 12px; color: #8a5a2b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sdform, #sd-new .addrow, #sd-edit .addrow { align-items: center; }
.sdform .chips, #sd-new .chips, #sd-edit .chips { flex-wrap: nowrap; gap: 4px; }

/* 일기장 전환 (헤더) */
select.diary { width: auto; padding: 3px 8px; font-size: 15px; }
body.is-sample select.diary { background: #f6ecdf; border-color: #e6cfae; color: #8a5a2b; }
