:root {
  --bg: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: rgba(59, 130, 246, 0.15);
  --sidebar-section: #475569;
  --sidebar-divider: rgba(148, 163, 184, 0.12);

  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ==================== Layout ==================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  padding: 22px 24px 20px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
  border-bottom: 1px solid var(--sidebar-divider);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand i {
  font-size: 20px;
  color: var(--primary);
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-section);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 16px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.12s;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: white;
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: #60a5fa;
}

.sidebar-link i {
  font-size: 17px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sidebar-divider);
  font-size: 13px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  padding: 6px 0;
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-action a { color: var(--sidebar-text); font-size: 12px; }
.sidebar-user-action a:hover { color: white; }

/* ==================== Main Content ==================== */
.main-wrap {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 90;
  min-height: 56px;
}

.topbar-toggle {
  background: transparent;
  border: 0;
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  display: none; /* shown on mobile only */
  padding: 4px 8px;
  border-radius: 6px;
}
.topbar-toggle:hover { background: var(--bg); }

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.topbar-icon-btn:hover { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.topbar-icon-btn i { color: var(--text-muted); }

.main-content {
  padding: 28px 32px;
}

/* ==================== Page Header ==================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==================== Cards ==================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
}

.card-body { padding: 18px; }

/* KPI cards */
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.kpi-card:hover {
  box-shadow: var(--shadow);
}

.kpi-card .kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 18px;
}

