@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/plus-jakarta-sans.woff2") format("woff2");
}

:root {
  --accent: #6366f1;
  --bg-outer: #e8e8f4;
  --bg-page: #fafaff;
  --bg-card: #ffffff;
  --bg-subtle: #f2f2fa;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-subtle);
  --settings-pill: var(--bg-card);
  --text-main: #202033;
  --text-secondary: #515168;
  --text-muted: #7d7d94;
  --border-color: #d9d9e8;
  --border-soft: #eaeaf3;
  --danger: #ef4444;
  --danger-solid: #dc2626;
  --danger-solid-hover: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius: 14px;
}

body {
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  transition: height 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

body.dark-theme {
  --accent: #818cf8;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 75%, white);
  --primary-light: color-mix(in srgb, var(--accent) 15%, transparent);
  --primary-border: color-mix(in srgb, var(--accent) 36%, transparent);
  --primary-text: color-mix(in srgb, var(--accent) 45%, white);
  --bg-outer: #151522;
  --bg-page: #1d1d2c;
  --bg-card: #2e2e42;
  --bg-subtle: #303044;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-card);
  --settings-pill: #44445e;
  --text-main: #f3f3fb;
  --text-secondary: #c9c9dc;
  --text-muted: #9999b2;
  --border-color: #414158;
  --border-soft: #333348;
  --danger: #fb7185;
  --danger-solid: #dc4660;
  --danger-solid-hover: #c93852;
  --danger-bg: rgba(251, 113, 133, 0.12);
  --danger-border: rgba(251, 113, 133, 0.35);
}

/* Display styles: each style overrides the theme variables. Placed after body.dark-theme so the style wins over the theme toggle. */
body[data-style="paper"] {
  --accent: #c2410c;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  --bg-outer: #efe9df;
  --bg-page: #faf7f2;
  --bg-card: #fffdf8;
  --bg-subtle: #f3ede3;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-subtle);
  --settings-pill: var(--bg-card);
  --text-main: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --border-color: #e7ddd0;
  --border-soft: #efe7db;
  --danger-bg: #fef3ec;
  --danger-border: #f5c9ae;
  --radius: 10px;
}

body[data-style="paper"] .template-card,
body[data-style="paper"] .settings-modal-card,
body[data-style="paper"] .modal-card {
  box-shadow: 0 1px 3px rgba(120, 85, 50, 0.08);
}

body[data-style="mint"] {
  --accent: #10b981;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  --bg-outer: #d9f2e3;
  --bg-page: #f0fdf4;
  --bg-card: #ffffff;
  --bg-subtle: #dcfce7;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-subtle);
  --settings-pill: var(--bg-card);
  --text-main: #16211a;
  --text-secondary: #4b5a50;
  --text-muted: #8aa093;
  --border-color: #cdeeda;
  --border-soft: #dcf2e3;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius: 12px;
}

body[data-style="navy"] {
  --accent: #38bdf8;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 75%, white);
  --primary-light: color-mix(in srgb, var(--accent) 15%, transparent);
  --primary-border: color-mix(in srgb, var(--accent) 36%, transparent);
  --primary-text: color-mix(in srgb, var(--accent) 45%, white);
  --bg-outer: #0b1120;
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-subtle: #243449;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-card);
  --settings-pill: #33465f;
  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-soft: #2b3a4f;
  --danger: #fb7185;
  --danger-solid: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.14);
  --danger-border: rgba(244, 63, 94, 0.4);
  --radius: 10px;
}

body[data-style="navy"] .template-card,
body[data-style="navy"] .settings-modal-card,
body[data-style="navy"] .modal-card {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

body[data-style="candy"] {
  --accent: #ec4899;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  --bg-outer: #f9dbe9;
  --bg-page: #fdf2f8;
  --bg-card: #ffffff;
  --bg-subtle: #fce7f3;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-subtle);
  --settings-pill: var(--bg-card);
  --text-main: #2d1a24;
  --text-secondary: #6b4a5a;
  --text-muted: #a78b9b;
  --border-color: #f5d0e0;
  --border-soft: #fbe4ef;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --radius: 16px;
}

body[data-style="mono"] {
  --accent: #171717;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  --bg-outer: #e5e5e5;
  --bg-page: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f5f5f5;
  --settings-shell: var(--bg-page);
  --settings-well: var(--bg-subtle);
  --settings-pill: var(--bg-card);
  --text-main: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --border-color: #d4d4d4;
  --border-soft: #e5e5e5;
  --radius: 4px;
}

body[data-style="mono"] .template-card,
body[data-style="mono"] .settings-modal-card,
body[data-style="mono"] .modal-card {
  box-shadow: none;
}

body[data-style="glass"] {
  --accent: #007aff;
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 82%, black);
  --primary-light: color-mix(in srgb, var(--accent) 10%, white);
  --primary-border: color-mix(in srgb, var(--accent) 38%, white);
  --primary-text: color-mix(in srgb, var(--accent) 72%, black);
  --glass-intensity: 50;
  --glass-blur: calc(4px + var(--glass-intensity) * 0.36px);
  --bg-outer: #dbeafe;
  --bg-page: rgba(255, 255, 255, calc(0.2 + var(--glass-intensity) / 100 * 0.3));
  --bg-card: rgba(255, 255, 255, calc(0.35 + var(--glass-intensity) / 100 * 0.35));
  --bg-subtle: rgba(255, 255, 255, calc(0.25 + var(--glass-intensity) / 100 * 0.3));
  --settings-shell: rgba(255, 255, 255, calc(0.25 + var(--glass-intensity) / 100 * 0.35));
  --settings-well: rgba(255, 255, 255, calc(0.35 + var(--glass-intensity) / 100 * 0.35));
  --settings-pill: rgba(255, 255, 255, calc(0.55 + var(--glass-intensity) / 100 * 0.3));
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #7d8aa0;
  --border-color: rgba(255, 255, 255, 0.7);
  --border-soft: rgba(15, 23, 42, 0.12);
  --danger-bg: rgba(254, 242, 242, 0.7);
  --danger-border: rgba(254, 202, 202, 0.8);
  --radius: 16px;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(99, 102, 241, 0.5), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(236, 72, 153, 0.4), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(16, 185, 129, 0.35), transparent 60%),
    linear-gradient(160deg, #dbeafe, #fce7f3 45%, #d1fae5);
}

body[data-style="glass"][data-glass="clear"] {
  --bg-page: rgba(255, 255, 255, calc(0.1 + var(--glass-intensity) / 100 * 0.2));
  --bg-card: rgba(255, 255, 255, calc(0.2 + var(--glass-intensity) / 100 * 0.25));
  --bg-subtle: rgba(255, 255, 255, calc(0.12 + var(--glass-intensity) / 100 * 0.2));
  --settings-shell: rgba(255, 255, 255, calc(0.15 + var(--glass-intensity) / 100 * 0.25));
  --settings-well: rgba(255, 255, 255, calc(0.2 + var(--glass-intensity) / 100 * 0.25));
  --settings-pill: rgba(255, 255, 255, calc(0.4 + var(--glass-intensity) / 100 * 0.3));
}

