:root {
  color-scheme: light dark;
  --bg: #f3f3f3;
  --surface: #ffffff;
  --field: #f3f3f3;
  --line: #e0e0e0;
  --text: #1f1f1f;
  --dim: #6b6b6b;
  --accent: #1a6fc4;
  --accent-ink: #ffffff;
  --accent-soft: #dcebfa;
  --btn: #1a6fc4;
  --btn-ink: #ffffff;
  --badge: #e0e0e0;
  --badge-ink: #4a4a4a;
  --warn: #b3401f;
  --smile: #2a7fc4;
  --toyou: #2a7fc4;
}
@media (prefers-color-scheme: dark) {
  /* 클로드 확장 채팅창(커서 Visual Studio Dark 테마)과 같은 색 */
  :root {
    --bg: #1e1e1e;
    --surface: #252526;
    --field: #3c3c3c;
    --line: #3c3c3c;
    --text: #cccccc;
    --dim: #9a9a9a;
    --accent: #3794ff;
    --accent-ink: #ffffff;
    --accent-soft: #04395e;
    --btn: #0e639c;
    --btn-ink: #ffffff;
    --badge: #4d4d4d;
    --badge-ink: #ffffff;
    --warn: #ff8a66;
    --smile: #6cb6f0;
    --toyou: #6cb6f0;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 13px; font-weight: 700; color: var(--dim); margin: 26px 0 8px; }
code { font-size: 12px; }

button, input, select { font: inherit; color: inherit; }
input, select {
  width: 100%;
  min-height: 36px;
  padding: 5px 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); font-weight: 700; }
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }

.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login-card h1 { margin-bottom: 18px; }
.login-card button { width: 100%; }