.kpi-card .kpi-icon.bg-blue   { background: #dbeafe; color: #2563eb; }
.kpi-card .kpi-icon.bg-green  { background: #d1fae5; color: #059669; }
.kpi-card .kpi-icon.bg-red    { background: #fee2e2; color: #dc2626; }
.kpi-card .kpi-icon.bg-amber  { background: #fef3c7; color: #d97706; }
.kpi-card .kpi-icon.bg-purple { background: #ede9fe; color: #7c3aed; }

.kpi-card .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.kpi-card .delta {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-soft);
}

/* ==================== Buttons ==================== */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 7px 14px;
  transition: all 0.12s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm { font-size: 12.5px; padding: 4px 10px; }

/* ==================== Forms ==================== */
.form-control, .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-control-sm, .form-select-sm { font-size: 12.5px; }

.form-label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-label.small { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ==================== Tables ==================== */
.table {
  --bs-table-bg: var(--card);
  --bs-table-border-color: var(--border);
  font-size: 13px;
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 10px 12px;
}

.table thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
  white-space: nowrap;
}

.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* Sticky header */
.table-sticky thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 10;
  box-shadow: inset 0 -1px 0 var(--border);
}

.text-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-feature-settings: "tnum";
}

.amount-pos { color: var(--success); }
.amount-neg { color: var(--danger); }
.is-paid { color: var(--text-soft); }
.is-paid td { color: var(--text-soft); }

/* Wrap table in card-style for cleaner look */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-card .table thead th { background: var(--card); }
.table-card .table-sticky thead th { background: var(--card); }

/* ==================== Badges ==================== */
.badge {
  font-weight: 500;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.2px;
}

.badge.bg-success    { background: var(--success) !important; }
.badge.bg-danger     { background: var(--danger) !important; }
.badge.bg-warning    { background: var(--warning) !important; color: white; }
.badge.bg-info       { background: #cffafe !important; color: #0e7490 !important; }
.badge.bg-secondary  { background: #e2e8f0 !important; color: #475569 !important; }
.badge.bg-light      { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-dark       { background: #1e293b !important; }

/* ==================== Filter / Source Tabs ==================== */
.filter-bar {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* 한 줄 컴팩트 필터바 (거래처 원장, 거래장부 등 리스트 페이지 공통) */
.filter-bar.row { margin-left: 0 !important; margin-right: 0 !important; --bs-gutter-x: 0.5rem; }
.filter-bar-row { gap: 8px 8px; }
.filter-bar-row .fb-item { display: flex; flex-direction: column; }
.filter-bar-row .fb-item .form-label { margin-bottom: 2px; white-space: nowrap; }

/* 리스트 페이지 KPI 카드 압축 */
.kpi-row-compact .kpi-card { padding: 8px 14px; }
.kpi-row-compact .kpi-card .card-body { padding: 0 !important; }
.kpi-row-compact .kpi-card .label { font-size: 13px; margin-bottom: 3px; font-weight: 600; }
.kpi-row-compact .kpi-card .value { font-size: 22px; line-height: 1.15; letter-spacing: -0.4px; font-weight: 700; }

/* 공용 리스트 테이블 — 행 간격 압축, 가로 여백 확장, 폰트 키움 */
.list-table > tbody > tr > td,
.list-table > thead > tr > th { padding: 8px 12px; vertical-align: middle; line-height: 1.3; white-space: nowrap; }
.list-table > thead > tr > th {
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: #334155;
}
.list-table > tbody > tr > td { font-size: 13.5px; }
.list-table > tbody > tr > td.wrap,
.list-table > tbody > tr > td.small { white-space: normal; font-size: 13px; }
.list-table .badge { padding: 3px 7px; font-size: 12px; }
.list-table .btn-sm { padding: 3px 8px; font-size: 12.5px; line-height: 1.2; }
/* 연체 등 위험 행 강조 */
.list-table tr.row-overdue > td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
.list-table tr.row-overdue { background: #fef2f2; }
.list-table tr.row-overdue:hover { background: #fee2e2 !important; }

/* 컬럼 폭 드래그 핸들 */
.list-table th, .ar-ledger-table th { position: relative; }
.col-resizer {
  position: absolute;
  top: 0; right: 0;
  width: 6px; height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 5;
}
.col-resizer::before {
  content: ''; position: absolute;
  top: 25%; right: 2px;
  width: 2px; height: 50%;
  background: #cbd5e1;
  opacity: 0.6;
}
.col-resizer:hover::before { background: #2563eb; opacity: 1; width: 3px; }
body.col-resizing { cursor: col-resize !important; user-select: none !important; }
body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* 리스트 페이지: 본문 좌우 패딩 축소 (filter-bar-row 사용 페이지에 자동 적용) */
main.main-content:has(.filter-bar-row) { padding-left: 16px; padding-right: 16px; }

.source-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: white;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.12s;
}

.source-tab:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.source-tab.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.source-tab .count {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

.source-tab.active .count {
  background: rgba(255, 255, 255, 0.2);
}

/* ==================== Pagination ==================== */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

.pagination { margin: 0; }

.pagination .page-link {
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 10px;
  margin: 0 2px;
  border-radius: 6px;
}

.pagination .page-link:hover {
  background: var(--bg);
  color: var(--text);
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.pagination .page-item.disabled .page-link {
  color: var(--text-soft);
  background: white;
  border-color: var(--border);
}

.per-page-selector .form-select-sm { width: auto; display: inline-block; }

/* ==================== Alerts ==================== */
.alert {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* ==================== Login ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand i {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 10px;
  display: block;
}

.login-brand h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==================== Mobile ==================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .topbar { padding: 10px 16px; }
  .topbar-toggle { display: inline-flex; }
  .main-content { padding: 16px; }
  .page-header { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .page-header > div:last-child { width: 100%; }

  /* 페이지에 개별 대응 없이 그냥 쓰는 표 전부 가로 스크롤 처리 */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  table thead, table tbody, table tr { display: table; width: 100%; table-layout: auto; }

  /* KPI 카드 줄: 좁은 화면에서 슬라이버로 찌그러지지 않게 2열로 랩 */
  .row.g-2.kpi-row-compact,
  .row.g-2 > .kpi-card,
  div[class*="kpi-row"] {
    flex-wrap: wrap;
  }
  .kpi-row-compact > .col,
  .kpi-row-compact > [class*="col-"] {
    flex: 1 1 46%;
    min-width: 130px;
  }
  .kpi-row-compact .kpi-card .value { font-size: 18px; }
  .kpi-row-compact .kpi-card .label { font-size: 11.5px; }

  /* 필터/검색바, 버튼 그룹이 옆으로 튀어나가지 않게 */
  .filter-bar, .d-flex.gap-2 { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .kpi-row-compact > .col,
  .kpi-row-compact > [class*="col-"] {
    flex: 1 1 100%;
  }
}

/* ==================== Misc ==================== */
.text-muted { color: var(--text-muted) !important; }
.bg-light { background: var(--bg) !important; }
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  padding: 6px;
}
.dropdown-item {
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.active { background: var(--primary); color: white; }

/* ==================== Memo Widget (in topbar) ==================== */
.memo-widget {
  position: relative;
  display: inline-flex;
}

.memo-toggle {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.memo-toggle:hover { background: var(--bg); border-color: var(--border-strong); }
.memo-toggle i { color: var(--warning); }

.memo-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.memo-badge.is-zero { display: none; }

.memo-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  height: auto;
  min-width: 280px;
  min-height: 240px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

.memo-panel-resize {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
  z-index: 10;
  background:
    linear-gradient(45deg, transparent 45%, var(--text-soft) 45%, var(--text-soft) 55%, transparent 55%),
    linear-gradient(45deg, transparent 70%, var(--text-soft) 70%, var(--text-soft) 80%, transparent 80%);
  user-select: none;
  touch-action: none;
}
.memo-widget.open .memo-panel { display: flex; }
.memo-widget.open .memo-toggle { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.memo-title { font-weight: 600; font-size: 14px; }
.memo-title i { color: var(--warning); margin-right: 4px; }
.memo-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.memo-close:hover { background: var(--bg); color: var(--text); }

.memo-add {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafbfc;
}
.memo-add textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
.memo-add textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.memo-add .btn { align-self: flex-end; }

.memo-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}
.memo-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}
.memo-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.memo-item:last-child { border-bottom: 0; }
.memo-item:hover { background: #f8fafc; }
.memo-content {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.memo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-soft);
}
.memo-delete {
  background: transparent;
  border: 0;
  color: var(--text-soft);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
}
.memo-delete:hover { background: #fee2e2; color: var(--danger); }

.memo-item { cursor: grab; user-select: none; }
.memo-item.dragging { opacity: 0.45; cursor: grabbing; }
.memo-item .memo-delete { cursor: pointer; user-select: auto; }
.memo-item .memo-content {
  cursor: text;
  user-select: text;
  outline: none;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}
.memo-item .memo-content:focus { background: rgba(59, 130, 246, 0.06); }
.memo-item.is-pinned .memo-meta::before {
  content: "\F4D9";
  font-family: "bootstrap-icons";
  color: var(--warning);
  margin-right: 4px;
  font-size: 11px;
}
.memo-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-soft);
  font-style: italic;
  pointer-events: none;
}

/* ==================== Memo Pin Layer (sticky notes on screen) ==================== */
.memo-pin-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.memo-pin {
  position: fixed;
  width: 220px;
  height: auto;
  min-width: 160px;
  min-height: 70px;
  max-width: 600px;
  max-height: 70vh;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #78350f;
  overflow: hidden;
  resize: both;
}

.memo-pin.dragging { box-shadow: 0 14px 28px rgba(15, 23, 42, 0.28); }

.memo-pin-ghost {
  position: fixed;
  width: 220px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.28);
  padding: 8px 10px;
  font-size: 13px;
  color: #78350f;
  pointer-events: none;
  opacity: 0.92;
  z-index: 9999;
  transform: rotate(-2deg);
}
.memo-pin-ghost .memo-pin-content {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow: hidden;
}

.memo-pin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 8px;
  background: rgba(180, 83, 9, 0.12);
  border-bottom: 1px solid rgba(180, 83, 9, 0.18);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.memo-pin-header:active { cursor: grabbing; }

.memo-pin-handle { color: #92400e; font-size: 12px; line-height: 1; }

.memo-pin-close {
  background: transparent;
  border: 0;
  color: #92400e;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.memo-pin-close:hover { background: rgba(180, 83, 9, 0.18); }

.memo-pin-content {
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  line-height: 1.5;
  overflow-y: auto;
  cursor: text;
  outline: none;
  user-select: text;
}
.memo-pin-content:focus { background: rgba(255, 255, 255, 0.4); }