body[data-style="glass"][data-glass-background="sunset"] {
  --bg-outer: #ffedd5;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(249, 115, 22, 0.45), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(236, 72, 153, 0.45), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(168, 85, 247, 0.35), transparent 60%),
    linear-gradient(160deg, #ffedd5, #fce7f3 45%, #ede9fe);
}

body[data-style="glass"][data-glass-background="lagoon"] {
  --bg-outer: #ccfbf1;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(20, 184, 166, 0.45), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(14, 165, 233, 0.4), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(16, 185, 129, 0.35), transparent 60%),
    linear-gradient(160deg, #ccfbf1, #e0f2fe 45%, #d1fae5);
}

body[data-style="glass"][data-glass-background="rose"] {
  --bg-outer: #fce7f3;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(236, 72, 153, 0.45), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(249, 115, 22, 0.4), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(168, 85, 247, 0.35), transparent 60%),
    linear-gradient(160deg, #fce7f3, #ffedd5 45%, #ede9fe);
}

body[data-style="glass"][data-glass-background="sky"] {
  --bg-outer: #dbeafe;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(14, 165, 233, 0.45), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(99, 102, 241, 0.4), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(20, 184, 166, 0.35), transparent 60%),
    linear-gradient(160deg, #dbeafe, #e0f2fe 45%, #ede9fe);
}

body[data-style="glass"][data-glass-background="lavender"] {
  --bg-outer: #ede9fe;
  background-image:
    radial-gradient(120% 90% at 15% 0%, rgba(168, 85, 247, 0.45), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, rgba(236, 72, 153, 0.4), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, rgba(99, 102, 241, 0.35), transparent 60%),
    linear-gradient(160deg, #ede9fe, #fce7f3 45%, #dbeafe);
}

body[data-style="glass"][data-glass-background="custom"] {
  --bg-outer: color-mix(in srgb, var(--glass-custom-c1, #6366f1) 15%, white);
  background-image:
    radial-gradient(120% 90% at 15% 0%, color-mix(in srgb, var(--glass-custom-c1, #6366f1) 50%, transparent), transparent 55%),
    radial-gradient(100% 80% at 90% 10%, color-mix(in srgb, var(--glass-custom-c2, #ec4899) 45%, transparent), transparent 55%),
    radial-gradient(120% 100% at 50% 100%, color-mix(in srgb, var(--glass-custom-c3, #10b981) 40%, transparent), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--glass-custom-c1, #6366f1) 15%, white), color-mix(in srgb, var(--glass-custom-c2, #ec4899) 15%, white) 45%, color-mix(in srgb, var(--glass-custom-c3, #10b981) 15%, white));
}

/* No backdrop-filter on .app-wrapper: it would reposition the fixed modals inside it. */
body[data-style="glass"] .list-container,
body[data-style="glass"] .search-box,
body[data-style="glass"] .settings-modal-card,
body[data-style="glass"] .modal-card,
body[data-style="glass"] .style-menu,
body[data-style="glass"] .category-tab,
body[data-style="glass"] .bulk-action-bar,
body[data-style="glass"] .settings-tab-panel.active,
body[data-style="glass"] .modal-panel,
body[data-style="glass"] .editor-container {
  backdrop-filter: blur(var(--glass-blur)) saturate(calc(120% + var(--glass-intensity) * 0.6%));
}

/* Dropdown menus stay solid so list text cannot bleed through them. */
body[data-style="glass"] .sort-menu,
body[data-style="glass"] .style-menu,
body[data-style="glass"] .template-more-menu,
body[data-style="glass"] .accent-color-popover,
body[data-style="glass"] .toolbar-color-popover,
body[data-style="glass"] .list-style-popover,
body[data-style="glass"] .insert-table-popover,
body[data-style="glass"] .category-dropdown-menu,
body[data-style="glass"] .line-height-menu,
body[data-style="glass"] .table-select-menu,
body[data-style="glass"] .font-menu,
body[data-style="glass"] .insert-image-menu,
body[data-style="glass"] .paragraph-style-menu,
body[data-style="glass"] .horizontal-line-menu,
body[data-style="glass"] .attachment-badge-popup,
body[data-style="glass"] .var-autocomplete {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(var(--glass-blur)) saturate(calc(120% + var(--glass-intensity) * 0.6%));
}

/* The list panel is a backdrop-filter stacking context that painted over the sort menu. */
body[data-style="glass"] .search-box {
  z-index: 20;
}

body[data-style="glass"] .list-container,
body[data-style="glass"] .settings-modal-card,
body[data-style="glass"] .modal-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 8px 32px rgba(30, 41, 59, 0.12);
}

/* The dark dim made modal glass look grey next to the bright list panel. */
body[data-style="glass"] .modal-backdrop,
body[data-style="glass"] .preview-popup-backdrop {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(calc(var(--glass-blur) * 0.4)) saturate(calc(120% + var(--glass-intensity) * 0.6%));
}

.glass-intensity-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.glass-intensity-control input[type="range"] {
  flex: 1;
  min-width: 60px;
  accent-color: var(--primary);
  cursor: pointer;
}

.glass-intensity-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 34px;
  text-align: right;
}

.glass-background-swatches {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.glass-bg-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.glass-bg-swatch:hover {
  transform: scale(1.15);
}

.glass-bg-swatch.active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-main);
}

.glass-bg-swatch[data-glass-background="aurora"] {
  background: linear-gradient(135deg, #6366f1, #ec4899 50%, #10b981);
}

.glass-bg-swatch[data-glass-background="sunset"] {
  background: linear-gradient(135deg, #f97316, #ec4899 50%, #a855f7);
}

.glass-bg-swatch[data-glass-background="lagoon"] {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9 50%, #10b981);
}

.glass-bg-swatch[data-glass-background="rose"] {
  background: linear-gradient(135deg, #ec4899, #f97316 50%, #a855f7);
}

.glass-bg-swatch[data-glass-background="sky"] {
  background: linear-gradient(135deg, #0ea5e9, #6366f1 50%, #14b8a6);
}

.glass-bg-swatch[data-glass-background="lavender"] {
  background: linear-gradient(135deg, #a855f7, #ec4899 50%, #6366f1);
}

.glass-bg-swatch-custom {
  background: conic-gradient(#f43f5e, #f59e0b, #10b981, #0ea5e9, #8b5cf6, #f43f5e);
}

#glass-background-row {
  position: relative;
}

.glass-bg-color-popover {
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
}

body[data-style="glass"] .glass-bg-color-popover {
  background: #ffffff;
  backdrop-filter: none;
}

.glass-bg-color-popover .toolbar-color-surface {
  height: 104px;
}

/* The popover opens upward past the panel edge, so let it escape the scrollable panel while open. */
.settings-tab-panel.active.glass-bg-picker-open {
  overflow-y: visible;
  position: relative;
  z-index: 2;
}

.toolbar-color-slots {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar-color-slots-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.glass-bg-color-slots {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.glass-bg-color-slot {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.glass-bg-color-slot:hover {
  transform: scale(1.15);
}

.glass-bg-color-slot.active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-main);
}

* {
  box-sizing: border-box;
}

html,
body {
  background-color: var(--bg-outer);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  width: 470px;
  padding: 10px;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
}

button, input, select, textarea {
  font-family: inherit;
}

.app-wrapper {
  padding: 12px 14px;
  position: relative;
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-version-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--primary-text);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.3;
}

.subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

body[data-style="glass"] .btn-ghost {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(30, 41, 59, 0.16);
  box-shadow: 0 1px 4px rgba(30, 41, 59, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

body[data-style="glass"] .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.75);
}

.btn-danger-solid {
  background: var(--danger-solid);
  color: #ffffff;
  border: 1px solid var(--danger-solid);
}

.btn-danger-solid:hover {
  background: var(--danger-solid-hover);
  border-color: var(--danger-solid-hover);
}

.btn-xs {
  padding: 4px 9px;
  font-size: 11px;
  border-radius: 6px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px 8px 34px;
  font-size: 12.5px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box .select-mode-toggle {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.search-box .select-mode-toggle:not(.active):hover {
  background: var(--bg-card);
  border-color: var(--primary-border);
}

.sort-dropdown {
  position: relative;
  flex-shrink: 0;
}

.sort-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sort-trigger:hover,
.sort-trigger.open {
  border-color: var(--primary-border);
}

.sort-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.sort-trigger svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.sort-menu {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  top: calc(100% + 4px);
  right: 0;
  min-width: 150px;
  max-height: 175px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
  padding: 6px;
  z-index: 75;
}

.sort-option {
  width: 100%;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.sort-option:hover,
.sort-option.selected {
  background: var(--primary-light);
  color: var(--primary-text);
}

.select-mode-toggle.active {
  color: var(--primary-text);
  background: var(--primary-light);
  border-color: var(--primary-border);
}

#search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Tab Kategori di Bawah Search */
.category-tabs-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 11px;
}

.category-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-scroll-btn {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  width: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.cat-scroll-btn:hover {
  color: var(--text-main);
}

.cat-scroll-left {
  left: 0;
  justify-content: flex-start;
  padding-left: 2px;
  background: linear-gradient(to left, transparent, var(--bg-page) 50%);
}

.cat-scroll-right {
  right: 0;
  justify-content: flex-end;
  padding-right: 2px;
  background: linear-gradient(to right, transparent, var(--bg-page) 50%);
}

.cat-scroll-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}

.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.14s ease;
  flex-shrink: 0;
}

.category-tab:hover {
  border-color: var(--primary-border);
  color: var(--text-main);
  background: var(--bg-subtle);
}

.category-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.category-tab-count {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.16);
  color: inherit;
}

.category-tab.active .category-tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.category-tab-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* Template List: tinggi fleksibel sesuai isi dengan batas maksimal */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 4px 14px;
}

.template-pagination {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  width: fit-content;
  margin: 0;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(39, 39, 75, 0.06);
}

.pagination-indicator {
  position: absolute;
  top: 3px;
  left: 0;
  height: 28px;
  width: 28px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
  transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.64, 1), width 0.45s cubic-bezier(0.34, 1.3, 0.64, 1);
  pointer-events: none;
  z-index: 0;
}

.pagination-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 9px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.template-pagination.page-window-slide-forward .pagination-page-btn {
  animation: paginate-slide-in-right 0.3s ease;
}

.template-pagination.page-window-slide-backward .pagination-page-btn {
  animation: paginate-slide-in-left 0.3s ease;
}

@keyframes paginate-slide-in-right {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes paginate-slide-in-left {
  from { transform: translateX(-14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.pagination-btn.active {
  background: transparent;
  color: #ffffff;
  box-shadow: none;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.template-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  padding: 12px 2px;
  transition: transform 0.25s ease;
}

.list-container .template-card:last-child {
  border-bottom: none;
}

.template-select-checkbox {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-right: 10px;
  accent-color: var(--primary);
  cursor: pointer;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--primary-border);
  border-radius: 12px;
  padding: 6px 10px 6px 14px;
  margin-bottom: 8px;
}

.bulk-selected-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-text);
  white-space: nowrap;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.bulk-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.bulk-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.bulk-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
  flex-shrink: 0;
}

.bulk-icon-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.template-info {
  flex: 1;
  min-width: 0;
  margin-right: 10px;
}

.template-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.template-actions-column {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.template-excel-imports {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  max-width: 100%;
}

.template-excel-imports:empty {
  display: none;
}

.template-excel-progress {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  width: 190px;
  max-width: 100%;
  color: var(--text-muted);
  font-size: 10px;
}

.template-excel-count {
  flex: none;
  min-width: 28px;
  color: var(--primary-text);
  font-weight: 700;
  text-align: right;
}

.template-excel-progress-bar {
  flex: 1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border-soft);
}

.template-excel-progress-fill {
  display: block;
  height: 100%;
  width: var(--progress-width);
  border-radius: inherit;
  background: var(--primary);
}

.template-excel-progress-fill.is-animating {
  animation: excel-progress-grow 0.35s ease-out;
}

@keyframes excel-progress-grow {
  from {
    width: var(--previous-progress-width, 0%);
  }
  to {
    width: var(--progress-width);
  }
}

.template-excel-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.template-excel-clear:hover {
  background: var(--primary-light);
  color: var(--danger);
}

.template-category-badge {
  display: inline-flex;
  align-items: center;
  padding: 1.5px 7px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}

.template-category-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--primary-text);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
}

.template-category-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  margin-right: 4px;
}

.template-card.is-dragging {
  opacity: 0.45;
}

.category-tab.is-dragging {
  opacity: 0.45;
}

.category-tab[draggable="true"] {
  cursor: grab;
}

.template-card[draggable="true"] {
  cursor: grab;
}

.template-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-use {
  border: 1px solid var(--primary-border);
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.15s, color 0.15s;
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-delete-template:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.btn-favorite-template.is-favorite {
  color: #d97706;
  background: #fff7d6;
  border-color: #f3d27a;
}

.dark-theme .btn-favorite-template.is-favorite {
  color: #fbbf24;
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.45);
}

.template-more-menu {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 120;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.template-more-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.template-more-item:hover,
.template-more-item:focus-visible {
  outline: none;
  background: var(--primary-light);
  color: var(--primary-text);
}

.template-more-delete:hover,
.template-more-delete:focus-visible {
  color: var(--danger);
}

.template-more-delete {
  color: var(--danger);
}

.template-more-delete:hover,
.template-more-delete:focus-visible {
  background: var(--danger-bg);
}

.btn-edit:hover,
.btn-preview-template:hover,
.btn-template-more:hover,
.btn-template-more[aria-expanded="true"] {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-favorite-template:hover {
  color: #d97706;
  background: #fff7d6;
  border-color: #f3d27a;
}

.dark-theme .btn-favorite-template:hover {
  color: #fbbf24;
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.45);
}

/* Footer dengan Ikon Setting & Menu List */
.list-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.list-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-setting-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-setting-icon:hover,
.btn-setting-icon.active {
  background: var(--primary-light);
  color: var(--primary-text);
  border-color: var(--primary-border);
}

/* The settings box scrolls when it is taller than the popup, so its bottom rows stay reachable. */
#settings-modal {
  overflow-y: auto;
}

.modal-card.settings-modal-card {
  align-self: flex-start;
  background: var(--settings-shell);
  max-height: calc(100vh - 24px);
}

.modal-card.category-manage-card,
.modal-card.backup-modal-card,
.modal-card.trakteer-modal-card,
.modal-card.image-library-card {
  background: var(--settings-shell);
}

.modal-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 4px 14px;
}

body.dark-theme:not([data-style]) .settings-tab-panel.active,
body.dark-theme:not([data-style]) .modal-panel {
  background: #383854;
}

body[data-style="navy"] .settings-tab-panel.active,
body[data-style="navy"] .modal-panel {
  background: #28394f;
}

.modal-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.modal-header-btn,
.settings-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.modal-header-btn:hover,
.settings-back-btn:hover {
  background: var(--bg-subtle);
}

.settings-tabs {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--settings-well);
}

.settings-tab-indicator {
  position: absolute;
  top: 4px;
  left: 0;
  height: 30px;
  width: 100px;
  border-radius: 8px;
  background: var(--settings-pill);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.64, 1), width 0.45s cubic-bezier(0.34, 1.3, 0.64, 1), height 0.45s cubic-bezier(0.34, 1.3, 0.64, 1), top 0.45s cubic-bezier(0.34, 1.3, 0.64, 1);
  pointer-events: none;
  z-index: 0;
}

.settings-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.settings-tab:not(.active):hover {
  color: var(--text-main);
}

.settings-tab.active {
  background: transparent;
  color: var(--text-main);
  font-weight: 700;
  box-shadow: none;
}

.settings-tab-panel {
  display: none;
}

.settings-tab-panel.active {
  display: block;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 4px 14px;
  min-height: 0;
  overflow-y: auto;
}

.settings-tab-panel.active > .settings-modal-row,
.settings-tab-panel.active > .settings-menu-item {
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
}

.settings-tab-panel.active .settings-modal-row.settings-row-collapsed {
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.settings-tab-panel.active > .settings-modal-row:last-child,
.settings-tab-panel.active > .settings-menu-item:last-child {
  border-bottom: none;
}

.settings-tab-panel.active > .settings-menu-item:hover {
  background: transparent;
}

.settings-tab-panel.active > .settings-menu-item:hover .settings-row-chevron {
  color: var(--text-main);
  transform: translateX(2px);
}

.settings-tab-panel.active > .settings-menu-item:hover .settings-toggle {
  filter: brightness(0.94);
}

.settings-tab-panel.active .settings-section-label {
  padding: 12px 2px 4px;
}

.settings-tab-panel.active .settings-section-label:first-child {
  padding-top: 10px;
}

.settings-tab-panel.active .about-hero {
  padding: 14px 2px 8px;
}

.settings-tab-panel.tab-slide-forward {
  animation: tab-slide-in-right 0.3s ease;
}

.settings-tab-panel.tab-slide-backward {
  animation: tab-slide-in-left 0.3s ease;
}

.settings-section-label {
  display: block;
  padding: 10px 9px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.settings-section-label:first-child {
  padding-top: 2px;
}

.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 12px 9px 8px;
}

.about-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 4px;
}

.about-name {
  font-size: 16px;
}

.about-tagline {
  font-size: 11.5px;
  color: var(--text-muted);
}

.about-credit {
  font-size: 12px;
  color: var(--text-main);
}

.about-link {
  text-decoration: none;
}

.about-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 9px 10px;
}

.about-links .settings-menu-item {
  width: 32px;
  height: 32px;
  min-height: 0;
  flex: 0 0 auto;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}

/* Changelog: About tab button + modal */
.changelog-open-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 4px;
  margin-bottom: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.changelog-open-btn:hover {
  background: var(--bg-subtle);
}

.changelog-open-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.changelog-open-title {
  font-size: 13px;
  font-weight: 600;
}

.changelog-open-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

.changelog-open-chevron {
  flex: 0 0 auto;
  color: var(--text-muted);
}

.changelog-modal-card {
  background: var(--settings-shell);
  max-height: calc(100vh - 24px);
}

.changelog-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 0;
}

body.dark-theme .changelog-list {
  --bg-subtle: #35354a;
}

.changelog-version {
  border-bottom: 1px solid var(--border-soft);
}

.changelog-version:last-child {
  border-bottom: none;
}

.changelog-version-header {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.changelog-version-header:hover {
  background: var(--bg-subtle);
}

.changelog-version-number {
  flex: 0 0 auto;
}

.changelog-latest-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
}

.changelog-version-chevron {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.changelog-version.open .changelog-version-chevron {
  transform: rotate(180deg);
}

.changelog-version-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.changelog-version-body > ul {
  margin: 0;
  padding: 0 14px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-main);
}

.changelog-version-body > ul li::marker {
  color: var(--text-muted);
}

.changelog-section-title {
  display: inline-flex;
  align-items: center;
  margin: 10px 0 6px 32px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.changelog-version-body > ul + .changelog-section-title {
  margin-top: 6px;
}

.changelog-section-features {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.changelog-section-fixes {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

body.dark-theme .changelog-section-features {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}

body.dark-theme .changelog-section-fixes {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

.whats-new-modal-card {
  background: var(--settings-shell);
  max-height: calc(100vh - 24px);
}

#btn-close-whats-new {
  margin-left: auto;
}

#btn-close-changelog {
  margin-left: auto;
}

#btn-close-category-manage,
#btn-close-backup,
#btn-close-library {
  margin-left: auto;
}

.whats-new-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.whats-new-version-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.whats-new-version-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.whats-new-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-main);
}

.whats-new-list ul {
  margin: 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.whats-new-list ul li::marker {
  color: var(--text-muted);
}

.whats-new-list .changelog-section-title {
  margin-left: 18px;
  align-self: flex-start;
}

.whats-new-full-btn {
  width: 100%;
  justify-content: center;
}

@keyframes tab-slide-in-right {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes tab-slide-in-left {
  from { transform: translateX(-14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.settings-modal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  transition: opacity 0.2s ease;
}

.settings-row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.settings-row-label svg {
  flex: 0 0 auto;
  color: var(--text-muted);
}

/* Rows carry no icons in the grouped settings style; the label text does the work. */
#settings-panel-appearance .settings-row-label svg,
#settings-panel-content .settings-row-label svg,
#settings-panel-content .settings-menu-item > svg {
  display: none;
}

.settings-segmented {
  display: inline-flex;
  position: relative;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--settings-well);
}

.segmented-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 6px;
  background: var(--settings-pill);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.64, 1), width 0.45s cubic-bezier(0.34, 1.3, 0.64, 1);
  pointer-events: none;
}

.settings-segmented:has(button:disabled) .segmented-pill {
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  .segmented-pill {
    transition: none;
  }
}

.settings-segmented button {
  position: relative;
  z-index: 1;
  padding: 4px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.settings-segmented button:not(.active):not(:disabled):hover {
  color: var(--text-main);
}

.settings-segmented button.active {
  background: transparent;
  color: var(--text-main);
  font-weight: 700;
  box-shadow: none;
}

.settings-segmented button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.settings-row-chevron {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 15px;
  transition: transform 0.15s ease, color 0.15s ease;
}

.accent-color-popover {
  right: 0;
  bottom: calc(100% + 8px);
}

.category-manage-card {
  position: relative;
}

.category-color-popover {
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
}

.settings-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease, opacity 0.2s ease;
}

.settings-menu-item:hover {
  background: var(--bg-subtle);
}

.settings-menu-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.settings-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 21px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 30%, transparent);
  position: relative;
  transition: background-color 0.15s ease;
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.animation-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

/* Animation off: every animation and transition in the popup runs instantly. */
body.no-animations,
body.no-animations *,
body.no-animations *::before,
body.no-animations *::after {
  animation-duration: 0.01ms !important;
  animation-delay: 0s !important;
  transition-duration: 0.01ms !important;
  transition-delay: 0s !important;
}

/* Animation off: the form slide and the modal animations are removed entirely. */
body.no-animations #view-form,
body.no-animations .modal-backdrop,
body.no-animations .modal-backdrop .modal-card,
body.no-animations .modal-backdrop .image-lightbox {
  animation: none !important;
}

/* The Trakteer heart keeps beating even when animations are off. */
body.no-animations .footer-trakteer-btn svg {
  animation-duration: 1.6s !important;
}

body.no-animations .footer-trakteer-btn:hover svg {
  animation-duration: 0.8s !important;
}

/* When animations are off, the form drops its shadow so it paints as a plain opaque box. */
html:not(.sidebar-view) body.no-animations #view-form {
  box-shadow: none;
}

.settings-toggle:hover {
  filter: brightness(0.94);
}

.settings-toggle.on {
  background: var(--primary);
}

.settings-toggle.on::after {
  transform: translateX(15px);
}

.settings-accent-row {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 2px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
}

.accent-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
}

.accent-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.accent-swatch:hover {
  transform: scale(1.15);
}

.accent-swatch.active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text-main);
}

.accent-swatch-custom {
  background: conic-gradient(#f43f5e, #f59e0b, #10b981, #0ea5e9, #8b5cf6, #f43f5e);
}

.accent-swatch-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.accent-swatch-reset:hover {
  color: var(--primary-text);
  background: var(--primary-light);
}

.style-dropdown {
  position: relative;
  flex-shrink: 0;
}

.style-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  width: auto;
  min-width: 132px;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--settings-well);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.style-trigger:hover,
.style-trigger.open {
  border-color: var(--primary-border);
  background: color-mix(in srgb, var(--settings-well) 85%, var(--text-main));
}

.style-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.style-trigger-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6366f1;
}

.style-trigger svg {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.style-trigger.open svg {
  transform: rotate(180deg);
}

.style-menu {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  top: calc(100% + 4px);
  right: 0;
  min-width: 168px;
  max-height: 210px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
  padding: 6px;
  z-index: 75;
}

.style-option {
  width: 100%;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.style-option-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.style-option:hover,
.style-option.selected {
  background: var(--primary-light);
  color: var(--primary-text);
}

/* Soft red tint instead of solid red, so the button blends with the extension theme. */
.footer-trakteer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--danger-border);
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger-solid);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.footer-trakteer-btn:hover {
  background: var(--danger-border);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(190, 30, 45, 0.15);
}

.footer-trakteer-btn span {
  display: inline-block;
  transition: transform 0.2s ease;
}

.footer-trakteer-btn:hover span {
  transform: translateY(-1px);
}

.footer-trakteer-btn svg {
  transform-box: fill-box;
  transform-origin: center;
  animation: trakteer-heart-beat 1.6s ease-in-out infinite;
}

.footer-trakteer-btn:hover svg {
  animation-duration: 0.8s;
}

@keyframes trakteer-heart-beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.35); }
  30% { transform: scale(1); }
  45% { transform: scale(1.2); }
  60% { transform: scale(1); }
}

