/* === Generic === */
.h1 { font-size: var(--t-2xl); font-weight: 800; margin: 0 0 var(--sp-2); }
.h2 { font-size: var(--t-xl); font-weight: 700; margin: 0 0 var(--sp-2); }
.h3 { font-size: var(--t-lg); font-weight: 700; margin: 0; }
.sub { color: var(--c-text-soft); font-size: var(--t-sm); }
.muted { color: var(--c-text-mute); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }
.good { color: var(--c-good); }
.bad { color: var(--c-bad); }
.warn { color: var(--c-warn); }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }

.section { margin-bottom: var(--sp-5); }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--sp-4); flex-wrap: wrap; gap: var(--sp-3);
}

/* === Card === */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-3);
  padding: var(--sp-5);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.card-body { display: flex; flex-direction: column; gap: var(--sp-3); }

/* === Grid === */
.grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(12, 1fr);
}
.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-5  { grid-column: span 5; }
.span-6  { grid-column: span 6; }
.span-7  { grid-column: span 7; }
.span-8  { grid-column: span 8; }
.span-12 { grid-column: span 12; }
@media (max-width: 960px) {
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}

/* === Chip === */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  font-size: var(--t-xs);
  color: var(--c-text-soft);
}
.chip.primary { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }
.chip.good { background: rgba(22,163,74,.10); color: var(--c-good); border-color: transparent; }
.chip.bad { background: rgba(220,38,38,.10); color: var(--c-bad); border-color: transparent; }
.chip.warn { background: rgba(217,119,6,.10); color: var(--c-warn); border-color: transparent; }
.chip-young { background: rgba(79,124,255,.12); color: var(--c-young); border-color: transparent; }
.chip-yuri  { background: rgba(240,98,146,.12); color: var(--c-yuri);  border-color: transparent; }
.chip-seo   { background: rgba(22,163,74,.12); color: var(--c-seo);   border-color: transparent; }
.chip-minki { background: rgba(155,89,182,.12); color: var(--c-minki); border-color: transparent; }

/* === Btn === */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-2);
  padding: 8px 14px;
  font-size: var(--t-sm);
  color: var(--c-text);
}
.btn:hover { background: var(--c-line); }
.btn.primary { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-hover, #2bb77a); }
.btn.ghost { background: transparent; }

/* === KPI === */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-text-soft); font-size: var(--t-sm); }
.kpi-value { font-size: var(--t-3xl); font-weight: 800; line-height: 1.1; }
.kpi-delta { font-size: var(--t-xs); }

/* === Tabs === */
.itab {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--c-surface-2); border-radius: var(--r-2);
}
.itab button {
  background: transparent; border: none;
  padding: 6px 12px; border-radius: 8px;
  font-size: var(--t-sm); color: var(--c-text-soft);
}
.itab button.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-1); font-weight: 600; }

/* === Rank list === */
.rank-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.rank-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  /* left corners square per DESIGN-RULES.md §2 */
  border-radius: 0 var(--r-2) var(--r-2) 0;
  border: 1px solid transparent;
}
.rank-row:hover { background: var(--c-surface-2); }
.rank-name { font-weight: 600; }
.rank-bar {
  flex: 0 0 80px; height: 6px;
  background: var(--c-line); border-radius: 3px; overflow: hidden;
}
.rank-bar > i { display: block; height: 100%; background: var(--c-primary); }

/* === Table === */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tbl thead th {
  text-align: left; padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-line);
  color: var(--c-text-soft); font-weight: 600;
}
.tbl tbody td {
  padding: var(--sp-3);
  border-bottom: 1px dashed var(--c-line);
}
.tbl tbody tr:hover { background: var(--c-surface-2); }

/* === Progress === */
.progress {
  height: 8px; background: var(--c-line);
  border-radius: 4px; overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--c-primary); transition: width 0.3s; }

