:root {
  --green: #2f6f4e;
  --green-d: #255a3f;
  --bg: #f6f6f7;
  --card: #ffffff;
  --text: #1d2125;
  --muted: #6b7280;
  --line: #e4e6e9;
  --accent: #2f6f4e;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --card: #1e2125; --text: #e6e8ea; --muted: #9aa3ad;
    --line: #2b2f35; --green: #4a9d73; --accent: #4a9d73;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--text); overscroll-behavior-y: none;
}
#app { height: 100%; max-width: 820px; margin: 0 auto; position: relative; }

.view { display: none; flex-direction: column; height: 100dvh; }
.view.active { display: flex; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; gap: 8px;
  background: var(--green); color: #fff; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px;
  width: 38px; height: 38px; font-size: 20px; line-height: 1; cursor: pointer;
}
.ed-actions { display: flex; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c9d4cf; display: inline-block; }
.dot.ok { background: #7CFFB2; } .dot.sync { background: #ffd24a; } .dot.err { background: #ff7a7a; }

.subbar { display: flex; gap: 8px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.nb-select, .search {
  font-size: 15px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.nb-select { flex: 0 0 auto; max-width: 42%; }
.search { flex: 1; }

.notelist { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 90px; }
.note-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.note-card:active { transform: scale(.995); }
.nc-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.nc-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-date { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.nc-snip { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-height: 40px; overflow: hidden; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

.fab {
  position: absolute; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px);
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--green);
  color: #fff; font-size: 30px; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; z-index: 6;
}

.ed-title { font-size: 21px; font-weight: 700; border: 0; padding: 14px 16px 6px; background: transparent; color: var(--text); outline: none; }
.toolbar { display: flex; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; background: var(--card); position: sticky; top: 58px; z-index: 4; }
.toolbar button { flex: 0 0 auto; min-width: 40px; height: 36px; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 8px; font-size: 15px; cursor: pointer; }
.ed-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 120px; font-size: 16px; line-height: 1.6; outline: none; }
.ed-body img { max-width: 100%; border-radius: 8px; }
.ed-body:empty::before { content: "내용을 입력하세요…"; color: var(--muted); }
.ed-saved { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 10px); left: 16px; color: var(--muted); font-size: 12px; }

.settings { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.settings label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.settings input { font-size: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); }
.primary { background: var(--green); color: #fff; border: 0; border-radius: 10px; padding: 13px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 15px; cursor: pointer; }
.cfg-status { font-size: 14px; min-height: 20px; }
.cfg-status.ok { color: var(--green); } .cfg-status.err { color: var(--danger); }
.settings-info { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.install-hint { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px);
  background: #333; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 20; max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