.trakteer-modal-card {
  height: 520px;
}

.trakteer-modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Crop the embed to the banner: shift the frame up past its header, and widen it to hide its scrollbar. */
.trakteer-frame-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}

.trakteer-frame {
  width: calc(100% + 15px);
  height: calc(100% + 105px);
  /* Shift the frame up to the banner and center the wider frame so the payment button stays centered. */
  margin-top: -105px;
  margin-left: -7.5px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  /* Trakteer's page follows the system theme, so force its light theme here. */
  color-scheme: light;
}

.settings-menu-item .settings-toggle {
  margin-left: auto;
}

.settings-menu-item.settings-row-collapsed,
.settings-modal-row.settings-row-collapsed {
  height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.settings-version-badge {
  padding: 2px 6px;
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 22px 16px;
  color: var(--text-muted);
}

.empty-state p {
  margin: 8px 0 0;
  font-size: 12.5px;
}

/* Form View */
.form-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.form-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

html:not(.sidebar-view) #view-form {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 78;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 18px 36px -8px rgba(0, 0, 0, 0.35);
}

html:not(.sidebar-view) body.form-open .app-wrapper {
  pointer-events: none;
}

html:not(.sidebar-view) body.form-open #view-form {
  pointer-events: auto;
}

/* Modals open from the form (e.g. Discard Changes) live inside .app-wrapper too, so re-enable clicks on them while the form is open. */
html:not(.sidebar-view) body.form-open .modal-backdrop {
  pointer-events: auto;
}

