/* JENJEN Note — 젠젠 CI(검정·흰색, 굵은 장체 로고) + 회사 홈페이지 색(먹·종이·포인트 파랑) */
:root {
  --ink: #0e0e10;
  --ink-2: #1b1b1f;
  --paper: #fafaf8;
  --paper-2: #f1f1ee;
  --line: rgba(14, 14, 16, 0.12);
  --muted: #6b6c75;
  --side-muted: #8e8f99;
  --point: #2c46ff;
  --bg: var(--paper);
  --fg: var(--ink);
  --sel-bg: var(--ink);
  --sel-fg: var(--paper);
  --wide: 'Archivo', 'Pretendard Variable', Pretendard, sans-serif;
  --kr: 'Pretendard Variable', Pretendard, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --mono: 'Space Mono', 'Pretendard Variable', Pretendard, 'Malgun Gothic', monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --fg: #ececea;
    --paper-2: #1a1a1e;
    --line: rgba(250, 250, 248, 0.12);
    --muted: #9a9ba6;
    --sel-bg: var(--paper);
    --sel-fg: var(--ink);
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font: 15px/1.65 var(--kr);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; border-radius: 0; padding: 4px 10px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--point); outline-offset: 2px; }
button.ghost { color: var(--muted); font-size: 13px; }
button.ghost:hover { color: var(--fg); }
button.small { font-size: 12px; padding: 2px 8px; }
button.icon { width: 32px; height: 32px; padding: 0; font-size: 16px; line-height: 32px; }
button.new {
  background: var(--paper); color: var(--ink);
  font-family: var(--wide); font-stretch: 75%; font-weight: 800;
  letter-spacing: 0.02em; text-transform: uppercase; padding: 9px 12px;
}
button.new:hover { background: #fff; }
ul { list-style: none; margin: 0; padding: 0; }

.brand { font-family: var(--wide); font-stretch: 72%; font-weight: 600; font-size: 22px; letter-spacing: 0.005em; line-height: 1; }
.brand b { font-weight: 850; letter-spacing: -0.005em; }

#app { display: grid; grid-template-columns: 228px 310px 1fr; height: 100dvh; }

/* 사이드바 = 검정 명함 */
#sidebar {
  background: var(--ink); color: var(--paper);
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: max(16px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.side-head { display: flex; align-items: center; gap: 2px; padding: 2px 4px 10px; border-bottom: 1px solid rgba(250, 250, 248, 0.14); }
.side-head .brand { flex: 1; }
.side-head button { color: var(--side-muted); }
.side-head button:hover { color: var(--paper); }
#btn-new-note { margin: 4px 0 8px; }
.side-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--side-muted); padding: 0 4px;
}
.side-label button { color: var(--side-muted); }
.side-label button:hover { color: var(--paper); }
#books { overflow: auto; flex: 1; }
#books li, #trash-link li {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 4px 6px 10px; cursor: pointer; color: #cfcfd4;
  border-left: 2px solid transparent;
}
#books li:hover, #trash-link li:hover { color: var(--paper); background: var(--ink-2); }
#books li.on, #trash-link li.on { color: var(--paper); background: var(--ink-2); border-left-color: var(--point); font-weight: 600; }
#trash-link { border-top: 1px solid rgba(250, 250, 248, 0.14); padding-top: 8px; }
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-family: var(--mono); font-size: 11px; color: var(--side-muted); }
#books .more { width: 26px; height: 26px; line-height: 26px; padding: 0; color: var(--side-muted); opacity: 0; }
#books li:hover .more, #books li.on .more { opacity: 1; }
#sync-status { font-family: var(--mono); font-size: 10.5px; color: var(--side-muted); padding: 2px 4px; line-height: 1.5; }
#sync-status.err { color: #ff8a73; }

/* 노트 목록 = 흰 명함 */
#list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.list-head {
  display: flex; align-items: center; gap: 6px;
  padding: max(16px, env(safe-area-inset-top)) 16px 8px;
}
.list-head h2 {
  flex: 1; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
}
#search {
  margin: 0 16px 10px; padding: 8px 10px; font-size: 14px;
  border: 0; border-bottom: 1.5px solid var(--fg); border-radius: 0; background: transparent;
}
#search:focus { outline: none; border-bottom-color: var(--point); }
#notes { overflow: auto; flex: 1; }
#notes li { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
#notes li:hover { background: var(--paper-2); }
#notes li.on { background: var(--sel-bg); color: var(--sel-fg); }
#notes li.on .s, #notes li.on .d { color: inherit; opacity: 0.68; }
#notes .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#notes .s {
  font-size: 13px; color: var(--muted); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: keep-all; overflow-wrap: anywhere;
}
#notes .d { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
#notes .none { color: var(--muted); cursor: default; border: 0; }
#notes .none:hover { background: none; }

