:root {
  --bg: #F4EFE6;
  --surface: #FFFCF7;
  --surface-2: #FAF5EC;
  --ink: #2A2522;
  --ink-2: #4A433E;
  --muted: #8A8078;
  --line: #E7DFD3;
  --line-2: #D9CEBF;
  --clay: #C4613F;
  --clay-dark: #A44E30;
  --clay-soft: #F6E3D9;
  --sage: #5F7F63;
  --sage-soft: #E3EDE2;
  --amber: #A9762A;
  --amber-soft: #F6EAD3;
  --rose: #B4473A;
  --rose-soft: #F7DEDA;
  --shadow: 0 1px 2px rgba(60, 40, 25, .06), 0 4px 14px rgba(60, 40, 25, .06);
  --shadow-lg: 0 10px 30px rgba(60, 40, 25, .16);
  --radius: 16px;
  --font: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ── 머리 ── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(244, 239, 230, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 36px; height: 36px; border-radius: 10px; box-shadow: var(--shadow); }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.sync-line { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-line.warn { color: var(--amber); }
.sync-line.ok { color: var(--sage); }
.sync-line.bad { color: var(--rose); }
.top-actions { display: flex; gap: 4px; }
.install-btn { height: 34px; padding: 0 13px; margin: 4px 4px 0 0; border-radius: 17px; background: var(--clay); color: #fff; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2);
}
.icon-btn:hover { background: rgba(0, 0, 0, .04); }
.icon-btn:active { background: rgba(0, 0, 0, .07); }
.sync-btn.spin svg { animation: spin 1s linear infinite; color: var(--clay); }
.badge-dot {
  position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--clay); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 목록 ── */
.layout { flex: 1; display: flex; }
.list-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 16px; }
.search-row {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-top: 4px;
}
.search-row svg { color: var(--muted); width: 19px; height: 19px; }
.search-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15.5px; }
.search-row input::placeholder { color: var(--muted); }
.search-row:focus-within { border-color: var(--clay); box-shadow: 0 0 0 3px var(--clay-soft); }