html:not(.sidebar-view) body[data-style="glass"] #view-form {
  backdrop-filter: blur(20px) saturate(140%);
}

body:not(.no-animations) #view-form:not(.hidden) {
  animation: form-page-slide-in 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

body:not(.no-animations) #view-form.form-exiting {
  animation: form-page-slide-out 0.32s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes form-page-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes form-page-slide-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

#view-form .rich-editor {
  min-height: 300px;
  max-height: none;
}

html:not(.sidebar-view) body.form-open {
  height: 600px;
  display: flex;
  flex-direction: column;
}

html:not(.sidebar-view) body.form-open .app-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* The container above the footer is what grows and shrinks with the popup
   while the form is open: the list view fills the grown wrapper and the
   footer is pushed to the bottom. The form itself still covers the footer. */
html:not(.sidebar-view) body.form-open #view-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

html:not(.sidebar-view) body.form-open .list-footer {
  margin-top: auto;
}

html:not(.sidebar-view) body.form-open #view-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

html:not(.sidebar-view) body.form-open #view-form > .form-group {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

html:not(.sidebar-view) body.form-open #view-form .editor-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

html:not(.sidebar-view) body.form-open #view-form .rich-editor {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.label-optional {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-modern {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
}

.input-modern:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

body[data-style="glass"] .input-modern {
  border-color: var(--border-soft);
}

body[data-style="glass"] .input-modern:focus {
  border-color: var(--primary);
}

/* Dropdown Kategori (Pilih Kategori Ada atau Ketik Baru) */
.category-combobox {
  position: relative;
}

.category-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.category-input {
  padding-right: 30px;
}

.category-dropdown-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.category-dropdown-btn:hover,
.category-dropdown-btn.open {
  background: var(--primary-light);
  color: var(--primary-text);
}

.category-dropdown-menu {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 175px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 24px -6px rgba(0, 0, 0, 0.25);
  padding: 6px;
  z-index: 75;
}

.category-option {
  width: 100%;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.category-option:hover,
.category-option.selected {
  background: var(--primary-light);
  color: var(--primary-text);
}

.category-option-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  flex-shrink: 0;
}

.category-option-new {
  border-top: 1px solid var(--border-soft);
  margin-top: 3px;
  padding-top: 7px;
  border-radius: 0 0 6px 6px;
  color: var(--primary-text);
  font-weight: 600;
}