/* 편집기 = 종이 */
#editor-pane { display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
.ed-head {
  display: flex; align-items: center; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 28px 6px; color: var(--muted); font-size: 13px;
}
#note-book {
  border: 1px solid var(--line); border-radius: 0; background: var(--bg);
  padding: 4px 6px; font-size: 13px; max-width: 45%;
}
#saved { flex: 1; font-family: var(--mono); font-size: 11px; }
#btn-restore { color: var(--point); font-weight: 700; }
#note-area { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#title {
  border: 0; outline: none; background: none;
  font-size: 30px; font-weight: 800; letter-spacing: -0.03em; padding: 8px 40px 6px;
}
#editor {
  flex: 1; overflow: auto; outline: none;
  padding: 6px 40px 40vh; font-size: 16px; line-height: 1.75;
  word-break: keep-all; overflow-wrap: anywhere;
}
#editor > div { min-height: 1.75em; }
#editor hr { border: 0; border-top: 2px solid var(--fg); margin: 14px 0; }
#editor .todo { position: relative; padding-left: 30px; }
#editor .todo::before {
  content: ""; position: absolute; left: 1px; top: 0.36em;
  width: 17px; height: 17px; border: 2px solid var(--fg); background: var(--bg); cursor: pointer;
}
#editor .todo[data-checked]::before {
  background: var(--fg) center / 13px no-repeat
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3 8.4l3.2 3.1L13 4.6' fill='none' stroke='%23fafaf8' stroke-width='2.4' stroke-linecap='square'/></svg>");
}
#editor .todo[data-checked] { color: var(--muted); text-decoration: line-through; }
#editor-pane.readonly #title, #editor-pane.readonly #editor { color: var(--muted); }
#empty {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; color: var(--muted);
}
#editor-pane.blank #note-area, #editor-pane.blank .ed-head > :not(#btn-back) { visibility: hidden; }
#editor-pane.blank #empty { display: flex; }

/* 알림 띠 */
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--paper); padding: 10px 12px 10px 16px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); z-index: 20; max-width: calc(100vw - 32px);
}
#toast-undo { color: #8c9bff; font-weight: 700; padding: 2px 6px; }

/* 잠금 화면 */
#lock {
  position: fixed; inset: 0; z-index: 30; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#lock-form { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(300px, 100%); }
#lock .brand.big { font-size: 40px; margin-bottom: 8px; }
#lock p { margin: 0; color: var(--side-muted); font-size: 14px; min-height: 1.4em; text-align: center; }
#lock-pin {
  width: 100%; text-align: center; font-size: 26px; letter-spacing: 0.4em;
  background: transparent; border: 0; border-bottom: 2px solid var(--paper); padding: 6px; color: var(--paper);
}
#lock-pin:focus { outline: none; border-bottom-color: var(--point); }
#lock .new { width: 100%; }

/* 설정 창 */
dialog {
  border: 0; border-top: 6px solid var(--ink); padding: 22px 24px; border-radius: 0;
  background: var(--bg); color: var(--fg); width: min(400px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(14, 14, 16, 0.55); }
dialog h3 { margin: 0 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
dialog .hint { margin: -4px 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.55; word-break: keep-all; }
dialog label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 14px; }
dialog small { font-weight: 400; color: var(--muted); margin-left: 4px; }
dialog input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 2px; font-size: 16px;
  border: 0; border-bottom: 1.5px solid var(--fg); border-radius: 0; background: transparent;
}
dialog input:focus { outline: none; border-bottom-color: var(--point); }
#set-msg { color: var(--point); margin-top: 0; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }
dialog menu .new { background: var(--ink); color: var(--paper); padding: 8px 22px; }
dialog menu .new:hover { background: var(--ink-2); }
dialog menu .new:disabled { opacity: 0.5; }
@media (prefers-color-scheme: dark) {
  dialog { border-top-color: var(--paper); }
  dialog menu .new { background: var(--paper); color: var(--ink); }
}

.mobile-only { display: none; }

/* 폰: 한 화면에 한 칸씩 */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #sidebar, #list, #editor-pane { display: none; border: 0; }
  #app[data-view="books"] #sidebar,
  #app[data-view="list"] #list,
  #app[data-view="editor"] #editor-pane { display: flex; }
  .mobile-only { display: inline-block; }
  #btn-new-note { display: none; }
  #books li, #trash-link li { padding: 11px 4px 11px 12px; font-size: 16px; }
  #books .more { opacity: 1; }
  #title { padding: 6px 18px 4px; font-size: 25px; }
  #editor { padding: 4px 18px 40vh; }
  .ed-head { padding-left: 8px; padding-right: 12px; }
  #search { font-size: 16px; }
}