/* === D-Day big === */
.dday {
  display: inline-flex; flex-direction: column; align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-2);
  background: var(--c-primary-soft);
}
.dday .dday-num { font-family: var(--f-num); font-size: var(--t-2xl); font-weight: 800; color: var(--c-primary); }
.dday .dday-label { font-size: var(--t-xs); color: var(--c-text-soft); }

/* === Checklist === */
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.checklist li {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--c-line);
  /* left corners square per DESIGN-RULES.md §2 */
  border-radius: 0 var(--r-2) var(--r-2) 0;
}
.checklist li.done { background: var(--c-surface-2); }
.checklist li.done .ck-item { text-decoration: line-through; color: var(--c-text-mute); }
.ck-mark {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1.5px solid var(--c-line);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 18px; margin-top: 2px;
}
.checklist li.done .ck-mark { background: var(--c-good); border-color: var(--c-good); color: white; }
.ck-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* === Empty === */
.empty {
  padding: var(--sp-6);
  text-align: center;
  color: var(--c-text-mute);
  border: 1px dashed var(--c-line);
  border-radius: var(--r-2);
}
.empty strong { display: block; color: var(--c-text-soft); margin-bottom: 6px; }

/* === Photo grid (views/photos.js) === */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.photo-cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--r-2);
  background: var(--c-bg);
  border: 1px solid var(--c-line);
}
.photo-cell img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.photo-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
  color: white;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
}
.drop-active {
  outline: 2px dashed var(--c-cool);
  outline-offset: -6px;
  background: color-mix(in srgb, var(--c-cool) 5%, transparent);
}
.chip-active {
  background: var(--c-cool);
  color: white;
}

/* === Input (identity editor) === */
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-2);
  background: var(--c-bg);
  color: var(--c-text);
  font-family: inherit;
  font-size: inherit;
  box-sizing: border-box;
}
.input:focus { outline: none; border-color: var(--c-cool); }
textarea.input { resize: vertical; min-height: 60px; }

.btn.small { padding: 4px 8px; font-size: var(--t-sm); }
.btn.danger { background: var(--c-bad); color: white; border-color: var(--c-bad); }
.rank-row.active { background: color-mix(in srgb, var(--c-cool) 10%, transparent); border-left: 3px solid var(--c-cool); }

/* =============================================================
   Cabinet — 계약·서류 캐비닛
   ============================================================= */
.cabinet-page { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }

.cabinet-hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-3);
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--hero, var(--c-primary)) 18%, var(--c-surface)) 0%,
              var(--c-surface) 100%);
  border: 1px solid var(--c-line);
  box-shadow: var(--sh-1);
  position: relative;
  overflow: hidden;
}
.cabinet-hero::after {
  content: ''; position: absolute; right: -20px; top: -30px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--hero, var(--c-primary)) 0%, transparent 70%);
  opacity: 0.18; pointer-events: none;
}
.hero-left { display: flex; gap: var(--sp-4); align-items: center; }
.hero-icon {
  width: 56px; height: 56px;
  border-radius: var(--r-3);
  background: var(--hero, var(--c-primary));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--hero, var(--c-primary)) 35%, transparent);
}
.hero-icon .lucide { width: 26px; height: 26px; }
.hero-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--c-text-mute); font-weight: 700; }
.hero-title { margin: 2px 0 4px; font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.02em; }
.hero-sub { color: var(--c-text-soft); font-size: var(--t-sm); }
.hero-actions { display: flex; gap: var(--sp-2); }
@media (max-width: 599px) {
  .cabinet-hero { padding: var(--sp-3) var(--sp-4); }
  .hero-icon { width: 44px; height: 44px; }
  .hero-icon .lucide { width: 22px; height: 22px; }
  .hero-title { font-size: var(--t-xl); }
  .hero-actions { width: 100%; justify-content: stretch; }
  .hero-actions .btn { flex: 1; justify-content: center; }
}