/* Editor Container */
.editor-container {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: visible;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.editor-toolbar-primary > .tool-group > button,
.editor-toolbar-primary > .tool-dropdown-wrap > button,
.editor-toolbar-secondary .tool-group > button,
.editor-toolbar-tertiary .tool-group > button,
.editor-toolbar-secondary .tool-dropdown-wrap > button,
.editor-toolbar-tertiary .tool-dropdown-wrap > button {
  padding: 0 6px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  transition: all 0.12s;
}

.editor-toolbar-primary > .tool-group > button:hover,
.editor-toolbar-primary > .tool-dropdown-wrap > button:hover,
.editor-toolbar-secondary .tool-group > button:hover,
.editor-toolbar-tertiary .tool-group > button:hover,
.editor-toolbar-secondary .tool-dropdown-wrap > button:hover,
.editor-toolbar-tertiary .tool-dropdown-wrap > button:hover {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.editor-toolbar-primary > .tool-group > button:disabled,
.editor-toolbar-primary > .tool-dropdown-wrap > button:disabled,
.editor-toolbar-secondary .tool-group > button:disabled,
.editor-toolbar-tertiary .tool-group > button:disabled,
.editor-toolbar-secondary .tool-dropdown-wrap > button:disabled,
.editor-toolbar-tertiary .tool-dropdown-wrap > button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.editor-toolbar-primary > .tool-group > button:disabled:hover,
.editor-toolbar-primary > .tool-dropdown-wrap > button:disabled:hover,
.editor-toolbar-secondary .tool-group > button:disabled:hover,
.editor-toolbar-tertiary .tool-group > button:disabled:hover,
.editor-toolbar-secondary .tool-dropdown-wrap > button:disabled:hover,
.editor-toolbar-tertiary .tool-dropdown-wrap > button:disabled:hover {
  background: transparent;
  color: var(--text-secondary);
}

.editor-toolbar-primary > .tool-group > button.active-tool,
.editor-toolbar-primary > .tool-dropdown-wrap > button.active-tool,
.editor-toolbar-secondary .tool-group > button.active-tool,
.editor-toolbar-tertiary .tool-group > button.active-tool,
.editor-toolbar-secondary .tool-dropdown-wrap > button.active-tool,
.editor-toolbar-tertiary .tool-dropdown-wrap > button.active-tool {
  background-color: var(--primary-light);
  color: var(--primary-text);
}

.tool-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-tool-split {
  padding: 0 6px !important;
  gap: 2px !important;
}

.caret-icon {
  opacity: 0.75;
}

.tool-divider {
  width: 1px;
  height: 16px;
  background-color: var(--border-color);
  margin: 0 3px;
}

/* Popover Bullet & Number Style */
.list-style-popover {
  position: absolute;
  top: 32px;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  padding: 8px;
  z-index: 75;
}

.bullet-popover {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 6px;
}

.number-popover {
  display: grid;
  grid-template-columns: repeat(3, 62px);
  gap: 6px;
}

.list-style-option {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg-page);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.list-style-option:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.list-style-option.active-style {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.preview-default-bullet,
.preview-uniform-bullet {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.preview-default-bullet > span,
.preview-uniform-bullet > span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.b-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.b-circle {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1.3px solid var(--text-secondary);
  background: transparent;
  flex-shrink: 0;
}

.b-square {
  width: 5px;
  height: 5px;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.b-bar {
  height: 2px;
  flex: 1;
  border-radius: 2px;
  background: var(--text-muted);
}

.preview-num-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.preview-num-stack > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-num-stack b {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 14px;
  text-align: left;
  line-height: 1.1;
}

.n-bar {
  height: 2px;
  flex: 1;
  border-radius: 2px;
  background: var(--text-muted);
}

/* Line Height Dropdown Menu */
.line-height-menu {
  position: absolute;
  top: 32px;
  left: 0;
  min-width: 84px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  padding: 6px;
  z-index: 75;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.line-height-item:hover {
  background: var(--primary-light);
  color: var(--primary-text);
}

.line-height-item.active-lh {
  background: var(--primary-light);
  color: var(--primary-text);
  font-weight: 700;
}

/* Popover Sisipkan Tabel & Variabel */
.insert-table-popover {
  position: absolute;
  width: 254px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.2);
  padding: 8px 13px;
  z-index: 75;
  color: var(--text-main);
}

.insert-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.insert-table-header strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.popover-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-size-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-text);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.3;
}

.var-name-field {
  width: 100%;
  margin-bottom: 7px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-page);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.var-name-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.var-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 5px 0 4px;
}

.var-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.var-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.var-chip:hover {
  background: var(--primary-light);
  color: var(--primary-text);
  border-color: var(--primary-border);
  transform: translateY(-1px);
}

.var-chip-auto {
  border-style: dashed;
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--primary-text);
}

.var-chip-auto:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.table-grid-picker {
  display: grid;
  grid-template-columns: repeat(8, 18px);
  gap: 3px;
  justify-content: center;
  outline: none;
}

.table-grid-picker:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

.table-grid-cell {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-page);
  cursor: pointer;
  transition: background-color 0.08s ease, border-color 0.08s ease;
}

.table-grid-cell.selected {
  background: var(--primary);
  border-color: var(--primary);
}

.table-grid-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
}

.find-replace-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.find-replace-field {
  display: block;
}

.find-replace-field span {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.find-replace-field input {
  display: block;
  width: 100%;
  min-width: 0;
}

.find-replace-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
}

.find-replace-actions {
  display: flex;
  gap: 4px;
  align-self: stretch;
  justify-content: flex-end;
}

#btn-find-prev,
#btn-find-next {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
}

.table-custom-toggle {
  display: inline-block;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: color 0.12s ease, background-color 0.12s ease;
}

.table-custom-toggle:hover {
  color: var(--primary-text);
  background: var(--primary-light);
}

#table-custom-inputs {
  margin-top: 10px;
}

.insert-table-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

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

.size-field > span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-page);
  transition: border-color 0.15s;
}

.stepper:focus-within {
  border-color: var(--primary);
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.stepper-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.stepper input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: none;
  border-left: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.stepper input[type="number"]::-webkit-outer-spin-button,
.stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.insert-table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}

/* Floating Bubble Toolbar Tabel */
.table-floating-toolbar {
  position: absolute;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 8px 22px -4px rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
  user-select: none;
}

.ft-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.ft-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 4px;
}

.ft-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.ft-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.ft-btn.active {
  background: var(--primary-light);
  color: var(--primary-text);
}

.ft-btn.ft-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.ft-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ft-btn:disabled:hover {
  background: transparent;
  color: var(--text-main);
}

/* Panel Pengaturan Lebar, Border & Sel Tabel */
.table-panel {
  padding: 8px 10px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11.5px;
}

.table-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-panel-close {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.table-panel-close:hover {
  background: var(--danger-border);
  color: var(--danger-solid);
}

.table-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.table-panel-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 66px;
}

.table-width-group,
.table-border-controls,
.table-cell-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.border-mode-group,
.cell-align-group,
.cell-valign-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 2px;
  border-radius: 7px;
  gap: 2px;
}

.border-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.border-mode-btn:hover {
  color: var(--text-main);
}

.border-mode-btn.active-border-mode {
  background: var(--primary-light);
  color: var(--primary-text);
}

.cell-align-btn,
.cell-valign-btn {
  width: 24px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cell-align-btn:hover,
.cell-valign-btn:hover {
  color: var(--text-main);
}

.cell-align-btn.active-align,
.cell-valign-btn.active-valign {
  background: var(--primary-light);
  color: var(--primary-text);
}

.table-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.table-width-select {
  width: 90px;
}

.border-width-select {
  width: 50px;
}

.border-style-select {
  width: 71px;
}

.table-select-native {
  display: none;
}

.table-select-trigger {
  width: 100%;
  min-width: 0;
  padding: 4px 24px 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  font-size: 11.5px;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.table-select-trigger svg {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.table-select-trigger:hover,
.table-select-trigger.open {
  background: var(--bg-card);
  border-color: var(--primary);
  color: var(--text-main);
}

.table-select-arrow {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: color 0.14s ease;
}

.table-select-trigger:hover .table-select-arrow,
.table-select-trigger.open .table-select-arrow {
  color: var(--primary-text);
}

.table-select-menu {
  z-index: 75;
}

.table-width-input {
  width: 112px;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  font-size: 11.5px;
  color: var(--text-main);
}

.table-panel input[type="color"] {
  width: 26px;
  height: 24px;
  padding: 1px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-card);
}

/* Rich Text Area */
.rich-editor {
  min-height: 160px;
  max-height: 170px;
  padding: 10px 12px;
  overflow-y: auto;
  outline: none;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  border-radius: 0 0 var(--radius) var(--radius);
}

html:not(.sidebar-view) body.editor-expanded {
  width: 760px;
}

body.editor-expanded .rich-editor {
  min-height: 300px;
  max-height: 340px;
}

/* Floating expand button at the editor's top-right corner */
/* Dropdown and popover menus use z-index 75 so they paint above this button. */
.editor-expand-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 65;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--primary);
  opacity: 0.6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  transition: all 0.15s ease;
}

.editor-expand-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  opacity: 1;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

html.sidebar-view .editor-expand-btn {
  display: none;
}

.rich-editor:empty:before,
.rich-editor.editor-empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.rich-editor.editor-empty {
  font-size: var(--editor-font-size, 13px);
}

.rich-editor ul,
.rich-editor ol {
  margin: 4px 0;
  padding-left: 22px;
}

/* Variable autocomplete (type {{ in the editor) */
.var-autocomplete {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 75;
  min-width: 200px;
  max-width: 320px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  padding: 6px;
}

.var-complete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 30px;
  padding: 5px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
}

.var-complete-item.selected,
.var-complete-item:hover {
  background: var(--primary-light);
  color: var(--primary-text);
}