.chips {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 13px; border-radius: 16px; font-size: 14px; font-weight: 550;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap;
}
.chip .n { color: var(--muted); font-weight: 500; margin-left: 3px; font-size: 13px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on .n { color: rgba(255, 255, 255, .7); }
.chip.tag { color: var(--clay-dark); }
.chip.tag.on { background: var(--clay); border-color: var(--clay); color: #fff; }

.list { padding: 6px 0 calc(120px + var(--safe-b)); }
.day { margin: 18px 2px 8px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.day:first-child { margin-top: 8px; }
.card {
  display: flex; gap: 12px; padding: 14px 15px; margin-bottom: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s ease;
}
.card:active { transform: scale(.985); }
.card.sel { border-color: var(--clay); box-shadow: 0 0 0 3px var(--clay-soft), var(--shadow); }
.card-main { flex: 1; min-width: 0; }
.card h3 {
  margin: 0; font-size: 16px; font-weight: 680; letter-spacing: -.01em; line-height: 1.4;
  display: flex; align-items: center; gap: 6px;
}
.card h3 .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h3 .pin { width: 15px; height: 15px; color: var(--clay); stroke-width: 2.2; }
.card h3.dim .t { color: var(--muted); font-weight: 600; }
.snippet {
  margin: 3px 0 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all;
}
.snippet.dim { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 9px; font-size: 12.5px; color: var(--muted); }
.meta .m { display: inline-flex; align-items: center; gap: 3px; }
.meta svg { width: 14px; height: 14px; stroke-width: 2; }
.thumb { width: 64px; height: 64px; border-radius: 11px; object-fit: cover; background: var(--surface-2); flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.work { background: var(--clay-soft); color: var(--clay-dark); }
.pill.work::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1s ease-in-out infinite; }
.pill.done { background: var(--sage-soft); color: var(--sage); }
.pill.err { background: var(--rose-soft); color: var(--rose); }
.pill.tagp { background: var(--surface-2); color: var(--clay-dark); border: 1px solid var(--line); }
@keyframes blink { 50% { opacity: .25; } }

.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty .big { font-size: 17px; color: var(--ink-2); font-weight: 650; margin-bottom: 6px; }

/* ── 아래 버튼 줄 ── */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 24px calc(10px + var(--safe-b));
  background: rgba(250, 245, 236, .94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.act {
  width: 86px; height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-2); font-size: 12.5px; font-weight: 600;
}
.act:active { background: rgba(0, 0, 0, .05); }
.mic-btn {
  width: 72px; height: 72px; margin-top: -30px; border-radius: 50%;
  background: var(--clay); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(196, 97, 63, .42), 0 0 0 6px var(--bg);
  transition: transform .12s ease, background .12s ease;
}
.mic-btn svg { width: 32px; height: 32px; stroke-width: 2; }
.mic-btn:active { transform: scale(.94); background: var(--clay-dark); }

/* ── 상세 ── */
.detail-pane {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s cubic-bezier(.3, .7, .2, 1);
  visibility: hidden;
}
.detail-pane.open { transform: none; visibility: visible; }
.detail-empty { display: none; }
.d-top {
  display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-t)) 8px 8px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.d-top .spacer { flex: 1; min-width: 0; }
.d-status { font-size: 12.5px; color: var(--muted); padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.on { color: var(--clay); }
.icon-btn.on svg { fill: var(--clay-soft); }
.d-scroll { flex: 1; overflow-y: auto; padding: 16px 18px calc(40px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.d-title {
  width: 100%; border: 0; outline: 0; background: none; padding: 0; margin: 0 0 6px;
  font-size: 22px; font-weight: 750; letter-spacing: -.02em; line-height: 1.35;
}
.d-title::placeholder { color: #BDB3A8; font-weight: 650; }
.d-body {
  width: 100%; min-height: 34vh; border: 0; outline: 0; background: none; padding: 0; resize: none;
  font-size: 17px; line-height: 1.7; color: var(--ink);
}
.d-body::placeholder { color: #BDB3A8; }
.d-when { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }

.section { margin-top: 22px; }
.section-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-h h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }

.ai-box {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.ai-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-msg { font-size: 14px; color: var(--ink-2); flex: 1; min-width: 160px; }
.ai-msg.err { color: var(--rose); }
.raw {
  white-space: pre-wrap; font-size: 14.5px; line-height: 1.65; color: var(--ink-2);
  background: var(--surface-2); border-radius: 10px; padding: 12px; border: 1px dashed var(--line-2);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 15px; border-radius: 12px; font-size: 14.5px; font-weight: 650;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink);
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn.primary:active { background: var(--clay-dark); }
.btn.soft { background: var(--clay-soft); border-color: transparent; color: var(--clay-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--rose); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.todos { display: flex; flex-direction: column; gap: 2px; }
.todo { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.todo input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; border-radius: 7px; flex: none;
  border: 2px solid var(--line-2); background: var(--surface); display: grid; place-content: center; margin: 0;
}
.todo input[type=checkbox]:checked { background: var(--sage); border-color: var(--sage); }
.todo input[type=checkbox]:checked::after {
  content: ""; width: 10px; height: 6px; border: 2.4px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px);
}
.todo .tt { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15.5px; padding: 6px 0; border-bottom: 1px solid transparent; }
.todo .tt:focus { border-bottom-color: var(--line-2); }
.todo.done .tt { text-decoration: line-through; color: var(--muted); }
.todo .x { width: 32px; height: 32px; color: var(--muted); display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.todo .x svg { width: 16px; height: 16px; }
.todo-add { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.todo-add input { flex: 1; border: 0; outline: 0; background: none; font-size: 15px; padding: 8px 0; border-bottom: 1px dashed var(--line-2); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 11px; border-radius: 15px; background: var(--clay-soft); color: var(--clay-dark); font-size: 14px; font-weight: 600; }
.tag-chip button { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--clay-dark); border-radius: 12px; }
.tag-chip svg { width: 14px; height: 14px; }
.tag-input { border: 0; outline: 0; background: none; font-size: 14.5px; padding: 4px 2px; min-width: 110px; flex: 1; }

.attach { display: flex; flex-direction: column; gap: 10px; }
.audio-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.audio-row audio { flex: 1; min-width: 0; height: 40px; }
.audio-row .dur { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 14px; background: rgba(42, 37, 34, .55); color: #fff; display: flex; align-items: center; justify-content: center; }
.photos .ph button svg { width: 14px; height: 14px; }
.ph-add { aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed var(--line-2); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; }

.trash-bar { display: flex; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--amber-soft); color: var(--amber); align-items: center; margin-bottom: 14px; font-size: 14px; }
.trash-bar span { flex: 1; }

/* ── 녹음 화면 ── */
.rec-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(244, 239, 230, .97);
  display: flex; align-items: center; justify-content: center;
  padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b));
}
.rec-inner { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.rec-mode { margin: 0 0 18px; font-size: 14px; font-weight: 700; color: var(--clay-dark); letter-spacing: .04em; display: flex; align-items: center; gap: 7px; }
.rec-mode::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--clay); animation: blink 1.1s ease-in-out infinite; }
.rec-orb-wrap { width: 220px; height: 220px; display: flex; align-items: center; justify-content: center; }
.rec-orb {
  --lvl: 0;
  width: 132px; height: 132px; border-radius: 50%; background: var(--clay); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 calc(10px + var(--lvl) * 44px) rgba(196, 97, 63, .16), 0 0 0 calc(20px + var(--lvl) * 70px) rgba(196, 97, 63, .08);
  transform: scale(calc(1 + var(--lvl) * .08)); transition: box-shadow .08s linear, transform .08s linear;
}
.rec-orb svg { width: 52px; height: 52px; stroke-width: 1.8; }
.rec-time { margin: 22px 0 4px; font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rec-hint { margin: 0; color: var(--muted); font-size: 15px; }
.rec-live { margin-top: 18px; width: 100%; max-height: 28vh; overflow-y: auto; text-align: left; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 16px; line-height: 1.6; }
.rec-live .interim { color: var(--muted); }
.rec-actions { display: flex; gap: 12px; margin-top: 34px; width: 100%; }
.rec-actions .btn { flex: 1; height: 56px; font-size: 17px; border-radius: 16px; }
.rec-stop .sq { width: 14px; height: 14px; border-radius: 3px; background: #fff; }

/* ── 설정 시트 ── */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(42, 37, 34, .32); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  animation: up .22s cubic-bezier(.3, .7, .2, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 750; }
.sheet-body { overflow-y: auto; padding: 4px 20px calc(26px + var(--safe-b)); }
.group { margin-top: 18px; }
.group > h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; }
.row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .lbl { flex: 1; min-width: 0; }
.lbl b { display: block; font-weight: 600; font-size: 15px; }
.lbl small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 1px; }
.row input[type=password], .row input[type=text] {
  width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: var(--bg); outline: 0;
}
.row input:focus { border-color: var(--clay); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--line-2); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + span { background: var(--sage); }
.switch input:checked + span::after { transform: translateX(20px); }
.radio { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.radio:last-child { border-bottom: 0; }
.radio input { accent-color: var(--clay); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); }
.conn.ok .dot { background: var(--sage); }
.conn.bad .dot { background: var(--rose); }
.help { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 8px 2px 0; }
.help code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; }

/* ── 사진 크게 보기 · 알림 ── */
.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(20, 16, 14, .92); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-close { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; color: #fff; }
.toast {
  position: fixed; left: 50%; bottom: calc(108px + var(--safe-b)); transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 14.5px; box-shadow: var(--shadow-lg);
  animation: up .18s ease;
}
.toast button { color: #F2B79F; font-weight: 700; white-space: nowrap; }

/* ── PC: 왼쪽 목록 + 오른쪽 편집 ── */
@media (min-width: 900px) {
  .top { padding-left: 24px; padding-right: 24px; }
  .app { height: 100dvh; }
  .layout { min-height: 0; }
  .list-pane { flex: none; width: 400px; padding: 0 16px 0 24px; overflow: hidden; border-right: 1px solid var(--line); }
  .list { flex: 1; overflow-y: auto; padding-bottom: 110px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
  .chips { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; }
  .action-bar { position: absolute; left: auto; right: auto; width: 400px; bottom: 0; padding: 10px 24px 14px; }
  .list-pane { position: relative; }
  .detail-pane { position: static; transform: none; visibility: visible; flex: 1; min-width: 0; transition: none; background: var(--surface); }
  .detail-empty { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 10px; }
  .detail-empty img { width: 64px; height: 64px; border-radius: 16px; opacity: .85; }
  .d-top { background: var(--surface); padding: 10px 18px; }
  .d-top .back { display: none; }
  .d-scroll { padding: 26px 48px 60px; max-width: 860px; width: 100%; margin: 0 auto; }
  .d-title { font-size: 26px; }
  .toast { bottom: 28px; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 22px; }
}
