:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2a2520;
  --muted: #8a7f72;
  --line: #ece5da;
  --accent: #c2410c;       /* warm terracotta */
  --accent-soft: #fbeee6;
  --pin: #e0a106;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(60,50,40,.05), 0 8px 22px -14px rgba(60,50,40,.25);
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native LIGHT. Opposite (dark) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="dark"]{
  --bg: #1e1b15;
  --card: #2b2b2b;
  --ink: #c1b7ad;
  --muted: #9c9388;
  --line: rgba(255,255,255,0.12);
  --accent: #ef500f;
  --accent-soft: #d76722;
  --pin: #b07e05;
  --ok: #159c47;
}












* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans KR", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55;
  -webkit-font-smoothing: antialiased; height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}

/* Header */
.site {
  display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: rgba(250,247,242,.85); backdrop-filter: blur(8px); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 19px; }
.brand-name { font-family: "Fraunces", serif; font-weight: 600; font-size: 21px; letter-spacing: -.01em; }

.sync {
  display: flex; align-items: center; gap: 7px; background: var(--card); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 12px; font-size: 12.5px; color: var(--muted); font-weight: 600;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9bfb1; transition: background .3s ease; }
.sync.live .sync-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(22,163,74,.04); } }

.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-action {
  background: var(--card); border: 1px solid var(--line); color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; border-radius: 9px; padding: 8px 12px; transition: all .12s ease;
}
.icon-action:hover { color: var(--ink); border-color: #d8cfc2; }
.btn { font-family: inherit; font-weight: 700; cursor: pointer; border: none; border-radius: 9px; padding: 9px 15px; font-size: 13.5px; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 320px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column;
  background: #fdfbf8; min-height: 0;
}
.search-wrap { padding: 12px; border-bottom: 1px solid var(--line); }
.search {
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 9px; padding: 9px 12px; font-family: inherit; font-size: 14px; outline: none;
}
.search:focus { border-color: var(--accent); }

.note-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.note-item {
  border-radius: 10px; padding: 11px 12px; cursor: pointer; margin-bottom: 3px; border: 1px solid transparent;
  transition: background .12s ease;
}
.note-item:hover { background: #f4ede3; }
.note-item.active { background: var(--accent-soft); border-color: #f1d8c7; }
.note-item .ni-top { display: flex; align-items: center; gap: 6px; }
.note-item .ni-title { font-weight: 700; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .ni-pin { color: var(--pin); font-size: 11px; }
.note-item .ni-preview { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .ni-date { font-size: 11px; color: #b3a899; margin-top: 4px; }
.list-empty { color: var(--muted); text-align: center; padding: 30px 12px; font-size: 13.5px; }

/* Editor */
.editor { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 18px 24px 0; }
.back-btn { display: none; align-self: flex-start; background: none; border: none; color: var(--accent); font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer; padding: 0 0 8px; }
.ed-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.pin-btn { background: none; border: none; cursor: pointer; font-size: 17px; opacity: .35; filter: grayscale(1); transition: all .15s ease; padding: 2px; }
.pin-btn.on { opacity: 1; filter: none; }
.ed-meta { font-size: 12px; color: var(--muted); }
.del-btn { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-family: inherit; font-size: 13px; padding: 4px 8px; border-radius: 7px; }
.del-btn:hover { color: var(--accent); background: var(--accent-soft); }

.title-field {
  border: none; outline: none; background: transparent; color: var(--ink); width: 100%;
  font-family: "Fraunces", serif; font-weight: 600; font-size: 28px; letter-spacing: -.01em; padding: 6px 0;
}
.title-field::placeholder { color: #d3c8ba; }
.body-field {
  flex: 1; border: none; outline: none; background: transparent; color: var(--ink); resize: none;
  font-family: inherit; font-size: 15.5px; line-height: 1.75; padding: 8px 0 24px; width: 100%;
}
.body-field::placeholder { color: #c9bfb1; }

.editor.empty .ed-head, .editor.empty .title-field, .editor.empty .body-field { display: none; }
.editor.empty::after {
  content: "왼쪽에서 노트를 고르거나, 새 노트를 만들어 보세요.";
  color: var(--muted); margin: auto; font-size: 14px; text-align: center;
}

/* Mobile: one pane at a time */
@media (max-width: 720px) {
  .sidebar { width: 100%; border-right: none; }
  .editor { display: none; }
  body.editing .sidebar { display: none; }
  body.editing .editor { display: flex; }
  .back-btn { display: block; }
  .actions .icon-action { display: none; }
  /* Let the theme/i18n switchers wrap to a 2nd row instead of clipping off the
     right edge (body is overflow:hidden → nowrap would silently hide them). */
  .site { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 99px; font-weight: 600; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60; box-shadow: 0 12px 30px -8px rgba(0,0,0,.35);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* i18n language switcher — 테라코타 액센트로 맞춤. */
.i18n-switch {
  --i18n-switch-bg: var(--accent-soft);
  --i18n-switch-border: #e3d6cc;
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent);
  --i18n-switch-active-fg: #fff;
  --i18n-switch-menu-bg: var(--card);
  --i18n-switch-menu-border: var(--line);
}

/* dark-mode overrides for hardcoded light layout panels (refinement) */
:root[data-theme="dark"] .site{ background: rgba(20,18,16,.85); }
:root[data-theme="dark"] .sidebar{ background: rgba(24,22,20,.9); }