.rich-editor p {
  margin: 0 0 6px;
}

.rich-editor p:last-child {
  margin-bottom: 0;
}

.rich-editor hr {
  border: none;
  border-top: 1.5px solid var(--border-color);
  margin: 10px 0;
}

.rich-editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  table-layout: fixed;
}

.rich-editor td,
.rich-editor th {
  position: relative;
  border: 1px solid var(--text-main);
  padding: 6px 8px;
  min-width: 28px;
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.rich-editor.cell-range-selecting,
.rich-editor.cell-range-selecting * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.rich-editor td.df-cell-selected,
.rich-editor th.df-cell-selected {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.rich-editor table[data-noborder="true"],
.rich-editor table[data-noborder="true"] td,
.rich-editor table[data-noborder="true"] th {
  border-color: transparent !important;
}

/* Handle Resize Kolom & Lebar Tabel */
.df-col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 15;
  background: transparent;
  transition: background-color 0.12s ease;
}

.df-col-resizer:hover,
.df-col-resizer.active {
  background: rgba(99, 102, 241, 0.55);
}

.df-row-resizer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 6px;
  cursor: row-resize;
  user-select: none;
  z-index: 15;
  background: transparent;
  transition: background-color 0.12s ease;
}

.df-row-resizer:hover,
.df-row-resizer.active {
  background: rgba(99, 102, 241, 0.55);
}

.df-table-width-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  user-select: none;
  z-index: 16;
  background: rgba(99, 102, 241, 0.16);
  border-right: 2px solid var(--primary);
  transition: background-color 0.12s ease;
}

.df-table-width-handle:hover,
.df-table-width-handle.active {
  background: rgba(99, 102, 241, 0.45);
}

.df-table-width-handle-left {
  left: -4px;
  right: auto;
  border-right: 0;
  border-left: 2px solid var(--primary);
}

/* Modal Backdrop & Cards */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 80;
}

body:not(.no-animations) .modal-backdrop:not(.hidden) {
  animation: modal-backdrop-in 0.18s ease-out;
}

body:not(.no-animations) .modal-backdrop:not(.hidden) .modal-card,
body:not(.no-animations) .modal-backdrop:not(.hidden) .image-lightbox {
  animation: modal-card-in 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

body:not(.no-animations) .modal-backdrop.modal-closing {
  animation: modal-backdrop-out 0.16s ease-in forwards;
}

body:not(.no-animations) .modal-backdrop.modal-closing .modal-card,
body:not(.no-animations) .modal-backdrop.modal-closing .image-lightbox {
  animation: modal-card-out 0.16s ease-in forwards;
}

.modal-backdrop.modal-no-open-anim {
  animation: none !important;
}

@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-backdrop-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-card-in {
  from { transform: scale(0.96) translateY(8px); }
  to { transform: scale(1) translateY(0); }
}

@keyframes modal-card-out {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(0.96) translateY(8px); }
}

.preview-popup-backdrop {
  z-index: 90;
  background: rgba(0, 0, 0, 0.35);
}

.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 18px 36px -8px rgba(0, 0, 0, 0.35);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.08s ease-out;
}

.var-preview-popup-card {
  max-height: 82vh;
}

.backup-modal-actions {
  display: flex;
  gap: 8px;
  padding: 12px 2px;
}

.backup-modal-actions .btn {
  flex: 1;
}

.backup-url-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 2px;
}

.backup-url-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0;
}

.backup-url-row {
  display: flex;
  gap: 8px;
}

.backup-url-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.backup-url-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.backup-url-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.backup-url-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.backup-restore-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 2px;
}

.backup-restore-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.backup-restore-status {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.backup-restore-block .btn {
  width: 100%;
}

.backup-auto-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 2px;
}

.backup-auto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.backup-auto-head .backup-url-label {
  margin-bottom: 0;
}

.backup-auto-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.backup-auto-settings {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 2px 0 6px;
}

.backup-auto-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.backup-auto-field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.backup-auto-badge {
  cursor: pointer;
}

.backup-auto-badge:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.backup-auto-field input[type="time"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-main);
  color-scheme: light;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

body.dark-theme .backup-auto-field input[type="time"] {
  color-scheme: dark;
}

.backup-auto-field input[type="time"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.backup-auto-field input[type="time"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.image-library-card {
  max-height: min(560px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
}

.image-library-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.image-library-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.image-library-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg-subtle);
  aspect-ratio: 1 / 1;
  min-width: 0;
}

.image-library-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.image-library-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 1;
}

.image-library-item:hover::after,
.image-library-item:focus-within::after {
  opacity: 1;
}

.image-library-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-library-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 14px 8px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.image-library-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.image-library-item:hover .image-library-actions,
.image-library-item:focus-within .image-library-actions {
  opacity: 1;
}

.image-library-action-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1f2937;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.image-library-action-btn:hover {
  background: #fff;
}

.image-library-action-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  opacity: 1;
}

.image-library-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
}

.image-library-item-uploading {
  cursor: default;
}

.image-library-item-uploading:hover::after,
.image-library-item-uploading:focus-within::after {
  opacity: 0;
}

.image-library-item-uploading .image-library-thumb {
  opacity: 0.55;
}

.image-library-uploading-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.image-library-uploading-badge .image-upload-spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

.image-lightbox-backdrop {
  background: rgba(0, 0, 0, 0.72);
  z-index: 120;
}

.image-lightbox {
  position: relative;
  width: fit-content;
  min-width: min(280px, calc(100vw - 32px));
  max-width: min(480px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.08s ease-out;
  padding: 16px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
}

.image-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

.image-lightbox-img {
  width: auto;
  max-width: 100%;
  min-height: 120px;
  max-height: 380px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 8px;
  background: #f3f4f6;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: block;
}

.image-lightbox-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.image-lightbox-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  overflow-wrap: anywhere;
}

.image-lightbox-used {
  font-size: 11px;
  color: #6b7280;
  overflow-wrap: anywhere;
}

.image-lightbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-lightbox-actions .btn {
  flex: 1;
}

.image-lightbox-remove {
  flex: 1 1 100%;
  background: none;
  border: none;
  padding: 4px;
  color: #dc2626;
  font-size: 12px;
  cursor: pointer;
}

.image-lightbox-remove:hover {
  text-decoration: underline;
}

.duplicate-import-message {
  margin: 0 0 8px;
  font-size: 13px;
}

.duplicate-import-list {
  margin: 0 0 12px;
  padding-left: 18px;
  max-height: 160px;
  overflow-y: auto;
  font-size: 13px;
}

.duplicate-import-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.image-library-card .modal-header .modal-title-group {
  flex: 1;
}

.template-preview-content {
  max-width: 100%;
  max-height: 310px;
  min-width: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}

.template-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.template-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-subtle);
}

.template-history-info {
  flex: 1;
  min-width: 0;
}

.template-history-date {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.template-history-name {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-history-empty {
  padding: 16px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

.template-history-current-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 2px 7px;
}

.template-history-select {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.template-history-compare-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.template-history-diff {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
}

.template-history-diff-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-history-diff-titles {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-history-diff-body {
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}

.template-history-diff-line {
  padding: 2px 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.template-history-diff-line.diff-add {
  background: rgba(34, 197, 94, 0.14);
}

.template-history-diff-line.diff-del {
  background: rgba(239, 68, 68, 0.14);
}

.template-history-diff-line.diff-same {
  color: var(--text-muted);
}

.template-preview-content table {
  max-width: 100%;
  table-layout: fixed;
}

.template-preview-content td,
.template-preview-content th {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.template-preview-content img,
.template-preview-content video {
  max-width: 100%;
  height: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.var-modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.btn-preview-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.btn-preview-trigger:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.var-fill-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 290px;
  padding-right: 2px;
}

.excel-import-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--bg-subtle);
}

.excel-import-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.excel-pending-file-name {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.excel-sheet-picker {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
}

.excel-sheet-picker label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.excel-sheet-picker select {
  width: 100%;
}

.excel-sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.excel-import-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.var-fill-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.var-fill-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.var-fill-item label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary-text);
}

.var-auto-tag {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 999px;
}

.var-counter-btn {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: auto;
}

.var-counter-btn:hover {
  color: var(--text-main);
  border-color: var(--border-color);
}

.var-counter-btn.active {
  color: var(--primary-text);
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.var-preview-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--primary-text);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 1px 6px;
  border-radius: 999px;
}

.var-live-preview {
  max-height: 310px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 12.5px;
  line-height: 1.5;
  word-wrap: break-word;
}

.var-live-preview p {
  margin: 0 0 6px;
}

.var-live-preview p:last-child {
  margin-bottom: 0;
}

.var-live-preview ul,
.var-live-preview ol {
  margin: 4px 0;
  padding-left: 20px;
}

.var-live-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 12px;
}

.var-live-preview td,
.var-live-preview th {
  border: 1px solid var(--border-color);
  padding: 5px 7px;
}

body.dark-theme .rich-editor,
body.dark-theme .rich-editor *,
body.dark-theme .var-live-preview,
body.dark-theme .var-live-preview * {
  color: var(--text-main) !important;
}

body.dark-theme .rich-editor table:not([data-noborder="true"]),
body.dark-theme .rich-editor table:not([data-noborder="true"]) td,
body.dark-theme .rich-editor table:not([data-noborder="true"]) th,
body.dark-theme .var-live-preview table,
body.dark-theme .var-live-preview td,
body.dark-theme .var-live-preview th {
  border-color: var(--border-color) !important;
}

body.dark-theme .rich-editor hr,
body.dark-theme .var-live-preview hr {
  border-color: var(--border-color) !important;
}

/* Modal Kelola Kategori */
.category-create-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
}