/* Tabs (카테고리 selector) */
.cabinet-tabs {
  display: flex; gap: 4px;
  overflow-x: auto;
  padding: 4px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  scrollbar-width: none;
}
.cabinet-tabs::-webkit-scrollbar { display: none; }
.cab-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: transparent; border: none;
  border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 600;
  color: var(--c-text-soft);
  cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.cab-tab:hover { color: var(--c-text); background: var(--c-surface-2); }
.cab-tab.active {
  background: var(--tab, var(--c-primary));
  color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--tab, var(--c-primary)) 35%, transparent);
}
.cab-tab .lucide { width: 14px; height: 14px; }
.cab-tab-cnt {
  font-size: 11px;
  background: rgba(0,0,0,0.10);
  padding: 1px 7px; border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.cab-tab.active .cab-tab-cnt { background: rgba(255,255,255,0.22); color: #fff; }

/* Toolbar */
.cabinet-toolbar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
}
.cab-subs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.cab-sub {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  padding: 5px 11px;
  font-size: var(--t-xs); font-weight: 600;
  color: var(--c-text-soft);
  cursor: pointer; transition: all 0.12s;
}
.cab-sub:hover { color: var(--c-text); border-color: var(--c-primary); }
.cab-sub.active {
  background: var(--c-primary-soft);
  color: var(--c-primary-strong);
  border-color: var(--c-primary);
}
.cab-sub .muted { font-weight: 500; }
.cab-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  padding: 0 12px; height: 34px;
  min-width: 200px; flex: 0 0 auto;
}
.cab-search input { border: none; outline: none; background: transparent; font-size: var(--t-sm); flex: 1; min-width: 0; color: var(--c-text); }
.cab-search:focus-within { border-color: var(--c-primary); box-shadow: var(--sh-glow); }
@media (max-width: 599px) {
  .cab-search { flex: 1; min-width: 0; }
}

/* Two columns: events | documents */
.cabinet-grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: 1.4fr 1fr;
  min-width: 0;
}
@media (max-width: 1023px) { .cabinet-grid { grid-template-columns: 1fr; } }
.cabinet-col {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-3);
  padding: var(--sp-4);
  box-shadow: var(--sh-1);
  min-width: 0;
}
.col-head {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--t-md); font-weight: 700;
  margin: 0 0 var(--sp-3); padding-bottom: var(--sp-2);
  border-bottom: 1px dashed var(--c-line);
  color: var(--c-text);
}

/* Event card */
.ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev-card {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--c-line);
  background: var(--c-surface-2);
  border-radius: 0 var(--r-2) var(--r-2) 0;
  min-width: 0;
}
.ev-card.owner-young  { border-left-color: var(--c-young); }
.ev-card.owner-yuri   { border-left-color: var(--c-yuri); }
.ev-card.owner-seo    { border-left-color: var(--c-seo); }
.ev-card.owner-family { border-left-color: var(--c-family); }
.ev-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--c-surface);
  border-radius: var(--r-2);
  padding: 4px;
}
.ev-d { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.ev-y { font-size: 10px; color: var(--c-text-mute); font-weight: 600; }
.ev-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ev-title { font-weight: 700; word-break: break-word; }
.ev-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: var(--t-xs); color: var(--c-text-soft); }
.ev-meta .lucide { width: 12px; height: 12px; }
.ev-notes { font-size: var(--t-xs); color: var(--c-text-soft); padding: 4px 6px; background: var(--c-surface); border-radius: var(--r-1); }
.ev-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ev-tag { font-size: 10px; padding: 2px 7px; border-radius: var(--r-pill); font-weight: 700; }