.shell { min-height: 100%; }
.main { position: relative; max-width: 760px; margin: 0 auto; padding: 22px 16px 96px; }
.head { margin-bottom: 14px; padding-right: 96px; }
.sync-btn { position: absolute; z-index: 2; top: 18px; right: 16px; min-width: 84px; min-height: 32px; padding: 0 8px; font-size: 13px; white-space: nowrap; background: var(--surface); }
.sync-btn:disabled { opacity: 1; color: var(--dim); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.news-title { margin: 26px 0 8px; }
.news-title h2 { margin: 0; }
.live-btn { flex: none; }
.hint { color: var(--dim); font-size: 13px; margin: 6px 0 12px; }
.error { color: var(--warn); font-size: 13px; margin: 8px 0 0; min-height: 0; }
.error:empty { display: none; }
.offline { background: var(--warn); color: #fff; padding: 8px 12px; border-radius: 8px; margin: 0 96px 14px 0; font-size: 13px; }

.nav {
  position: fixed;
  z-index: 3;
  inset: auto 0 0 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .brand { display: none; }
.nav a {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 2px 7px;
  color: var(--dim);
  font-size: 12px;
  text-decoration: none;
}
.nav a.on { color: var(--accent); font-weight: 700; }
.glyph { font-size: 17px; line-height: 1.2; }
.glyph.glyph-code { font: 700 12px/20px Consolas, "Cascadia Mono", monospace; letter-spacing: -0.08em; white-space: nowrap; }
.badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--badge);
  color: var(--badge-ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}
.nav a .badge { position: absolute; top: 4px; left: calc(50% + 8px); }

@media (min-width: 820px) {
  .main { max-width: none; padding: 30px 40px 96px; }
  .sync-btn { top: 26px; right: 40px; }
  .view { max-width: 720px; margin: 0 auto; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.form > label { margin-top: 10px; }
.form > label:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.field { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; margin-top: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.item .num { width: 20px; flex: none; color: var(--accent); font-weight: 800; text-align: center; }
.item .body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .title { font-weight: 600; }
.item.is-done .title { color: var(--dim); text-decoration: line-through; }
.item .meta { color: var(--dim); font-size: 13px; }
.item .meta.late { color: var(--warn); font-weight: 600; }
.item .time { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); min-width: 44px; }
.item input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--accent); }
.tools { display: flex; gap: 4px; flex: none; }
.tools button { min-height: 28px; min-width: 28px; padding: 0 6px; font-size: 12px; }
.empty { color: var(--dim); font-size: 14px; padding: 8px 2px; list-style: none; }

.fold { margin-top: 22px; }
.fold summary { cursor: pointer; color: var(--dim); font-size: 13px; font-weight: 700; padding: 6px 0; }

.digest { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.digest.unread { border-color: var(--accent); }
.digest-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.digest-head strong { font-size: 16px; }
.digest-head .range { color: var(--dim); font-size: 12px; }
.new-tag { background: var(--btn); color: var(--btn-ink); border-radius: 4px; font-size: 11px; font-weight: 700; padding: 0 5px; }
.brand-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.brand-name { font-weight: 700; min-width: 76px; }
.brand-name.smile { color: var(--smile); }
.brand-name.toyou { color: var(--toyou); }
.brand-name.other { color: var(--dim); }
.counts { font-variant-numeric: tabular-nums; font-size: 14px; }
.digest .actions button { flex: 1; }

.cal-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-bar strong { flex: 1; min-width: 0; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.cal-bar button { flex: none; min-width: 40px; }
.cal-views { display: flex; flex: none; }
.cal-views button { padding: 0 8px; }
.cal-views button:first-child { border-radius: 8px 0 0 8px; border-right: 0; }
.cal-views button:last-child { border-radius: 0 8px 8px 0; }
.cal-views button.on { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); font-weight: 700; }
.cal-year[hidden], #cal-month[hidden] { display: none; }
.cal-year { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cal-mini { min-width: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.cal-mini.current { border-color: var(--accent); }
.cal-mini-title { display: block; width: 100%; min-height: 28px; padding: 0 2px; border: 0; font-size: 14px; font-weight: 800; text-align: left; }
.cal-mini-week, .cal-mini-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-mini-week span { color: var(--dim); font-size: 10px; line-height: 16px; text-align: center; }
.cal-mini-week span:first-child { color: var(--warn); }
.cal-mini-week span:last-child { color: var(--accent); }
.cal-mini-day { position: relative; min-width: 0; min-height: 28px; padding: 0; border: 0; border-radius: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cal-mini-day.sat { color: var(--accent); }
.cal-mini-day.sun, .cal-mini-day.hol { color: var(--warn); }
.cal-mini-day.hol { font-weight: 800; }
.cal-mini-day.today { background: var(--btn); color: var(--btn-ink); font-weight: 800; }
.cal-mini-day.has::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.cal-mini-notes { margin: 4px 0 0; padding: 0; font-size: 11px; line-height: 15px; list-style: none; }
.cal-mini-notes .hol { color: var(--warn); }
.cal-mini-notes .ann { color: var(--dim); }
.cal-line.hol, .cal-line.ann { white-space: normal; overflow-wrap: anywhere; }
.cal-line.hol { color: var(--warn); font-weight: 700; }
.cal-line.ann { color: var(--dim); }
.cal-day-name { margin: -4px 0 8px; font-size: 13px; font-weight: 700; }
.cal-day-name.hol { color: var(--warn); }
.cal-day-name.ann { color: var(--dim); }
.cal-day .item.cal-item { flex-wrap: nowrap; gap: 6px; }
.cal-day .item.cal-item .tools { width: auto; }
.cal-clock::-webkit-calendar-picker-indicator { display: none; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week span { padding: 4px 0; text-align: center; color: var(--dim); font-size: 12px; font-weight: 700; }
.cal-week span:first-child { color: var(--warn); }
.cal-week span:last-child { color: var(--accent); }
.cal-grid { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  min-height: 72px;
  padding: 3px;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  color: var(--text);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}
.cal-cell.out { background: var(--bg); }
.cal-cell.out > * { opacity: 0.5; }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { align-self: flex-start; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 10px; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.cal-cell.sun .cal-num { color: var(--warn); }
.cal-cell.sat .cal-num { color: var(--accent); }
.cal-cell.hol .cal-num { color: var(--warn); }
.cal-cell.today .cal-num { background: var(--btn); color: var(--btn-ink); }
.cal-line { display: block; overflow: hidden; padding: 0 2px; border-radius: 3px; font-size: 10px; line-height: 14px; white-space: nowrap; }
.cal-line.ev { background: var(--accent-soft); }
.cal-line.task { background: var(--badge); color: var(--badge-ink); }
.cal-line.memo, .cal-line.more { color: var(--dim); }
.cal-line.done { text-decoration: line-through; opacity: 0.65; }
.cal-time { display: none; }
.cal-day { margin-top: 14px; }
.cal-day h2:first-child { margin-top: 0; color: var(--text); font-size: 15px; }
.cal-memo { display: block; width: 100%; min-height: 72px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; resize: vertical; }
.cal-status { min-height: 18px; margin: 2px 0 0; color: var(--dim); font-size: 12px; }
.item input.cal-edit { flex: 1; min-width: 0; width: auto; }
.item input.cal-clock, .cal-add input.cal-clock { flex: none; width: 92px; padding-inline: 4px; font-size: 13px; }
.cal-add { display: flex; gap: 6px; }
.cal-add input { flex: 1; min-width: 0; }
.cal-add button { flex: none; }
@media (min-width: 561px) {
  .cal-cell { min-height: 92px; padding: 4px; }
  .cal-line { font-size: 11px; line-height: 15px; }
  .cal-time { display: inline; margin-right: 3px; font-variant-numeric: tabular-nums; }
  .cal-day { margin-top: 0; }
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .cal-mini { padding: 8px; }
}
@media (max-width: 560px) {
  .cal-bar { gap: 4px; }
  .cal-bar strong { font-size: 15px; white-space: nowrap; }
  .cal-bar > button { min-width: 32px; padding: 0 6px; }
}
@media (min-width: 1180px) {
  .cal-year { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.subnav { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 7px 14px; color: var(--dim); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a.on { color: var(--accent); border-bottom-color: var(--accent); }

.note-yellow { --note: #fff3b0; }
.note-green { --note: #d3f2c9; }
.note-pink { --note: #fbd5e3; }
.note-purple { --note: #e4d8f7; }
.note-blue { --note: #cfe8fa; }
.note-gray { --note: #ececec; }
@media (prefers-color-scheme: dark) {
  .note-yellow { --note: #4d4418; }
  .note-green { --note: #264a2b; }
  .note-pink { --note: #55283c; }
  .note-purple { --note: #3f2f5e; }
  .note-blue { --note: #1f4460; }
  .note-gray { --note: #2a2a2a; }
}
.note-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.note-tools button { flex: none; }
.note-tools input { flex: 1; min-width: 0; background: var(--field); }
.note-colors { display: flex; gap: 4px; }
.note-colors .swatch {
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(127, 127, 127, 0.6);
  border-radius: 50%;
  background: var(--note);
}
.note-colors .swatch.on { border: 2px solid var(--text); }
.trash-box { flex: none; margin-top: 8px; border-top: 1px solid var(--line); }
.trash-toggle { width: 100%; min-height: 30px; padding: 0 2px; color: var(--dim); font-size: 12px; text-align: left; background: transparent; border: 0; }
.trash-rows { max-height: 180px; overflow-y: auto; }
.trash-row { display: block; width: 100%; min-height: 0; padding: 6px 8px; margin-bottom: 4px; font-size: 13px; text-align: left; background: transparent; border: 1px dashed var(--line); border-radius: 8px; }
.trash-row span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-row .trash-action { color: var(--accent); font-size: 12px; }
.version-row { display: block; width: 100%; min-height: 0; padding: 10px 12px; margin-bottom: 6px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.version-row span { display: block; }
.version-row .version-time { color: var(--dim); font-size: 12px; }
.version-row .version-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; white-space: pre-line; font-size: 14px; }
.rel-paper.colored { background: var(--note); }
.page-row.colored { box-shadow: inset 4px 0 0 var(--note); }
.spirit-shell { height: calc(100dvh - 330px); min-height: 420px; }
#reader-title { flex: 1 1 120px; min-width: 0; min-height: 30px; padding: 2px 8px; font-weight: 700; background: transparent; }
#spirit-text-shell .rel-status { flex: none; }

.rel-shell { display: flex; height: calc(100dvh - 170px); min-height: 320px; }
.with-subnav .rel-shell { height: calc(100dvh - 222px); }
.rel-list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rel-paper { flex: 1; min-width: 0; display: none; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rel-shell.editing .rel-list { display: none; }
.rel-shell.editing .rel-paper { display: flex; }
.rel-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rel-tools button { flex: none; }
.rel-tools input { flex: 1; min-width: 0; background: var(--field); }
.rel-rows { flex: 1; min-height: 0; overflow-y: auto; }
.page-row {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 10px 12px;
  margin-bottom: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.page-row.on { border-color: var(--accent); background: var(--accent-soft); }
.page-row span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-row .page-title { font-weight: 700; }
.page-row .page-sub { color: var(--dim); font-size: 12px; }
.rel-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.rel-bar button { min-height: 28px; padding: 0 8px; font-size: 12px; }
.rel-status { flex: 1; font-size: 12px; color: var(--dim); text-align: right; }
.rel-status.failed { color: var(--warn); font-weight: 700; }
.rel-body {
  flex: 1;
  width: 100%;
  padding: 18px 22px 40px;
  font: inherit;
  font-size: var(--note-font, 17px);
  line-height: 1.75;
  color: inherit;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
}
/* 내용 왼쪽, 목록 오른쪽. 폰이 아니면 창을 줄이거나 화면을 확대해도 유지한다. */
@media (min-width: 561px) {
  .view.wide { max-width: none; }
  .rel-shell { flex-direction: row-reverse; gap: 12px; }
  .rel-list { flex: 0 0 clamp(190px, 34%, 270px); }
  .rel-paper, .rel-shell.editing .rel-paper { display: flex; }
  .rel-shell.editing .rel-list { display: flex; }
  .rel-back { display: none; }
  .rel-tools { flex-wrap: wrap; }
  .rel-tools input { flex: 1 1 110px; }
  .split { display: flex; align-items: flex-start; gap: 12px; }
  .split-main { flex: 1; min-width: 0; }
  .split-side { flex: 0 0 min(400px, 48%); min-width: 0; }
  .split-side h2:first-child { margin-top: 0; }
  .split-side .item { flex-wrap: wrap; }
  .split-side .item .body { flex-basis: 50%; }
  .split-side .tools { width: 100%; justify-content: flex-end; }
}
@media (min-width: 820px) {
  .with-subnav .rel-shell { height: calc(100dvh - 230px); }
  .rel-shell { height: calc(100dvh - 178px); gap: 14px; }
  .spirit-shell { height: calc(100dvh - 338px); }
  .rel-body { padding: 24px 34px 48px; }
}

.back-link { display: inline-block; color: var(--dim); font-size: 13px; text-decoration: none; margin-bottom: 8px; }
.spirit-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spirit-head h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.seminar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  margin-bottom: 8px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seminar-row strong { flex: 1; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.seminar-row span { flex: none; color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.file-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  background: var(--btn);
  color: var(--btn-ink);
}
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; flex: none; min-height: 0; padding: 0; }
.file-input:focus-visible + button { outline: 2px solid var(--accent); }
#spirit-detail .note-tools { flex-wrap: wrap; }
#spirit-detail .note-tools input[type="search"] { flex: 1 1 180px; }
.spirit-text {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 10px 12px;
  margin-bottom: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.spirit-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spirit-text .page-title { font-weight: 700; }
.spirit-text .page-sub { color: var(--dim); font-size: 13px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.photo-card { display: block; min-height: 0; padding: 0; overflow: hidden; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.photo-card img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--line); }
.photo-card span { display: block; padding: 4px 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spirit-reader { width: min(860px, 100vw); height: min(880px, 100dvh); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); }
.spirit-reader[open] { display: flex; flex-direction: column; }
.spirit-reader::backdrop, .spirit-photo::backdrop { background: rgba(0, 0, 0, 0.55); }
.spirit-reader-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.spirit-reader-bar button { min-height: 28px; padding: 0 8px; font-size: 12px; }
.spirit-photo { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0e0f10; color: #eee; }
.spirit-photo[open] { display: flex; flex-direction: column; }
.spirit-photo .viewer-bar { background: #1b1d1f; border-bottom-color: #333; flex-wrap: wrap; }
.spirit-photo .viewer-bar strong { flex: 1; min-width: 120px; overflow-wrap: anywhere; }
.spirit-photo button { color: #eee; border-color: #555; }
.photo-count { align-self: center; padding: 0 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.photo-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.photo-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }

.page-row, .spirit-text, .photo-card { font-size: 15px; }

.linked-title { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.linked-section { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--dim); }
.linked-body .photo-grid + .linked-section, .linked-body .spirit-text + .linked-section { margin-top: 16px; }
.linked-other { padding: 8px 12px; margin-bottom: 6px; color: var(--dim); font-size: 14px; border: 1px dashed var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.page-row.is-empty .page-title { color: var(--dim); font-weight: 400; }
.today-tag { display: inline-block !important; margin-left: 6px; padding: 0 5px; font-size: 11px; font-weight: 700; color: var(--btn-ink); background: var(--btn); border-radius: 4px; vertical-align: 1px; }
.linked-text-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#linked-text-body { flex: 1; width: 100%; padding: 20px 28px 40px; font: inherit; font-size: var(--note-font, 17px); line-height: 1.8; color: inherit; background: transparent; border: 0; outline: none; resize: none; }

.viewer { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--text); }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(0, 0, 0, 0.6); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #141416; }

@media (max-width: 420px) {
  .row { flex-direction: column; }
  .nav { overflow-x: auto; scrollbar-width: none; }
  .nav a { flex: 0 0 52px; min-width: 0; padding-inline: 0; font-size: 11px; letter-spacing: -0.03em; white-space: nowrap; }
  .rel-bar { gap: 5px; padding-inline: 8px; }
  .rel-bar button { flex: none; padding: 0 7px; }
  .rel-status { min-width: 0; overflow: hidden; white-space: nowrap; }
  .note-colors { gap: 3px; }
  .note-colors .swatch { width: 20px; height: 20px; }
}
@media (max-width: 560px) {
  .spirit-reader { width: 100vw; height: 100dvh; border-radius: 0; }
  .subnav { overflow-x: auto; scrollbar-width: none; }
  .subnav a { flex: none; margin-bottom: 0; padding-inline: 10px; white-space: nowrap; }
  .item { flex-wrap: wrap; }
  .item .body { flex-basis: 50%; }
  .tools { width: 100%; justify-content: flex-end; }
}

.search-btn { right: 106px; min-width: 64px; }
.search-wide { display: none; }
.search-field { width: 100%; }
.search-row { display: block; width: 100%; min-height: 0; margin-bottom: 8px; padding: 10px 12px; text-align: left; font-weight: 400; white-space: normal; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.search-row:hover { border-color: var(--accent); }
.search-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--dim); font-size: 12px; }
.search-where { color: var(--accent); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-title { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-snippet { display: block; margin-top: 2px; color: var(--dim); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.search-snippet mark { padding: 0 2px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.head { padding-right: 172px; }
@media (min-width: 561px) {
  .head { padding-right: 200px; }
  .search-wide { display: inline; }
}
@media (min-width: 820px) {
  .search-btn { right: 132px; }
}

/* 쉐마·체인저 안쪽 탭 (자료 | 노트). 위 작은 탭보다 한 단계 작은 알약 모양 */
.innernav { display: inline-flex; gap: 2px; margin: -4px 0 12px; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.innernav a { padding: 4px 14px; color: var(--dim); font-size: 13px; font-weight: 600; text-decoration: none; border-radius: 6px; }
.innernav a.on { color: var(--text); background: var(--field); }
.with-innernav .rel-shell { height: calc(100dvh - 262px); }
@media (min-width: 820px) {
  .with-innernav .rel-shell { height: calc(100dvh - 270px); }
}

/* 따로 띄운 노트 창 (PC 프로그램): 메뉴 없이 쓰는 곳만 창 가득 */
body.popout .nav, body.popout .sync-btn { display: none; }
body.popout .main { max-width: none; margin: 0; padding: 0; }
body.popout .view { max-width: none; margin: 0; }
body.popout .view > :not(.notebook-host) { display: none; }
body.popout .rel-shell, body.popout .with-subnav .rel-shell, body.popout .with-innernav .rel-shell { height: 100vh; height: 100dvh; min-height: 0; gap: 0; }
body.popout .rel-list, body.popout .nb-back { display: none !important; }
body.popout .rel-paper { display: flex !important; border: 0; border-radius: 0; }
body.popout .offline { position: fixed; z-index: 5; top: 8px; left: 8px; right: 8px; margin: 0; }

/* 폰 앱 업데이트: '오늘' 맨 아래 버전 줄, 새 버전이 있으면 아래 메뉴 위에 파란 단추 */
.update-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--dim); font-size: 13px; }
.update-row.fresh { border-color: var(--accent); color: var(--text); }
.update-row.fresh #app-update { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); font-weight: 700; }
.update-fresh { position: fixed; z-index: 5; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 64px); min-height: 34px; padding: 0 14px; border-radius: 17px; background: var(--btn); color: var(--btn-ink); border: 0; font-weight: 700; font-size: 13px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.update-status { position: fixed; z-index: 6; bottom: calc(env(safe-area-inset-bottom) + 108px); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); margin: 0; padding: 8px 14px; border-radius: 18px; background: var(--btn); color: var(--btn-ink); font-size: 13px; text-align: center; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
body.popout .update-fresh, body.popout .update-status { display: none; }

/* 보기: 그림·표가 든 노트를 원본처럼 (글은 마크다운 그대로 저장) */
.rel-view { overflow-y: auto; overflow-wrap: anywhere; cursor: text; }
.rel-view > :first-child { margin-top: 0; }
.rel-view p { margin: 0 0 0.9em; }
.rel-view img { display: block; max-width: 100%; height: auto; margin: 0.6em 0; border-radius: 6px; }
.rel-view h2, .rel-view h3, .rel-view h4, .rel-view h5, .rel-view h6 { margin: 1.1em 0 0.5em; line-height: 1.35; }
.rel-view h2 { font-size: 1.35em; } .rel-view h3 { font-size: 1.2em; } .rel-view h4, .rel-view h5, .rel-view h6 { font-size: 1.05em; }
.rel-view .md-table { overflow-x: auto; margin: 0.6em 0 1em; }
.rel-view table { border-collapse: collapse; font-size: 0.92em; line-height: 1.5; }
.rel-view th, .rel-view td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.rel-view th { background: var(--field); }
.rel-view pre { background: var(--field); padding: 10px 12px; border-radius: 6px; overflow-x: auto; font: 0.88em/1.5 Consolas, "Cascadia Mono", monospace; white-space: pre; }
.rel-view code { background: var(--field); padding: 1px 5px; border-radius: 4px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.9em; }
.rel-view blockquote { margin: 0.4em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--dim); }
.rel-view hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.rel-view .md-li { position: relative; margin: 0.15em 0; }
.rel-view .md-mark { position: absolute; margin-left: -1.3em; color: var(--dim); }
.rel-view a { color: var(--accent); }
.nb-viewbtn.on { border-color: var(--accent); color: var(--accent); }
/* 폰 폭: 노트 위 단추 6개가 한 줄에 들어가게 간격만 줄인다 */
@media (max-width: 420px) {
  .rel-bar { gap: 4px; padding: 8px 6px; flex-wrap: wrap; row-gap: 6px; }
  .rel-bar button { padding: 0 5px; }
}
.rel-status { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rel-bar button { flex: none; }

.update-row #app-version { flex: 1; min-width: 0; }
.update-row button { flex: none; }

/* 알림 설정 */
.pref-link { display: flex; align-items: center; gap: 10px; margin: 28px 0 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.pref-link + .update-row { margin-top: 10px; }
.pref-link-title { font-weight: 700; flex: none; }
.pref-link-sub { flex: 1; min-width: 0; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pref-link-go { color: var(--dim); font-size: 20px; line-height: 1; }
.pref-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.pref-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 66px); align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.pref-row:first-child { border-top: 0; }
.pref-head { background: var(--field); font-size: 12px; }
.pref-head span:not(:first-child) { text-align: center; display: flex; flex-direction: column; line-height: 1.3; }
.pref-row small { display: block; color: var(--dim); font-size: 11px; font-weight: 400; }
.pref-row span[role="cell"]:not(.pref-name) { display: flex; justify-content: center; }
.switch { min-width: 52px; min-height: 30px; padding: 0 8px; border-radius: 15px; font-size: 12px; font-weight: 700; background: var(--field); color: var(--dim); border: 1px solid var(--line); }
.switch.on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.switch:disabled { opacity: 0.4; }
.pref-quiet { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; color: var(--dim); }
.pref-quiet > span:first-of-type { flex: 1 1 180px; }
.pref-times { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.pref-times input { width: 150px; background: var(--field); }
#alertprefs-buzz { margin-top: 4px; }
@media (max-width: 420px) {
  .pref-row { grid-template-columns: minmax(0, 1fr) repeat(3, 56px); gap: 4px; padding: 10px 8px; }
  .switch { min-width: 48px; }
}
@media (max-width: 420px) { .pref-times input { width: 128px; } }