.category-manage-list {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.category-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
}

.category-manage-list .category-manage-item:last-child {
  border-bottom: none;
}

.category-manage-item-hidden .category-manage-name {
  opacity: 0.55;
}

.category-manage-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.category-manage-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-manage-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.category-manage-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.category-manage-actions .btn {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
}

.category-manage-actions .btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.category-manage-actions .btn.category-manage-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.category-manage-actions .category-manage-color-btn {
  width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
}

.category-rename-input {
  flex: 1;
  min-width: 0;
}

.category-manage-footer {
  padding: 12px 2px;
  border-top: 1px solid var(--border-soft);
}

.category-manage-footer .btn {
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Modal Konfirmasi Hapus Kustom */
.delete-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.delete-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  flex-shrink: 0;
}

.delete-modal-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 2px;
}

.delete-confirm-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-main);
  word-break: break-word;
}

.delete-confirm-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* Form Actions */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 33px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0f172a;
  color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  z-index: 100;
  white-space: nowrap;
}

.toast.error {
  background-color: var(--danger-solid);
  border-color: var(--danger-solid);
}

.hidden {
  display: none !important;
}

/* File inputs triggered by .click(): keep them rendered but off-screen.
   Firefox ignores .click() on a display:none file input, so the picker never opens. */
.file-input-hidden {
  position: fixed !important;
  left: -9999px !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

body {
  padding: 12px;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app-wrapper {
  padding: 16px 16px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(39, 39, 75, 0.08);
}

.app-header {
  margin-bottom: 14px;
  padding-bottom: 13px;
}

.brand {
  gap: 11px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 5px 12px color-mix(in srgb, var(--accent) 22%, transparent);
}

.brand-icon img {
  height: 26px;
  width: auto;
  display: block;
}

.app-header h1 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.subtitle {
  display: inline-block;
  margin-top: 3px;
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

.header-version-badge {
  padding: 2px 7px;
  font-size: 9px;
  letter-spacing: 0.02em;
}

.btn {
  min-height: 34px;
  border-radius: 8px;
  font-weight: 650;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.btn-primary {
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.16);
}

.btn-primary:hover {
  box-shadow: 0 6px 14px rgba(99, 102, 241, 0.22);
  transform: translateY(-1px);
}

#btn-show-add {
  min-height: 36px;
  padding-inline: 13px;
}

.search-box {
  margin-bottom: 11px;
}

#search-input {
  min-height: 38px;
  padding-top: 9px;
  padding-bottom: 9px;
  border-radius: 11px;
  background: var(--bg-card);
  box-shadow: 0 2px 5px rgba(39, 39, 75, 0.035);
}

.category-tabs {
  gap: 7px;
}

.category-tab {
  padding: 6px 10px;
  border-color: transparent;
  background: var(--bg-subtle);
  font-size: 11px;
}

.category-tab.active {
  box-shadow: 0 3px 8px rgba(99, 102, 241, 0.18);
}

.list-container {
  max-height: 410px;
}

.template-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.template-meta-row {
  margin-top: 4px;
}

.template-category-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.01em;
}

.template-actions-column {
  gap: 5px;
}

.template-actions {
  gap: 2px;
}

.btn-use {
  min-height: 30px;
  padding: 5px 12px;
  border-color: var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 11.5px;
  box-shadow: none;
  margin-right: 4px;
}

.btn-use:hover {
  background: var(--primary-hover);
  border-color: var(--primary);
  color: #fff;
  box-shadow: none;
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-muted);
}

.template-excel-progress {
  width: 190px;
}

.template-excel-progress-bar {
  height: 5px;
  background: var(--border-soft);
}

.template-excel-progress-fill {
  background: linear-gradient(90deg, var(--primary), #818cf8);
}

.list-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-color: var(--border-soft);
}

.btn-setting-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border-color: var(--border-soft);
  background: var(--bg-subtle);
}

.template-more-menu,
.category-dropdown-menu,
.list-style-popover,
.line-height-menu,
.insert-table-popover,
.table-select-menu {
  border-color: var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.settings-menu-item {
  min-height: 34px;
  border-radius: 8px;
}

.empty-state {
  padding: 28px 18px;
}

.form-header {
  margin-bottom: 14px;
}

.form-header h2 {
  font-size: 17px;
  letter-spacing: -0.025em;
}

.form-row-2col {
  gap: 10px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  margin-bottom: 6px;
  font-size: 11.5px;
  letter-spacing: 0.01em;
}

.input-modern {
  min-height: 37px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg-card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.editor-container {
  border-color: var(--border-color);
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(39, 39, 75, 0.04);
}

.editor-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 7px 8px;
  background: var(--bg-subtle);
  border-radius: 13px 13px 0 0;
}

.editor-toolbar-primary,
.editor-toolbar-secondary,
.editor-toolbar-tertiary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.editor-toolbar-primary {
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-soft);
}

.editor-toolbar-primary .tool-divider {
  margin: 0 1px;
}

.editor-toolbar-secondary {
  flex-wrap: nowrap;
  gap: 2px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-soft);
}

.editor-toolbar-tertiary {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.editor-toolbar-tertiary .tool-group {
  flex-shrink: 0;
}

.editor-toolbar-tertiary .tool-divider {
  margin: 0 3px;
  flex-shrink: 0;
}

.editor-toolbar-secondary .tool-group {
  flex-shrink: 0;
}

.editor-toolbar-secondary .tool-divider {
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar-more-group {
  margin-left: auto;
}

.toolbar-more-btn svg {
  transform: rotate(180deg);
  transition: transform 0.18s ease;
}

.editor-toolbar.toolbar-rows-collapsed .toolbar-more-btn svg {
  transform: rotate(0deg);
}

.editor-toolbar.toolbar-rows-collapsed .editor-toolbar-secondary,
.editor-toolbar.toolbar-rows-collapsed .editor-toolbar-tertiary {
  display: none;
}

.editor-toolbar.toolbar-rows-collapsed .editor-toolbar-primary {
  padding-bottom: 0;
  border-bottom: none;
}

.editor-toolbar-secondary .tool-group > button,
.editor-toolbar-tertiary .tool-group > button,
.editor-toolbar-secondary .tool-dropdown-wrap > button,
.editor-toolbar-tertiary .tool-dropdown-wrap > button {
  height: 28px;
  min-width: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-page);
}

.editor-toolbar-primary > .tool-group > button,
.editor-toolbar-primary > .tool-dropdown-wrap > button {
  height: 26px;
  min-width: 26px;
  padding: 0 4px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-page);
}

.editor-toolbar-primary .toolbar-color-picker {
  position: relative;
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  margin: 0;
  cursor: pointer;
}

.toolbar-color-trigger {
  position: relative;
  display: inline-flex;
  width: 26px;
  height: 26px;
  min-width: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-page);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.toolbar-color-trigger > svg {
  transform: translateY(-2px);
}

.toolbar-color-trigger:hover,
.toolbar-color-trigger.active-tool {
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--primary-text);
}

.toolbar-color-trigger:focus-visible,
.toolbar-color-close:focus-visible,
.toolbar-color-swatch:focus-visible,
.toolbar-color-reset:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.toolbar-color-indicator {
  position: absolute;
  bottom: 3px;
  left: 50%;
  width: 12px;
  height: 3px;
  border: 1px solid rgba(32, 32, 51, 0.18);
  border-radius: 999px;
  transform: translateX(-50%);
}

.toolbar-color-popover {
  position: absolute;
  z-index: 75;
  width: 264px;
  max-width: calc(100vw - 32px);
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
  color: var(--text-main);
}

.toolbar-color-popover-header,
.toolbar-color-current,
.toolbar-color-hue {
  display: flex;
  align-items: center;
}

.toolbar-color-popover-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.toolbar-color-popover-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toolbar-color-popover-title strong {
  font-size: 12px;
  font-weight: 700;
}

.toolbar-color-popover-title span,
.toolbar-color-hue > span {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
}

.toolbar-color-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toolbar-color-close:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.toolbar-color-current {
  gap: 9px;
  margin-bottom: 10px;
}

.toolbar-color-preview {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.editor-container .toolbar-color-hex,
.settings-modal-card .toolbar-color-hex {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-page);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.toolbar-color-hex input {
  width: 82px;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font: 600 11px "Plus Jakarta Sans", sans-serif;
  text-align: right;
  text-transform: uppercase;
}

.toolbar-color-hex:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.toolbar-color-surface {
  position: relative;
  height: 124px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background-color: var(--picker-hue, #f2d422);
  background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent);
  cursor: crosshair;
  touch-action: none;
}

.toolbar-color-handle {
  position: absolute;
  top: 0;
  left: 100%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(25, 25, 40, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.editor-container .toolbar-color-hue,
.settings-modal-card .toolbar-color-hue {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 11px 0 0;
}

.toolbar-color-hue > span {
  width: 26px;
}

.toolbar-color-hue input {
  width: auto;
  min-width: 0;
  flex: 1;
  height: 16px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
}

.toolbar-color-hue input::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  appearance: none;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-border), 0 1px 3px rgba(0, 0, 0, 0.24);
}

.toolbar-color-hue input::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-border), 0 1px 3px rgba(0, 0, 0, 0.24);
}