/* Document card */
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-card {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 10px;
  padding: 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-2);
  background: var(--c-surface);
  align-items: center;
}
.doc-thumb {
  width: 48px; height: 48px; border-radius: var(--r-1);
  background: var(--c-surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-mute);
  overflow: hidden;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-title { font-weight: 700; }
.doc-meta { font-size: var(--t-xs); color: var(--c-text-mute); }
.doc-summary { font-size: var(--t-xs); color: var(--c-text-soft); margin-top: 4px; }
.badge {
  font-size: 10px; padding: 2px 7px; border-radius: var(--r-pill);
  background: var(--c-surface-2); color: var(--c-text-soft); font-weight: 600;
}
.badge.done { background: rgba(136,199,20,0.15); color: var(--c-primary-strong); }
.badge.pending, .badge.running { background: rgba(231,168,35,0.18); color: var(--c-warn); }
.badge.failed { background: rgba(226,85,85,0.18); color: var(--c-bad); }

.doc-empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); }
.doc-empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--grad-fresh);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-primary-strong);
}
.doc-empty-icon .lucide { width: 28px; height: 28px; }
.doc-empty-title { font-weight: 700; color: var(--c-text); }
.doc-empty-sub { color: var(--c-text-soft); text-align: center; font-size: var(--t-sm); }

/* Upload modal scrim */
.modal-scrim { position: fixed; inset: 0; background: rgba(10,24,22,0.55); z-index: 90; }
.upload-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92vw); max-height: 84vh;
  border: 1px solid var(--c-line);
  border-radius: var(--r-3);
  background: var(--c-surface);
  box-shadow: var(--sh-3);
  padding: 0; z-index: 100;
}
.upload-modal[open] { display: block; }

/* === Polish on existing components — lime gradient buttons === */
.btn.primary {
  background: var(--grad-lime);
  border: none;
  color: var(--c-on-primary);
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 14px rgba(136,199,20,0.30);
}
.btn.primary:hover {
  background: var(--grad-lime);
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(136,199,20,0.36);
}
.btn { transition: all 0.15s; }

/* dday redesign with gradient */
.dday {
  background: var(--grad-lime);
  color: var(--c-on-primary);
  border-radius: var(--r-3);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 4px 16px rgba(136,199,20,0.28);
}
.dday .dday-num { color: #fff; }
.dday .dday-label { color: rgba(255,255,255,0.85); }

/* Card hover float */
.card { transition: transform 0.2s, box-shadow 0.2s; }
.card:hover { box-shadow: var(--sh-2); }

/* =============================================================
   Upload Modal
   ============================================================= */
.upl-form { display: flex; flex-direction: column; max-height: 84vh; min-width: 0; }
.upl-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5); gap: var(--sp-3);
  border-bottom: 1px solid var(--c-line);
}
.upl-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--c-text-mute); font-weight: 700; }
.upl-title { margin: 4px 0 4px; font-size: var(--t-lg); font-weight: 800; }
.upl-sub { font-size: var(--t-xs); color: var(--c-text-soft); }
.upl-body { padding: var(--sp-4) var(--sp-5); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-3); }
.upl-foot {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--c-line);
  background: var(--c-surface-2);
}
.upl-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--sp-5);
  border: 2px dashed var(--c-line);
  border-radius: var(--r-3);
  background: var(--grad-fresh);
  cursor: pointer; transition: all 0.15s;
}
.upl-drop:hover, .upl-drop.over {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
}
.upl-drop-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--c-surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-primary-strong);
  box-shadow: var(--sh-1);
}
.upl-drop-icon .lucide { width: 24px; height: 24px; }
.upl-drop-title { font-weight: 600; color: var(--c-text); }
.upl-drop-sub { font-size: var(--t-xs); color: var(--c-text-soft); }
.upl-list { display: flex; flex-direction: column; gap: 6px; }
.upl-file {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--c-surface-2);
  border-radius: var(--r-2);
  font-size: var(--t-sm);
}
.upl-file .lucide { width: 16px; height: 16px; color: var(--c-text-soft); }
.upl-file-rm {
  background: transparent; border: none; padding: 4px;
  color: var(--c-text-mute); cursor: pointer;
  border-radius: 4px;
}
.upl-file-rm:hover { color: var(--c-bad); background: rgba(226,85,85,0.1); }
.upl-fields { display: flex; flex-direction: column; gap: var(--sp-3); }
.upl-row { display: flex; flex-direction: column; gap: 4px; }
.upl-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.upl-label { font-size: var(--t-xs); font-weight: 600; color: var(--c-text-soft); }
.upl-progress { padding: var(--sp-3) var(--sp-5); }
.upl-prog-bar { height: 6px; background: var(--c-line); border-radius: 3px; overflow: hidden; }
.upl-prog-bar > i { display: block; height: 100%; background: var(--grad-lime); transition: width 0.2s; }
.upl-prog-msg { font-size: var(--t-xs); color: var(--c-text-soft); margin-top: 6px; }
.upl-done { display: flex; align-items: center; gap: 8px; color: var(--c-primary-strong); font-weight: 600; }
.upl-error { display: flex; align-items: center; gap: 8px; color: var(--c-bad); font-weight: 600; }
@media (max-width: 599px) {
  .upl-row.two { grid-template-columns: 1fr; }
  .upl-head, .upl-body, .upl-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

/* =============================================================
 * Memory Card — "N년 전 오늘" (features/memory-today.js)
 *   - 홈 대시보드 상단에 연도별 가로 스크롤 스트립
 *   - RULE #15 좌측 막대가 있는 카드 스타일 적용 (card 는 기본)
 * ============================================================= */
.memory-card .card-head { border-bottom: 1px dashed var(--c-line); padding-bottom: 8px; }

.memory-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px 2px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.memory-strip::-webkit-scrollbar { height: 8px; }
.memory-strip::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 4px; }

