:root {
  --bg: #0b0a12;
  --text: #eceaf3;
  --muted: #a5a1b8;
  --line: rgba(255,255,255,.10);
  --glass: rgba(255,255,255,.055);
  --glass-hi: rgba(255,255,255,.10);
  --primary: #8a5cff;
  --primary-soft: rgba(138,92,255,.20);
  --accent: #6ee7f2;
  --on-primary: #ffffff;
  --error: #ff8a8a;
  --sidebar-w: 244px;
  --detail-w: 400px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ── 배경 (홈페이지와 같은 오로라) ── */
.aurora { position: fixed; inset: -20% -10%; z-index: -2; filter: blur(72px); opacity: .62; pointer-events: none; }
.aurora span { position: absolute; display: block; border-radius: 50%; mix-blend-mode: screen; animation: drift 24s ease-in-out infinite alternate; }
.aurora span:nth-child(1) { width: 46vw; height: 46vw; left: 2%;  top: 0%;   background: #7b3ff2; }
.aurora span:nth-child(2) { width: 38vw; height: 38vw; right: 4%; top: 10%;  background: #2f7cf6; animation-delay: -6s; }
.aurora span:nth-child(3) { width: 34vw; height: 34vw; left: 24%; bottom: 0%; background: #17b8a6; animation-delay: -12s; }
.aurora span:nth-child(4) { width: 24vw; height: 24vw; right: 18%; bottom: 4%; background: #e0479e; animation-delay: -3s; opacity: .7; }
@keyframes drift { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(4vw,-4vh,0) scale(1.16); } }

.grid-overlay {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 25%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 25%, #000 40%, transparent 100%);
  opacity: .45;
}
@media (prefers-reduced-motion: reduce) { .aurora span { animation: none; } }

/* ── 로그인 · 금고 ── */

.center-view {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.card.glass {
  padding: 34px 28px 30px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}

.lock-badge {
  align-self: center;
  width: 62px; height: 62px;
  display: grid; place-items: center;
  font-size: 28px;
  border-radius: 20px;
  background: linear-gradient(140deg, #8a5cff, #4527a0);
  box-shadow: 0 10px 26px rgba(90,40,200,.45);
}

.brand {
  margin: 6px 0 0;
  text-align: center;
  font-size: 32px; font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(100deg, #c9b7ff 0%, #6ee7f2 60%, #c9b7ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { margin-top: -6px; letter-spacing: .08em; }

.vault-owner {
  margin: -6px 0 0;
  font-size: 16px; font-weight: 700;
  color: #ded5ff;
}
.vault-owner .who {
  display: inline-block;
  padding: 5px 12px; margin-right: 4px;
  background: var(--primary-soft);
  border: 1px solid rgba(138,92,255,.35);
  border-radius: 999px;
}
.center-btn { align-self: center; margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.check-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; color: var(--muted);
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.field > span { font-size: 13px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  padding: 13px 15px;
  font-size: 16px; /* 16px 미만이면 iOS가 확대한다 */
  font-family: inherit;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 12px;
}
input::placeholder, textarea::placeholder { color: #7d7a8c; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(138,92,255,.75);
  box-shadow: 0 0 0 3px rgba(138,92,255,.18);
}
textarea { resize: vertical; }
select option { background: #1a1822; color: var(--text); }

button { font-size: 16px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; }
button:disabled { opacity: .45; cursor: default; }

.primary {
  padding: 14px; border-radius: 999px;
  color: var(--on-primary);
  background: linear-gradient(100deg, #8a5cff, #5b32d6);
  box-shadow: 0 10px 24px rgba(90,40,200,.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(90,40,200,.5); }
.secondary { padding: 12px 18px; border-radius: 999px; background: var(--glass-hi); color: var(--text); border: 1px solid var(--line); }
.link-btn { padding: 7px 12px; font-size: 14px; background: none; color: #c8bcff; border-radius: 10px; }
.link-btn:hover { background: var(--glass-hi); }
.link-btn.danger { color: var(--error); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  font-size: 17px; background: none; color: var(--text); border-radius: 999px;
}
.icon-btn:hover { background: var(--glass-hi); }

/* 홈으로 (topbar 오른쪽 끝) */
.home-btn {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; color: #c8bcff;
}
.home-btn svg { width: 20px; height: 20px; fill: currentColor; }

.error { margin: 0; color: var(--error); font-size: 14px; }
.muted { margin: 0; color: var(--muted); font-size: 14px; }
.center-text { text-align: center; line-height: 1.55; }

/* ── 메인 ── */

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

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(11,10,18,.62);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.app-title {
  margin: 0; font-size: 20px; font-weight: 800; white-space: nowrap;
  background: linear-gradient(100deg, #c9b7ff, #6ee7f2);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.search { flex: 1; min-width: 0; max-width: 460px; }

.body-grid { flex: 1; display: flex; min-height: 0; position: relative; }

/* 구분 */
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  padding: 14px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.cat-nav { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cat-item {
  padding: 12px 15px;
  font-size: 15px; text-align: left;
  background: none; color: var(--text);
  border-radius: 12px; width: 100%;
  transition: background .15s ease;
}
.cat-item:hover { background: var(--glass-hi); }
.cat-item.active {
  font-weight: 700;
  color: #fff;
  background: linear-gradient(100deg, rgba(138,92,255,.45), rgba(110,231,242,.18));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.manage-btn { margin-top: 10px; text-align: left; }

/* 목록 */
.list-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 0 12px; }
/* 좌측 트리 (바인더 > 그룹) */
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 12px 9px 6px;
  border-radius: 10px; cursor: pointer;
  color: var(--text); font-size: 15px;
}
.tree-row:hover { background: var(--glass); }
.tree-row.active { background: var(--primary-soft); }
.tree-row.child { padding-left: 22px; font-size: 14px; color: var(--muted); }
.tree-row.child.active { color: var(--text); }

.tree-caret {
  width: 22px; height: 22px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted);
  background: none; border: none; border-radius: 6px; cursor: pointer;
}
.tree-caret:hover { background: var(--glass-hi); color: var(--text); }
.tree-caret.placeholder { cursor: default; }

.tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { flex: none; font-size: 12px; color: var(--muted); }

/* 알림 (한 노트에 여러 개) */
.reminder-count {
  flex: none;
  font-size: 12px; color: #ffd79a;
  padding: 2px 8px; border-radius: 999px; background: rgba(255,183,77,.16);
}
.reminder-count.all-done { color: var(--muted); background: var(--glass-hi); }

.reminder-row {
  margin-bottom: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--glass);
}
.reminder-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.reminder-head input { flex: 1; }
/* 예정일·시간·반복·알림 시점을 한 줄에. 좁은 화면에서는 두 칸씩 접는다 */
.reminder-grid { display: grid; grid-template-columns: 1.2fr 0.9fr 1fr 1fr; gap: 8px; }
.reminder-grid .field { min-width: 0; }
.reminder-grid .field span { font-size: 12px; }
.reminder-grid input, .reminder-grid select { min-width: 0; padding: 8px 8px; font-size: 13.5px; }
@media (max-width: 900px) {
  .reminder-grid { grid-template-columns: 1fr 1fr; }
}

/* 펼친 노트 안의 알림 줄 */
.reminder-line {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding: 8px 10px;
  border-radius: 10px; background: var(--glass);
}
.reminder-line.done .reminder-text { text-decoration: line-through; opacity: .55; }
.reminder-text { flex: 1; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.reminder-left { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* 성격 필터 (전체 / 할일 / 시크릿) */
.filter-row { display: flex; gap: 8px; padding: 12px 6px 0; }
.chip-btn {
  padding: 6px 14px; font-size: 13px; border-radius: 999px;
  color: var(--muted); background: var(--glass); border: 1px solid var(--line);
}
.chip-btn.active { color: var(--text); background: var(--primary-soft); border-color: rgba(138,92,255,.5); }

/* 할일 / 시크릿 토글 */
.kind-row { display: flex; gap: 10px; }
.kind-check {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  color: var(--muted); background: var(--glass); border: 1px solid var(--line);
}
.kind-check input { width: auto; margin: 0; accent-color: var(--primary); }
.kind-check:has(input:checked) { color: var(--text); background: var(--primary-soft); border-color: rgba(138,92,255,.5); }
.kind-hint { font-size: 12.5px; margin-top: -4px; }
.field-hint {
  font-size: 12px; color: var(--muted);
  margin: 2px 0 0; line-height: 1.5;
  overflow-wrap: anywhere;
}

/* 날짜·시간 입력을 어두운 테마에 맞춘다 (브라우저 기본 위젯이 흰 바탕으로 뜨는 것 방지) */
input[type="date"], input[type="time"] {
  color-scheme: dark;
  cursor: pointer;
  background: var(--glass-hi);
}
input[type="date"]:hover, input[type="time"]:hover { border-color: rgba(138,92,255,.6); }

/* 달력·시계 아이콘: 기본값이 너무 흐려 눌러야 하는 자리인지 안 보인다.
   ※ filter가 배경까지 반전시키므로 배경색은 주지 않는다 (색이 뒤집혀 이상해진다) */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.6);
  opacity: 1;
  cursor: pointer;
  margin-left: 4px;
  transform: scale(1.25);
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(1) brightness(2.2);
}

/* 사이드바 기본 알림 시간 */
.pref-row { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.pref-row span { font-size: 13px; color: var(--muted); }
.pref-row input, .pref-row select { width: auto; flex: 1; padding: 8px 10px; font-size: 14px; }
.binder-row { padding-top: 14px; }
.binder-row span { flex: none; }

.row-count { flex: none; font-size: 12px; color: var(--muted); margin-right: 4px; }

/* 관리 화면에서 고를 수 있는 줄 (바인더) */
.cat-manage-item.selectable { cursor: pointer; }
.cat-manage-item.selectable:hover { background: var(--glass); }
.cat-manage-item.selectable.active {
  background: var(--primary-soft);
  border-color: rgba(138,92,255,.45);
}

/* 그룹 관리 줄 안의 바인더 선택 */
.row-select {
  width: auto; max-width: 150px; flex: none;
  padding: 6px 8px; font-size: 13px; border-radius: 8px;
}
.two-col { display: flex; gap: 12px; }
.two-col .field { flex: 1; min-width: 0; }

/* 할일 완료 체크 */
.todo-check {
  flex: none; width: 26px; height: 26px; margin-right: 4px;
  border-radius: 8px; font-size: 14px; line-height: 1;
  color: var(--text); background: transparent; border: 1.5px solid var(--line);
}
.todo-check.on { background: rgba(106,220,145,.25); border-color: rgba(106,220,145,.6); }
.list-item.done .item-title { text-decoration: line-through; opacity: .55; }
.list-item.done .item-sub { opacity: .55; }

/* 예정일 배지 */
.item-date.due { padding: 2px 9px; border-radius: 999px; background: var(--glass-hi); }
.item-date.due.soon { color: #ffd79a; background: rgba(255,183,77,.18); }
.item-date.due.over { color: #ffb0b0; background: rgba(255,105,105,.20); }

.list-info { padding: 0; }
.list-head { display: flex; align-items: center; gap: 10px; padding: 14px 6px 10px; }
.add-btn { margin-left: auto; flex: none; padding: 7px 14px; font-size: 13.5px; }
.sort-select {
  width: auto; flex: none;
  padding: 7px 10px; font-size: 13px; border-radius: 10px;
  color: var(--text); background: var(--glass); border: 1px solid var(--line);
}
.list { margin: 0; padding: 0 0 90px; list-style: none; display: flex; flex-direction: column; gap: 8px; }

.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--glass);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.list-item:hover { transform: translateY(-2px); background: var(--glass-hi); border-color: rgba(255,255,255,.2); }
.list-item.selected {
  border-color: rgba(138,92,255,.6);
  background: linear-gradient(100deg, rgba(138,92,255,.22), rgba(110,231,242,.08));
}
.item-main { flex: 1; min-width: 0; }
.item-title-row { display: flex; align-items: baseline; gap: 10px; }
/* 제목은 필요한 만큼만 차지하고, 날짜는 auto 여백으로 오른쪽 끝에 붙는다.
   그래야 알림 개수가 제목 바로 뒤에 오면서도 제목을 밀지 않는다. */
.item-title { flex: 0 1 auto; min-width: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.item-date { flex: none; margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.item-sub { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }

/* 노트 배경색 (색 이름 → 은은한 틴트) */
[data-color="red"]    { --tint: 255,105,105; }
[data-color="amber"]  { --tint: 255,183,77;  }
[data-color="green"]  { --tint: 106,220,145; }
[data-color="teal"]   { --tint: 94,220,220;  }
[data-color="blue"]   { --tint: 105,165,255; }
[data-color="violet"] { --tint: 170,125,255; }
[data-color="pink"]   { --tint: 255,125,190; }
[data-color="gray"]   { --tint: 190,190,205; }

.list-item[data-color] {
  background: rgba(var(--tint), .15);
  border-color: rgba(var(--tint), .38);
}
.list-item[data-color]:hover { background: rgba(var(--tint), .22); }
.list-item[data-color].selected { border-color: rgba(138,92,255,.75); box-shadow: 0 0 0 2px rgba(138,92,255,.32); }
.detail-pane[data-color] { background: linear-gradient(180deg, rgba(var(--tint), .16), rgba(16,14,24,.9) 220px), rgba(16,14,24,.86); }

/* 색 고르기 */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 999px;
  background: rgba(var(--tint, 255,255,255), .34);
  border: 1px solid rgba(var(--tint, 255,255,255), .55);
  transition: transform .12s ease;
}
.swatch:not([data-color]) { background: var(--glass); border: 1px dashed rgba(255,255,255,.35); }
.swatch:hover { transform: translateY(-2px); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255,255,255,.75); }

.chip {
  padding: 5px 11px; font-size: 12px; white-space: nowrap;
  color: #ded5ff;
  background: var(--primary-soft);
  border: 1px solid rgba(138,92,255,.35);
  border-radius: 999px;
}

/* 상세 · 편집 · 구분 관리 패널 */
.detail-pane {
  width: var(--detail-w); flex: none;
  display: flex; flex-direction: column;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: rgba(16,14,24,.86);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.detail-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px;
  background: rgba(16,14,24,.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.detail-head h2 { flex: 1; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.detail-body { padding: 18px; display: flex; flex-direction: column; gap: 20px; }

.detail-section > h3 {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.value-row {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.value-text {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; overflow-wrap: anywhere;
}
.cred-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.cred-label { font-size: 12px; color: var(--muted); }
.memo-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.detail-body a { color: #9fd8ff; overflow-wrap: anywhere; }

/* 편집 */
.cred-edit {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.cred-edit .inputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.url-row { display: flex; align-items: center; gap: 6px; }
.url-row input { flex: 1; min-width: 0; }

/* 구분 관리 */
.cat-add-row { display: flex; gap: 8px; }
.cat-add-row input { flex: 1; min-width: 0; }
.cat-manage-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cat-manage-item {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 6px 8px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.cat-manage-item .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* 좁은 화면 */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 8; }
.only-narrow { display: none; }

@media (max-width: 820px) {
  .only-narrow { display: inline-flex; }
  .only-wide { display: none; }
  .app-title { display: none; }

  .sidebar {
    position: absolute; inset: 0 auto 0 0; z-index: 9;
    background: rgba(16,14,24,.94);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 0 40px rgba(0,0,0,.5);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }

  .detail-pane { position: absolute; inset: 0; width: auto; z-index: 10; border-left: none; }
}

/* 추가 버튼 */
.fab {
  position: fixed;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 15;
  width: 58px; height: 58px;
  font-size: 28px; line-height: 1;
  color: var(--on-primary);
  background: linear-gradient(140deg, #8a5cff, #4527a0);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(90,40,200,.5);
  transition: transform .15s ease;
}
.fab:hover { transform: translateY(-2px) scale(1.03); }

/* 알림 */
.toast {
  position: fixed;
  left: 50%; bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  padding: 12px 20px;
  font-size: 14px; color: #fff;
  background: linear-gradient(100deg, #8a5cff, #5b32d6);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
}

/* ── NotePark 추가 ── */
.btn-link { display: block; text-align: center; text-decoration: none; }
/* 본문 칸은 남는 높이를 채우되, 자기 최소 높이보다 작게 눌리지는 않는다.
   눌리면 textarea가 상자 밖으로 삐져나와 아래 칸(첨부·작성일)을 덮어썼다. */
.field.grow { flex: 1 1 auto; }
.field.grow textarea {
  min-height: 320px;
  line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, Menlo, "Malgun Gothic", monospace;
}
/* 내용이 길면 줄이지 말고 패널이 스크롤되게 둔다 */
.detail-body { flex: 1 0 auto; }

/* 편집·상세 패널이 열려 있으면 + 버튼을 숨긴다 (저장 버튼과 헷갈리지 않게) */
body.panel-open .fab { display: none; }

/* 높이는 min-height가 정하고, 더 필요하면 사용자가 아래 모서리를 끌어 늘린다.
   height:100%는 부모가 눌렸을 때 함께 어긋나서 쓰지 않는다. */

/* 목록에서 펼쳐 읽기 — 완료 체크는 왼쪽에 두고 나머지는 아래로 쌓는다 */
.list-item.stack {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 8px;
}
.list-item.stack > * { grid-column: 2; }
.list-item.stack > .todo-check { grid-column: 1; grid-row: 1; }
.list-item.stack > .chip { justify-self: start; margin: 8px 0 0; }
.list-item.expanded {
  border-color: rgba(138,92,255,.5);
  cursor: default;
}
/* 펼친 노트의 머리말(제목 줄 + 그룹 칩) = 접는 자리.
   마우스를 올리면 접히는 범위 전체가 함께 밝아진다 */
.item-main.foldable {
  cursor: pointer;
  margin: -6px -8px 0;
  padding: 6px 8px 8px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line);
}
.item-main.foldable:hover { background: var(--glass-hi); }
.item-main.foldable:hover .fold-hint { color: var(--text); }
.item-main.foldable > .chip { display: inline-block; margin-top: 8px; }
.fold-hint {
  flex: none; margin-left: 10px;
  font-size: 12px; color: #c8bcff; white-space: nowrap;
}

.item-body {
  margin-top: 12px;
  cursor: text;
  user-select: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
}
/* 메타와 버튼 줄도 누르면 접힌다 (버튼 자체는 제외) */
.item-meta { margin-top: 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.item-actions {
  display: flex; align-items: center; gap: 4px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.item-actions .fold-hint { margin-left: 0; margin-right: auto; }
/* 펼친 노트 머리말의 버튼 줄 — 그룹 칩과 한 줄, 접기 바로 아래 */
.item-actions.top {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px; padding-top: 0;
  border-top: none;
}
.item-actions.top > .chip { margin-right: auto; }
.item-actions.top { margin-bottom: 4px; }

/* ★목록 안의 버튼은 폼 버튼과 같은 크기면 안 된다.
   .secondary 는 원래 '저장' 같은 큰 버튼용(12px 18px / 16px)이라
   좀은 줄에 그대로 놓으면 줄을 잡아먹고 아래 칸과 겹쳐 보인다. */
.item-actions .secondary { padding: 6px 14px; font-size: 13.5px; }
.item-actions .link-btn { padding: 6px 10px; font-size: 13.5px; }
.item-actions:hover .fold-hint, .item-meta:hover { color: var(--text); }

/* 금고 열기 오버레이 (시크릿 노트를 열거나 저장하려는 순간에만 뜬다) */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(6, 10, 14, .72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.unlock-card { width: min(380px, 100%); gap: 14px; }
.unlock-card h2 { margin: 0; font-size: 20px; }
.unlock-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

/* 첨부 파일 */
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--glass);
  font-size: 13.5px;
}
.file-row .file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-row .file-size { flex: none; font-size: 12px; color: var(--muted); }
.file-row.pending .file-name { color: var(--muted); font-style: italic; }
.file-hint { margin: 6px 0 0; font-size: 12px; }

/* 펼친 노트 안의 첨부 */
.item-files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--glass);
  color: #c8bcff; text-decoration: none; font-size: 13.5px;
  cursor: pointer;
}
.file-link:hover { background: var(--glass-hi); }

/* 첨부 줄: 이름을 누르면 열고, ⬇ 를 누르면 내려받는다 */
.file-link .file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-link .icon-btn { flex: none; padding: 2px 6px; font-size: 14px; }

/* 목록 안에서 바로 편집 — 오른쪽 패널을 그 노트 자리로 옮겨 쓴다 */
.detail-pane.inline {
  width: auto;
  margin: 10px -4px 0;
  border-left: none;
  border-top: 1px solid var(--line);
  background: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  overflow: visible;
}
.detail-pane.inline .detail-body { padding: 14px 0 0; }
.detail-pane.inline .detail-head {
  position: static;
  padding: 12px 0 0;
  background: none;
  border-bottom: none;
}
/* 편집 중인 줄은 접기 동작을 막는다 (실수로 닫히면 쓰던 것이 사라진 것처럼 보인다) */
.list-item.editing { cursor: default; }
.list-item.editing .item-main { cursor: default; }

/* 편집 머리 줄: 할일·시크릿 옆에 배경색, 바인더·그룹 옆에 제목 */
.kind-row { flex-wrap: wrap; }
.kind-row .color-picker { margin-left: auto; gap: 6px; }
.kind-row .color-picker .swatch { width: 24px; height: 24px; }
.head-row { flex-wrap: wrap; align-items: flex-end; }
.head-row .field { min-width: 130px; }
/* 제목은 남는 폭을 다 쓰고, 좁아지면 아래로 내려간다 */
.head-row .title-field { flex: 2 1 240px; }

/* 닫기(✕)는 줄 오른쪽 끝에, 누르기 쉽게 크게 */
.detail-head .close-btn {
  margin-left: 6px;
  width: 44px; height: 44px;
  font-size: 18px; line-height: 1;
  border-radius: 12px;
}
.detail-head .close-btn:hover { background: var(--glass-hi); }

/* 본문 편집 — 글쓰기 칸 대신 직접 편집 영역 (형광펜을 그 자리에서 보여준다) */
.body-edit {
  min-height: 320px;
  padding: 12px 14px;
  line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, "Malgun Gothic", monospace;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--line); border-radius: 12px;
  outline: none;
}
.body-edit:focus { border-color: rgba(138,92,255,.6); background: var(--glass-hi); }

/* 형광펜 — 어두운 바탕에서 글자가 묻히지 않는 톤 */
mark.hl { padding: 0 2px; border-radius: 3px; color: #14121c; }
mark.hl[data-hl="y"] { background: #ffe066; }
mark.hl[data-hl="g"] { background: #8ce99a; }
mark.hl[data-hl="p"] { background: #ffa8c5; }
.item-body mark.hl, .body-edit mark.hl { color: #14121c; }

/* 고른 글자 위에 뜨는 도구모음 */
.format-bar {
  position: absolute; z-index: 70;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(24,20,34,.96);
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
.format-bar[hidden] { display: none; }
.format-bar .hl-btn {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid rgba(255,255,255,.25); border-radius: 50%;
  cursor: pointer;
}
.format-bar .hl-btn[data-hl="y"] { background: #ffe066; }
.format-bar .hl-btn[data-hl="g"] { background: #8ce99a; }
.format-bar .hl-btn[data-hl="p"] { background: #ffa8c5; }
.format-bar .fmt-btn {
  min-width: 26px; height: 24px; padding: 0 6px;
  font-weight: 700; color: var(--text);
  background: var(--glass); border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer;
}
.format-bar .fmt-btn:hover { background: var(--glass-hi); }

/* 본문 아래 '평문으로' — 눈에 띌 필요는 없지만 찾을 수는 있어야 한다 */
.plain-btn { align-self: flex-start; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.plain-btn:hover { color: var(--text); }

/* 길게 누르는 동안 "뭔가 되고 있다"는 신호 */
.item-body.holding {
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  transition: background .8s ease;
}

/* '+ 할일' — 체크박스 대신 누를 때마다 알림이 한 줄 늘어난다 */
.add-todo {
  padding: 8px 14px;
  font-family: inherit; font-size: 14px;
  color: #c8bcff;
  background: var(--glass);
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer;
}
.add-todo:hover { background: var(--glass-hi); border-color: rgba(138,92,255,.5); }

/* 알림 줄의 종 — 누르면 그 알림의 알람이 켜지고 꺼진다 */
.bell-btn {
  flex: none;
  padding: 2px 6px;
  font-size: 15px; line-height: 1;
  background: none; border: none; border-radius: 8px;
  cursor: pointer;
}
.bell-btn:hover { background: var(--glass-hi); }
.bell-btn.off { opacity: .55; }
.reminder-line.muted .reminder-text,
.reminder-line.muted .reminder-left { color: var(--muted); }


/* ══════════════════════════════════════════════════════
   PassPark 전용 (공통 부분은 위쪽 — NotePark과 같은 뼈대)
   ══════════════════════════════════════════════════════ */

/* 펼친 항목: NotePark은 완료 체크 칸이 있어 grid지만 PassPark은 그냥 쌓는다 */
.list-item.stack { display: block; }
.list-item.stack > * { grid-column: auto; }
.list-item.stack .item-main > .chip { display: inline-block; margin-top: 8px; }

/* 펼쳤을 때 보이는 내용 (아이디/비밀번호 · 메모 · URL) */
.item-detail { margin-top: 10px; }
.item-detail .value-text { user-select: text; }

/* 잠긴 비밀번호 줄 — 누르면 그 자리에서 금고를 연다 */
.locked-row { display: flex; align-items: center; gap: 10px; }
.locked-row .value-text { color: var(--muted); letter-spacing: .18em; }

/* 비밀번호는 글자를 구분하기 쉽게 고정폭으로 (금고를 열면 그대로 보인다) */
.value-text.secret {
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  letter-spacing: .02em;
  word-break: break-all;
}

/* 펼친 항목의 '▲ 접기'는 제목 줄 오른쪽 끝에.
   (NotePark은 제목 옆에 알림 개수·날짜가 와서 규칙이 다르다) */
.item-title-row .fold-hint { margin-left: auto; }

/* 여러 개 고르기 (카드를 길게 누르면 시작) */
.select-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 10px;
  border: 1px solid rgba(138,92,255,.45); border-radius: 14px;
  background: rgba(24,20,34,.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.select-bar[hidden] { display: none; }
.sel-count { flex: 1; font-size: 14px; font-weight: 600; }
.sel-category { max-width: 150px; padding: 7px 8px; font-size: 13px; }

/* 고르는 중에만 앞에 나타나는 체크 */
.sel-check {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 13px; line-height: 1;
  color: transparent;
  border: 1.5px solid var(--line); border-radius: 7px;
  background: var(--glass);
}
.list-item.picked { border-color: rgba(138,92,255,.65); background: var(--primary-soft); }
.list-item.picked .sel-check { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }

/* 길게 누르는 동안 "뭔가 되고 있다"는 신호 */
.list-item.holding { background: var(--glass-hi); }


/* ── 오프라인 (서버에 못 닿을 때 받아 둔 사본으로 보는 중) ───────────── */
.offline-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  background: var(--glass-hi, rgba(255,255,255,.06));
  border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.offline-bar span { flex: 1; }
.offline-bar .link-btn { font-size: 12px; padding: 2px 6px; }

/* 오프라인에서는 만들 수 없으니 아예 감춘다 */
body.offline #addBtn { display: none; }