.toolbar-color-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
  padding: 12px 1px 10px;
}

.toolbar-color-swatch {
  width: 20px;
  height: 20px;
  justify-self: center;
  padding: 0;
  border: 1px solid rgba(32, 32, 51, 0.18);
  border-radius: 6px;
  background: var(--swatch-color);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.toolbar-color-swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(24, 24, 48, 0.2);
}

.toolbar-color-swatch[aria-pressed="true"] {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.toolbar-color-reset {
  width: 100%;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.toolbar-color-reset:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--primary-text);
}

.editor-toolbar-primary > .tool-group > button:hover,
.editor-toolbar-primary > .tool-dropdown-wrap > button:hover,
.editor-toolbar-secondary .tool-group > button:hover,
.editor-toolbar-tertiary .tool-group > button:hover,
.editor-toolbar-secondary .tool-dropdown-wrap > button:hover,
.editor-toolbar-tertiary .tool-dropdown-wrap > button:hover,
.editor-toolbar-primary > .tool-group > button.active-tool,
.editor-toolbar-primary > .tool-dropdown-wrap > button.active-tool,
.editor-toolbar-secondary .tool-group > button.active-tool,
.editor-toolbar-tertiary .tool-group > button.active-tool,
.editor-toolbar-secondary .tool-dropdown-wrap > button.active-tool,
.editor-toolbar-tertiary .tool-dropdown-wrap > button.active-tool {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary-text);
}

.paragraph-style-button {
  min-width: 90px !important;
  justify-content: space-between !important;
  padding: 0 8px !important;
  white-space: nowrap;
}

.paragraph-style-menu {
  position: absolute;
  top: 34px;
  left: 0;
  z-index: 75;
  display: flex;
  min-width: 150px;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.paragraph-style-option {
  width: 100%;
  min-width: 0 !important;
  height: 30px !important;
  justify-content: flex-start !important;
  padding: 5px 10px !important;
  border: none !important;
  border-radius: 8px;
  background: transparent !important;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  outline: none;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.paragraph-style-option:hover {
  background: var(--primary-light) !important;
  color: var(--primary-text) !important;
}

.paragraph-style-option.active-style {
  background: var(--primary-light) !important;
  color: var(--primary-text) !important;
  font-weight: 700;
}

.paragraph-style-option:focus-visible {
  outline: 2px solid var(--primary-border);
  outline-offset: 1px;
}

.font-family-button {
  min-width: 100px !important;
  max-width: 100px !important;
  justify-content: space-between !important;
  padding: 0 8px !important;
  white-space: nowrap;
}

#font-family-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.font-family-button .caret-icon {
  flex-shrink: 0;
}

.font-size-button {
  min-width: 58px !important;
  justify-content: space-between !important;
  padding: 0 8px !important;
  white-space: nowrap;
}

.font-menu {
  position: absolute;
  top: 34px;
  left: 0;
  z-index: 75;
  display: flex;
  min-width: 150px;
  max-height: 260px;
  flex-direction: column;
  gap: 2px;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.font-option,
.line-height-item {
  width: 100%;
  min-width: 0 !important;
  height: 30px !important;
  flex-shrink: 0;
  justify-content: flex-start !important;
  padding: 5px 10px !important;
  border: none !important;
  border-radius: 8px;
  background: transparent !important;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  outline: none;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.font-option:hover {
  background: var(--primary-light) !important;
  color: var(--primary-text) !important;
}

.font-option.active-style {
  background: var(--primary-light) !important;
  color: var(--primary-text) !important;
  font-weight: 700;
}

.font-option:focus-visible {
  outline: 2px solid var(--primary-border);
  outline-offset: 1px;
}

.font-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-word-count {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

#font-size-menu {
  top: 32px;
  min-width: 84px;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
}

#font-size-menu .font-option {
  justify-content: center !important;
  text-align: center;
}

#line-height-menu .font-option {
  justify-content: center !important;
  text-align: center;
}

.horizontal-line-menu {
  position: absolute;
  top: 34px;
  right: 0;
  left: auto;
  z-index: 75;
  display: flex;
  width: 154px;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.horizontal-line-option {
  display: flex;
  width: 100%;
  height: 30px;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.horizontal-line-option:hover {
  background: var(--primary-light);
  color: var(--primary-text);
}

.horizontal-line-option.active-line-style {
  background: var(--primary-light);
  color: var(--primary-text);
  font-weight: 700;
}

.horizontal-line-option:focus-visible {
  outline: 2px solid var(--primary-border);
  outline-offset: 1px;
}

.insert-image-menu {
  position: absolute;
  top: 34px;
  right: 0;
  left: auto;
  z-index: 75;
  display: flex;
  width: 180px;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.insert-image-option {
  display: flex;
  width: 100%;
  height: 30px;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.insert-image-option svg {
  flex: 0 0 auto;
}

.insert-image-option:hover {
  background: var(--primary-light);
  color: var(--primary-text);
}

.insert-image-option:focus-visible {
  outline: 2px solid var(--primary-border);
  outline-offset: 1px;
}

.editor-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.template-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.attachment-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 500;
  cursor: default;
  outline: none;
}

.attachment-badge-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--text-muted);
}

.attachment-badge-count {
  white-space: nowrap;
}

.attachment-badge-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 75;
  display: none;
  min-width: 220px;
  max-width: 320px;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 14px 32px rgba(24, 24, 48, 0.16);
}

.attachment-badge-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 6px;
}

.attachment-badge:hover .attachment-badge-popup,
.attachment-badge:focus-within .attachment-badge-popup,
.attachment-badge-popup-open .attachment-badge-popup {
  display: block;
}

.attachment-popup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 8px;
}

.attachment-popup-row:hover {
  background: var(--bg-subtle);
}

.attachment-popup-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-main);
}

.attachment-popup-remove {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.attachment-popup-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.attachment-popup-row-uploading {
  opacity: 0.75;
}

.attachment-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.rich-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.image-upload-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11.5px;
}

.image-upload-spinner,
.attachment-chip-spinner {
  flex: 0 0 auto;
  border: 2px solid var(--border-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: image-upload-spin 0.8s linear infinite;
}

.image-upload-spinner {
  width: 14px;
  height: 14px;
}

.attachment-chip-spinner {
  width: 12px;
  height: 12px;
}

@keyframes image-upload-spin {
  to { transform: rotate(360deg); }
}

.horizontal-line-preview {
  display: inline-flex;
  width: 44px;
  flex: 0 0 44px;
  align-items: center;
}

.horizontal-line-preview::before {
  width: 100%;
  border-top: 1.5px solid currentColor;
  content: "";
}

.line-preview-double::before {
  border-top: 3px double currentColor;
}

.line-preview-dotted::before {
  border-top: 2px dotted currentColor;
}

.line-preview-dashed::before {
  border-top: 2px dashed currentColor;
}

.line-preview-thick::before {
  border-top: 3px solid currentColor;
}

.rich-editor {
  min-height: 160px;
  max-height: 170px;
  padding: 13px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3 {
  margin: 0.5em 0;
  line-height: 1.25;
}

.rich-editor h1 {
  font-size: 1.7em;
}

.rich-editor h2 {
  font-size: 1.4em;
}

.rich-editor h3 {
  font-size: 1.15em;
}

.rich-editor blockquote {
  margin: 8px 0;
  padding: 5px 10px;
  border-left: 3px solid var(--primary);
  background: var(--bg-subtle);
}

.rich-editor pre {
  overflow-x: auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.table-panel {
  border-color: var(--border-soft);
  border-radius: 0 0 13px 13px;
}

.form-actions {
  gap: 9px;
  margin-top: 14px;
}

.form-actions .btn {
  min-width: 88px;
}

.modal-backdrop {
  background: rgba(24, 24, 48, 0.52);
  backdrop-filter: blur(3px);
}

.modal-card {
  padding: 16px;
  border-color: var(--border-soft);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(9, 28, 23, 0.25);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.var-fill-fields {
  gap: 10px;
}

.excel-import-section {
  padding: 10px;
  border-color: var(--border-soft);
  border-radius: 12px;
}

.var-live-preview {
  border-color: var(--border-soft);
  border-radius: 12px;
}

.delete-modal-body {
  gap: 7px;
  padding: 6px 0 4px;
}

.toast {
  border: 0;
  background: #262640;
  box-shadow: 0 8px 24px rgba(24, 24, 48, 0.24);
}

body.dark-theme .app-wrapper {
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

@media (max-width: 380px) {
  .app-wrapper {
    padding: 13px 12px 10px;
  }

  .form-row-2col {
    grid-template-columns: 1fr;
    gap: 0;
  }
}