.memory-year-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-accent, var(--c-primary));
  border-radius: 0 var(--r-2, 8px) var(--r-2, 8px) 0; /* RULE #15: 좌측 막대 있는 쪽은 직각 */
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.memory-year-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

.memory-year-head {
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--c-accent-dim, #f4f9e4) 0%, transparent 100%);
  border-bottom: 1px dashed var(--c-line);
}
.memory-year-no {
  font-size: 22px; font-weight: 700; color: var(--c-accent-deep, #0e2c2b); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.memory-year-sub { font-size: 11px; color: var(--c-text-soft); margin-top: 2px; }

.memory-hero {
  width: 100%; aspect-ratio: 16 / 9;
  background: #eee;
  overflow: hidden;
}
.memory-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }

.memory-year-body {
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 10px;
  flex: 1;
}

.memory-block { font-size: 12px; }
.memory-block-head {
  font-size: 10px; font-weight: 600;
  color: var(--c-text-soft);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}
.memory-block-head .mi { width: 12px; height: 12px; }

.memory-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 3px;
}
.memory-list li {
  font-size: 12px; line-height: 1.35;
  display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap;
}
.memory-list li .mi { width: 11px; height: 11px; flex-shrink: 0; color: var(--c-text-soft); }
.memory-list .num.out { color: var(--c-bad, #d33); font-weight: 600; }
.memory-list .num.inc { color: var(--c-good, #2a8); font-weight: 600; }

.memory-year-foot {
  padding: 8px 12px;
  border-top: 1px dashed var(--c-line);
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--c-bg-soft, #fafaf7);
}
.memory-year-foot .mi { width: 11px; height: 11px; }
.memory-year-foot span { display: inline-flex; align-items: center; gap: 3px; }

@media (max-width: 599px) {
  .memory-year-card { flex-basis: 85%; }
}

/* =============================================================
 * Takeout 장소 통합 섹션 (features/places-takeout-section.js)
 * ============================================================= */
.tkp-block {
  background: var(--c-bg-soft, #fafaf7);
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-primary, #88c714);
  border-radius: 0 var(--r-2, 8px) var(--r-2, 8px) 0; /* RULE #15 */
  padding: 10px 12px;
}
.tkp-head {
  font-size: 11px; font-weight: 700;
  color: var(--c-accent-deep, #0e2c2b);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 4px;
}
.tkp-head .mi { width: 13px; height: 13px; }
.tkp-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.tkp-list li {
  font-size: 12.5px; line-height: 1.35;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--c-line);
  display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap;
}
.tkp-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.tkp-list li .mi { width: 12px; height: 12px; flex-shrink: 0; color: var(--c-text-soft); }
.chip-accent { background: var(--c-accent-dim, #f4f9e4); color: var(--c-accent-deep, #0e2c2b); }

/* =============================================================
 * 이력서 Drive 섹션 (features/resume-drive-section.js)
 * ============================================================= */
.rds-owner-block {
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-primary);
  border-radius: 0 var(--r-2, 8px) var(--r-2, 8px) 0; /* RULE #15 */
  padding: 10px 12px;
  background: var(--c-surface);
}
.rds-owner-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--c-line);
}
.rds-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.rds-file {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--c-line);
}
.rds-file:last-child { border-bottom: 0; }
.rds-file .mi { width: 14px; height: 14px; flex-shrink: 0; color: var(--c-text-soft); }
.rds-file .btn.small {
  padding: 4px 8px; font-size: 11px; gap: 3px;
  border: 1px solid var(--c-line);
  background: var(--c-bg-soft, #fafaf7);
}
.rds-file .btn.small.loading { opacity: 0.5; pointer-events: none; }
.rds-file .btn.small .mi { width: 11px; height: 11px; }



/* ================================================================
   Recurring Detect (FEATURE_ROADMAP Phase 2-3)
   ================================================================ */
.rec-detect-card { padding: 16px; }
.rec-detect-grid {
  display: flex; flex-direction: column; gap: 6px;
}
.rec-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--c-line);
  border-radius: 0 var(--r-2) var(--r-2) 0;   /* RULE #15: 좌측은 살리기 위해 flat */
  border-left: 3px solid var(--c-cool, #64748b);
  cursor: pointer;
  transition: background .15s;
}
.rec-row:hover { background: var(--c-bg-soft, #fafaf7); }
.rec-row input[type="checkbox"] { margin: 0; }
.rec-row .rec-bar {
  height: 4px; background: var(--c-line); border-radius: 2px; overflow: hidden;
}
.rec-row .rec-bar span {
  display: block; height: 100%;
  background: var(--c-good, #22c55e);
  transition: width .2s;
}
.rec-detect-commit {
  padding: 6px 12px;
}

/* ================================================================
   Source Selector 배지 (FEATURE_ROADMAP Phase 3-1)
   ================================================================ */
#source-status {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px;
  background: var(--c-bg-soft, #fafaf7);
  border-radius: 0 var(--r-2) var(--r-2) 0;   /* RULE #15 */
  border-left: 3px solid var(--c-cool, #64748b);
}

/* ================================================================
   Places Map (FEATURE_ROADMAP Phase 3-2)
   ================================================================ */
.places-map-card { padding: 0; overflow: hidden; }
.places-map-card .card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-line);
}
#places-leaflet {
  height: 420px; width: 100%;
  background: #f0ece6;
}
.leaflet-popup-content {
  font: 13px/1.45 var(--f-sans, -apple-system);
}
.leaflet-popup-content .p-name { font-weight: 600; }
.leaflet-popup-content .p-meta { color: var(--c-text-soft); font-size: 11px; margin-top: 4px; }

/* === Person Badge (from person-badge.js) === */
.p-badge {
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid var(--c-bg, #fff);
  box-sizing: content-box;
}
.p-badge-clickable:hover {
  transform: scale(1.12);
  z-index: 10 !important;
}
.p-badge-selected {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor !important;
}
.p-badge-remove {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-bad, #ef4444); color: #fff;
  font-size: 10px; line-height: 14px; text-align: center;
  cursor: pointer; display: none;
}
.p-badge:hover .p-badge-remove { display: block; }
.p-badge-group .p-badge { border: 2px solid var(--c-bg, #fff); }
.p-badge-picker .p-badge { margin: 0; }
.p-badge-add:hover {
  border-color: var(--c-accent, #88c714);
  color: var(--c-accent, #88c714);
}

/* === Event Editor Modal (from event-editor.js) === */
.ev-editor-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: ev-fade-in 0.15s ease;
}
@keyframes ev-fade-in { from { opacity: 0; } to { opacity: 1; } }
.ev-editor-modal {
  background: var(--c-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  animation: ev-slide-up 0.2s ease;
}
@keyframes ev-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.ev-editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-line, #e5e7eb);
}
.ev-editor-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.ev-editor-close {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--c-text-2, #666); border-radius: 6px;
}
.ev-editor-close:hover { background: var(--c-surface-2, #f3f4f6); }
.ev-editor-body { padding: 20px; }
.ev-field { margin-bottom: 14px; }
.ev-field-row { display: flex; gap: 12px; margin-bottom: 14px; }
.ev-label {
  display: block; font-weight: 500; font-size: 13px;
  margin-bottom: 4px; color: var(--c-text-2, #555);
}
.ev-actions {
  display: flex; gap: 8px; padding-top: 12px;
  border-top: 1px solid var(--c-line, #e5e7eb);
  margin-top: 8px;
}
@media (max-width: 600px) {
  .ev-editor-modal { max-width: 100%; border-radius: 12px 12px 0 0; align-self: flex-end; }
  .ev-field-row { flex-wrap: wrap; }
}

/* === Profile Management (from profiles.js) === */
.prof-section { margin-bottom: 24px; }
.prof-section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.prof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.prof-card {
  padding: 16px;
  transition: box-shadow 0.15s, transform 0.1s;
}
.prof-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.prof-card-header {
  display: flex; align-items: center; gap: 12px;
}
.prof-card-name {
  font-weight: 600; font-size: 15px;
}
.prof-card-meta {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px;
}
.prof-card-detail {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--c-line, #e5e7eb);
}
.prof-card-memo {
  margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prof-editor .card { margin-bottom: 16px; padding: 20px; }
.prof-editor h3 { margin-bottom: 16px; }
.form-row { margin-bottom: 14px; }
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .form-row-2col { grid-template-columns: 1fr; }
}
.form-label {
  display: block; font-weight: 500; font-size: 13px;
  margin-bottom: 4px; color: var(--c-text-2, #555);
}
.color-picker { margin-top: 4px; }
.color-dot { transition: transform 0.1s; }
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-width: 3px !important; }

/* === Global Search Overlay === */
.global-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.global-search-overlay.hidden {
  display: none;
}
.global-search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}
.global-search-modal {
  width: 90%;
  max-width: 600px;
  background: var(--c-surface);
  border-radius: var(--r-3);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
}
.global-search-input-wrap {
  position: relative;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--c-line);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.global-search-icon {
  flex-shrink: 0;
  color: var(--c-text-soft);
}
.global-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: var(--t-base);
  outline: none;
  color: var(--c-text);
  font-family: inherit;
}
.global-search-input::placeholder {
  color: var(--c-text-mute);
}
.global-search-kbd {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  background: var(--c-surface-2);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-soft);
  text-transform: uppercase;
  flex-shrink: 0;
}
.global-search-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) 0;
}
.global-search-results.hidden {
  display: none;
}
.gs-empty {
  padding: var(--sp-5);
  text-align: center;
  color: var(--c-text-mute);
  font-size: var(--t-sm);
}
.gs-group {
  border-top: 1px solid var(--c-line);
}
.gs-group:first-child {
  border-top: none;
}
.gs-group-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-text-soft);
}
.gs-group-label [data-lucide] {
  width: 14px;
  height: 14px;
}
.gs-result-item {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  transition: background-color 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.gs-result-item:hover,
.gs-result-item.selected {
  background-color: var(--c-surface-2);
}
.gs-result-content {
  flex: 1;
  min-width: 0;
}
.gs-result-title {
  font-weight: 500;
  font-size: var(--t-sm);
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-result-meta {
  font-size: var(--t-xs);
  color: var(--c-text-mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-result-amount {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--c-text-soft);
  flex-shrink: 0;
  white-space: nowrap;
}
.gs-more {
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  border-top: 1px solid var(--c-line);
}
.gs-more a {
  font-size: var(--t-xs);
  color: var(--c-primary);
  text-decoration: none;
  font-weight: 500;
}
.gs-more a:hover {
  text-decoration: underline;
}
/* AI mode toggle */
.global-search-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  color: var(--c-text-mute);
}
.global-search-mode-toggle:hover {
  background: var(--c-surface-2);
  color: #f59e0b;
}
.global-search-mode-toggle.active {
  background: #fef3c7;
  color: #f59e0b;
}
.global-search-mode-toggle [data-lucide] {
  width: 16px;
  height: 16px;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
.gs-result-snippet {
  font-size: 11px;
  color: var(--c-text-mute);
  margin-top: 2px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Rich Text Editor (RULE #37) === */
.rich-editor-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  transition: border-color .2s;
}
.rich-editor-wrap:focus-within {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.rich-editor-wrap .ql-toolbar {
  border: none !important;
  border-bottom: 1px solid var(--c-border) !important;
  background: var(--c-surface-2);
  padding: 6px 8px !important;
}
.rich-editor-wrap .ql-container {
  border: none !important;
  font-family: inherit;
  font-size: var(--t-base, 15px);
}
.rich-editor-wrap .ql-editor {
  padding: 12px 14px;
  line-height: 1.65;
  color: var(--c-text);
}
.rich-editor-wrap .ql-editor.ql-blank::before {
  color: var(--c-text-mute);
  font-style: normal;
}
.rich-editor-wrap .ql-editor h2 { font-size: 1.3em; font-weight: 700; margin: .6em 0 .3em; }
.rich-editor-wrap .ql-editor h3 { font-size: 1.1em; font-weight: 700; margin: .5em 0 .2em; }
.rich-editor-wrap .ql-editor blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 12px;
  margin: .4em 0;
  color: var(--c-text-soft);
}
.rich-editor-wrap .ql-editor pre {
  background: var(--c-surface-2);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: .9em;
}
.rich-editor-wrap .ql-editor a { color: var(--c-accent); text-decoration: underline; }

/* Emoji picker */
.ql-emoji-picker {
  position: absolute;
  z-index: 100;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 8px;
  width: 280px;
  max-height: 260px;
  overflow-y: auto;
}
.emoji-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 6px;
}
.emoji-tab {
  background: none;
  border: none;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: .5;
  transition: opacity .15s, background .15s;
}
.emoji-tab:hover, .emoji-tab.active { opacity: 1; background: var(--c-surface-2); }
.emoji-grid { display: flex; flex-direction: column; gap: 4px; }
.emoji-cat { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji-btn {
  background: none;
  border: none;
  font-size: 22px;
  padding: 3px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
  line-height: 1;
}
.emoji-btn:hover { background: var(--c-surface-2); }

/* Rich content display (read-only) */
.rich-content { line-height: 1.65; }
.rich-content h2 { font-size: 1.3em; font-weight: 700; margin: .6em 0 .3em; }
.rich-content h3 { font-size: 1.1em; font-weight: 700; margin: .5em 0 .2em; }
.rich-content blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 12px;
  margin: .4em 0;
  color: var(--c-text-soft);
}
.rich-content a { color: var(--c-accent); }

/* Twemoji inline sizing */
.rich-content img.emoji,
.rich-editor-wrap img.emoji,
img.emoji {
  height: 1.2em;
  width: 1.2em;
  vertical-align: -0.2em;
  margin: 0 .05em;
  display: inline;
}
