:root {
  --gold-1: #fbeec1;
  --gold-2: #e8c46a;
  --gold-3: #bd8a2e;
  --gold-4: #7c5716;
  --gold-grad: linear-gradient(135deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3) 80%);
  --silver-1: #f4f6f9;
  --silver-2: #c7cedb;
  --silver-3: #8891a2;
  --silver-grad: linear-gradient(135deg, var(--silver-1), var(--silver-2) 60%, var(--silver-3));

  --navy-deep: #05070d;
  --navy: #0b1120;
  --navy-light: #1c2942;

  --glass: rgba(8, 12, 24, 0.58);
  --glass-strong: rgba(8, 12, 24, 0.76);
  --glass-border: rgba(232, 196, 106, 0.28);
  --hairline: rgba(255, 255, 255, 0.1);

  --text: #f1f3f8;
  --text-dim: #a6afc4;

  --green: #7be0a8; --green-bg: rgba(123, 224, 168, 0.14); --green-border: rgba(123, 224, 168, 0.35);
  --amber: #f0cf7d; --amber-bg: rgba(240, 207, 125, 0.14); --amber-border: rgba(240, 207, 125, 0.35);
  --red: #f0918a; --red-bg: rgba(240, 145, 138, 0.14); --red-border: rgba(240, 145, 138, 0.35);
  --blue: #8fb3ef; --blue-bg: rgba(143, 179, 239, 0.14); --blue-border: rgba(143, 179, 239, 0.35);

  --radius: 14px;
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: #bcd6ee;
  background-image:
    linear-gradient(180deg, rgba(8, 12, 24, 0.12) 0%, rgba(8, 12, 24, 0.2) 55%, rgba(8, 12, 24, 0.36) 100%),
    url("bg-courthouse.jpg");
  background-size: cover, cover;
  background-position: center top, center top;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: linear-gradient(var(--gold-3), var(--gold-4)); border-radius: 10px; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 30px;
  background: linear-gradient(180deg, rgba(15, 20, 36, 0.656), rgba(10, 14, 26, 0.624));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  height: 112px; width: auto; display: block;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.55));
}
.topbar-actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 9px; padding: 9px 17px; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: all .15s ease; white-space: nowrap; letter-spacing: 0.1px;
}
.btn.primary {
  background: var(--gold-grad);
  color: #241a05;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 6px 16px rgba(189, 138, 46, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.ghost {
  background: var(--glass);
  color: var(--silver-1);
  border: 1px solid rgba(199, 206, 219, 0.28);
  backdrop-filter: blur(6px);
}
.btn.ghost:hover { background: var(--glass-strong); border-color: rgba(199, 206, 219, 0.5); }
.btn.danger { background: var(--glass); color: var(--red); border: 1px solid var(--red-border); }
.btn.danger:hover { background: var(--red-bg); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; filter: none !important; }
.btn.big { padding: 15px 24px; font-size: 14.5px; border-radius: 11px; }

#view-root { flex: 1; padding: 30px; max-width: 1180px; margin: 0 auto; width: 100%; }

/* ---------- Footer ---------- */
.app-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 15px;
  padding: 13.5px 45px;
  background: linear-gradient(180deg, rgba(15, 20, 36, 0.52), rgba(10, 14, 26, 0.5));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.04) inset, 0 -10px 30px rgba(0, 0, 0, 0.25);
}
.footer-copyright { font-size: 17.25px; color: var(--text-dim); }
.footer-badges { display: flex; gap: 12px; flex-wrap: wrap; }
.footer-badge {
  font-size: 16.5px; font-weight: 600; color: var(--text-dim);
  background: rgba(255,255,255,0.05); border: 1px solid var(--hairline); border-radius: 999px;
  padding: 6px 15px; white-space: nowrap;
}

/* ---------- Dashboard ---------- */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }
.case-card {
  position: relative;
  background: linear-gradient(160deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 19px;
  cursor: pointer; transition: box-shadow .18s ease, transform .12s ease, border-color .18s ease;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.case-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--glass-border); }
.case-card.dragging { opacity: 0.4; box-shadow: none; transform: none; }
.case-card h3 { margin: 0 0 4px; font-size: 16px; color: var(--silver-1); padding-right: 34px; padding-left: 18px; }
.card-drag-handle {
  position: absolute; top: 12px; left: 12px; color: var(--text-dim); font-size: 15px;
  cursor: grab; line-height: 1; user-select: none;
}
.case-card:active .card-drag-handle, .card-drag-handle:active { cursor: grabbing; }
.card-delete-btn {
  position: absolute; top: 12px; right: 12px;
  border: none; background: rgba(0,0,0,0.25); color: var(--text-dim); border-radius: 7px;
  width: 34px; height: 34px; font-size: 19px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.card-delete-btn:hover { background: var(--red-bg); color: var(--red); }
.case-card .parties { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }
.case-card .meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

.empty-state { text-align: center; padding: 70px 20px; color: var(--text-dim); }
.empty-state .big-icon { font-size: 42px; margin-bottom: 12px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.empty-state h2 { color: var(--silver-1); }

.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; border: 1px solid transparent; }
.badge.collecting { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.badge.outline { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.badge.script { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge.pending { background: rgba(255,255,255,0.06); color: var(--text-dim); border-color: var(--hairline); }
.badge.processing { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-border); }
.badge.done { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge.error { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }
.badge.ready { background: rgba(255,255,255,0.06); color: var(--text-dim); border-color: var(--hairline); }
.badge.processed-yes { background: rgba(46, 160, 67, 0.14); color: #1a7a2e; border-color: rgba(46, 160, 67, 0.4); }
.badge.processed-no { background: rgba(217, 48, 37, 0.12); color: #c0281b; border-color: rgba(217, 48, 37, 0.38); }
.badge.cancelled { background: rgba(255,255,255,0.06); color: var(--text-dim); border-color: var(--hairline); }

.hidden { display: none !important; }

/* ---------- Case detail ---------- */
.case-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.case-header-main { display: grid; grid-template-columns: auto auto; column-gap: 16px; row-gap: 4px; align-items: baseline; }
.case-header h1 {
  margin: 0; font-size: 23px;
  color: #ffffff;
}
.case-header .parties { color: #ffffff; font-size: 23px; font-weight: 700; }
.back-link { display: inline-block; margin-bottom: 0; color: var(--gold-2); text-decoration: none; font-size: 27px; font-weight: 700; cursor: pointer; }
.back-link:hover { color: var(--gold-1); text-decoration: underline; }

.stepper {
  display: flex; gap: 4px; margin-bottom: 26px;
  background: var(--glass); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stepper button {
  flex: 1; background: none; border: none; padding: 10px 6px; border-radius: 999px; font-size: 12.8px; font-weight: 700;
  color: var(--text-dim); cursor: pointer; transition: all .15s ease;
}
.stepper button.active { background: var(--gold-grad); color: #241a05; box-shadow: 0 4px 14px rgba(189,138,46,.3); }
.stepper button:hover:not(.active) { background: var(--glass-strong); color: var(--silver-1); }

.panel {
  background: linear-gradient(160deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 24px; margin-bottom: 18px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lift);
}
.panel h2 {
  margin-top: 0; font-size: 17.5px;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  display: inline-block;
}
.panel p.desc { color: var(--text-dim); font-size: 14.5px; margin-top: -6px; }

.pending-hint {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  background: var(--blue-bg); border: 1px solid var(--blue-border); color: var(--text);
  border-radius: 9px; padding: 12px 16px; font-size: 12.8px; line-height: 1.5; margin: 14px 0 6px;
}
.pending-hint .btn { flex-shrink: 0; padding: 7px 13px; font-size: 12.5px; }

.folder-group-title { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gold-2); margin: 20px 0 8px; opacity: 0.9; }
.folder-group-title:first-child { margin-top: 0; }
.group-icons { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.group-icon { height: 32px; width: 32px; display: block; object-fit: contain; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4)); }

/* ---------- Case Files: two-column layout ---------- */
.files-layout { display: flex; gap: 20px; margin-top: 16px; align-items: flex-start; }

.files-nav { flex: 0 0 400px; max-height: 792px; overflow-y: auto; padding-right: 6px; }

.folder-nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 4px; cursor: pointer;
  font-size: 13.8px; color: var(--text-dim); transition: background .15s ease, color .15s ease;
  border: 1px solid transparent;
}
.folder-nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.folder-nav-item.active { background: var(--gold-grad); color: #241a05; font-weight: 700; box-shadow: 0 4px 14px rgba(189,138,46,.3); }
.folder-nav-item .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-nav-item .fcount-group { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.folder-nav-item .fcount {
  font-size: 12px; font-weight: 700; min-width: 20px; text-align: center;
  padding: 1px 7px; border-radius: 999px;
}
.folder-nav-item .fcount-unprocessed { background: rgba(217, 48, 37, 0.22); color: #ffb3ab; }
.folder-nav-item .fcount-processed { background: rgba(46, 160, 67, 0.24); color: #9be8ac; }
.folder-nav-item.active .fcount-unprocessed { background: rgba(217, 48, 37, 0.16); color: #7a1f16; }
.folder-nav-item.active .fcount-processed { background: rgba(46, 160, 67, 0.2); color: #14591f; }

.files-viewer {
  flex: 1; min-width: 0;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 20px;
  color: #1a1f2e;
  display: flex; flex-direction: column;
  max-height: 792px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06), 0 20px 50px rgba(0,0,0,0.35);
}
.viewer-head {
  flex-shrink: 0; display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.1);
}
.viewer-head h3 { margin: 0; font-size: 16.5px; color: #1a1f2e; }
.viewer-head .fcount { font-size: 12.5px; color: #5b6472; }
.viewer-file-list { flex: 1; overflow-y: auto; margin-top: 4px; }
.viewer-empty { color: #7a8290; font-size: 13px; padding: 40px 0; text-align: center; }

.folder-drop {
  flex-shrink: 0;
  border: 1.5px dashed rgba(0, 0, 0, 0.2); border-radius: 8px; padding: 15px;
  text-align: center; color: #5b6472; font-size: 13.8px; cursor: pointer; transition: all .15s ease;
  background-color: rgba(232, 196, 106, 0.1);
  background-image: repeating-linear-gradient(45deg, rgba(189, 138, 46, 0.14) 0, rgba(189, 138, 46, 0.14) 1px, transparent 1px, transparent 9px);
  margin-bottom: 8px;
}
.folder-drop:hover {
  border-color: rgba(189, 138, 46, 0.55); color: #7c5716; background-color: rgba(189, 138, 46, 0.22);
  background-image: repeating-linear-gradient(45deg, rgba(189, 138, 46, 0.2) 0, rgba(189, 138, 46, 0.2) 1px, transparent 1px, transparent 9px);
}
.folder-drop.drag-over {
  border-color: var(--gold-3); background-color: rgba(189, 138, 46, 0.3); color: #7c5716;
  background-image: repeating-linear-gradient(45deg, rgba(189, 138, 46, 0.24) 0, rgba(189, 138, 46, 0.24) 1px, transparent 1px, transparent 9px);
}
.dropzone-icons { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; color: #9a9488; opacity: 0.75; transition: color .15s ease, opacity .15s ease; }
.dropzone-icon { display: inline-flex; }
.folder-drop:hover .dropzone-icons { color: #bd8a2e; opacity: 1; }
.folder-drop.drag-over .dropzone-icons { color: #bd8a2e; opacity: 1; }

.subfolder-toolbar { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.subfolder-toolbar .btn { padding: 7px 13px; font-size: 12.5px; flex-shrink: 0; }
.subfolder-breadcrumb { font-size: 12.8px; color: #5b6472; }
.subfolder-breadcrumb .crumb { cursor: pointer; color: #7c5716; font-weight: 600; }
.subfolder-breadcrumb .crumb:hover { text-decoration: underline; }
.subfolder-breadcrumb .crumb.current { color: #1a1f2e; cursor: default; }
.subfolder-breadcrumb .crumb.current:hover { text-decoration: none; }
.subfolder-breadcrumb .crumb-sep { margin: 0 6px; color: #a7aeba; }

.subfolder-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 10px; border-top: 1px solid rgba(0,0,0,0.08); cursor: pointer;
  transition: background .15s ease;
}
.subfolder-row:first-child { border-top: none; }
.subfolder-row:hover { background: rgba(0,0,0,0.03); }
.subfolder-fn { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: #1a1f2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subfolder-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.subfolder-meta .fcount { font-size: 12.5px; color: #5b6472; }

/* Shared action toolbar above the file list — one set of buttons that acts
   on whatever is checked below, instead of four buttons repeated per row. */
.file-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; margin-bottom: 8px; flex-shrink: 0; flex-wrap: wrap;
  background: rgba(0,0,0,0.035); border: 1px solid rgba(0,0,0,0.08); border-radius: 9px;
}
.file-toolbar-label { font-size: 13px; font-weight: 700; color: #1a1f2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.file-toolbar-progress { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; flex-shrink: 0; }
.file-toolbar-progress.hidden { display: none; }
.file-progress-track { flex: 1; height: 8px; background: rgba(0,0,0,0.08); border-radius: 999px; overflow: hidden; }
.file-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-3), var(--gold-2)); transition: width .35s ease; }
.file-progress-label { font-size: 11.5px; color: #5b6472; flex-shrink: 0; min-width: 130px; text-align: right; }

/* Per-file progress bar, shown under an individual compact-file-row while
   it's actively processing — several can be visible at once. */
.file-progress-wrap { display: flex; align-items: center; gap: 10px; padding: 0 6px 9px 30px; }
.file-progress-wrap.hidden { display: none; }
.file-progress-cancel-btn {
  flex-shrink: 0; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--red-border); background: var(--red-bg); color: #c0281b; cursor: pointer;
  transition: background .15s ease;
}
.file-progress-cancel-btn:hover { background: rgba(217, 48, 37, 0.22); }
.file-progress-cancel-btn:disabled { opacity: .6; cursor: default; }

.list-select-row { display: flex; gap: 14px; margin: 0 2px 6px; flex-shrink: 0; }
.link-btn {
  border: none; background: none; padding: 0; margin: 0; cursor: pointer;
  font-size: 12px; font-weight: 700; color: #7c5716; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

.file-action-btn {
  border: none; background: rgba(0,0,0,0.06); color: #1a1f2e; border-radius: 8px;
  padding: 9px 16px; font-size: 14.5px; font-weight: 700; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; transition: background .15s ease, color .15s ease;
}
.file-action-btn:hover { background: rgba(0,0,0,0.14); }
.file-action-btn.danger { color: #8a2a22; }
.file-action-btn.danger:hover { background: var(--red-bg); color: var(--red); }
.file-action-btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

/* Compact, checkbox-selectable rows — just name/size/status, no buttons, so
   many more files fit on screen at once. */
.compact-file-row, .compact-sidecar-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px; border-top: 1px solid rgba(0,0,0,0.08);
  cursor: pointer; font-size: 13px;
}
.compact-file-row:first-child { border-top: none; }
.compact-file-row:hover, .compact-sidecar-row:hover { background: rgba(0,0,0,0.03); }
.compact-file-row.selected, .compact-sidecar-row.selected { background: rgba(232, 196, 106, 0.14); }
.compact-file-row input[type="checkbox"], .compact-sidecar-row input[type="checkbox"] { flex-shrink: 0; width: 15px; height: 15px; cursor: pointer; accent-color: var(--gold-3); }
.compact-file-row .icon { color: #5b6472; flex-shrink: 0; }
.compact-file-row .fn-name { color: #1a1f2e; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-file-row .file-size { color: #7a8290; font-size: 14.5px; flex-shrink: 0; }
.compact-file-row .err-msg { color: var(--red); font-size: 11.5px; max-width: 220px; text-align: right; flex-shrink: 0; }
.compact-file-row .badge { margin-left: auto; flex-shrink: 0; }

.compact-sidecar-row { padding-left: 30px; }
.compact-sidecar-row .fn-name { color: #4a5261; font-size: 14.5px; }

.process-bar-wrap { background: rgba(255,255,255,0.06); border-radius: 999px; height: 11px; overflow: hidden; margin: 16px 0; border: 1px solid var(--hairline); }
.process-bar { background: var(--gold-grad); height: 100%; width: 0%; transition: width .3s ease; }
.process-log { max-height: 220px; overflow-y: auto; border: 1px solid var(--hairline); border-radius: 8px; margin-top: 14px; background: rgba(0,0,0,0.15); }
.process-log-row { display: flex; justify-content: space-between; padding: 8px 13px; font-size: 12.5px; border-bottom: 1px solid var(--hairline); }
.process-log-row:last-child { border-bottom: none; }

textarea.editor {
  width: 100%; min-height: 792px; font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 13px;
  line-height: 1.6; padding: 17px; border: 1px solid var(--hairline); border-radius: 9px; resize: vertical;
  color: #1a1f2e; background: #ffffff;
}
textarea.editor:focus { outline: none; border-color: var(--glass-border); box-shadow: 0 0 0 3px rgba(232,196,106,0.12); }

.flag-note { background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber); border-radius: 8px; padding: 11px 15px; font-size: 12.8px; margin: 10px 0; }

/* ---------- Outline/Script rich-text preview ---------- */
.editor-toggle { display: flex; gap: 6px; margin-top: 14px; }
.editor-toggle-btn {
  border: 1px solid var(--hairline); background: rgba(255,255,255,0.04); color: var(--text-dim);
  font-size: 12.5px; font-weight: 700; padding: 7px 15px; border-radius: 999px; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.editor-toggle-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.editor-toggle-btn.active { background: var(--gold-grad); color: #241a05; border-color: transparent; }

.rich-preview {
  width: 100%; min-height: 792px; max-height: 792px; overflow-y: auto;
  background: #ffffff; color: #1a1f2e; border: 1px solid var(--hairline); border-radius: 9px;
  padding: 24px 28px; margin-top: 10px; font-size: 14px; line-height: 1.65;
}
.rich-preview .rte-title { font-size: 26px; font-weight: 800; color: #1F3864; margin: 0 0 14px; }
.rich-preview .rte-h1 { font-size: 19px; font-weight: 800; color: #1F3864; margin: 22px 0 8px; }
.rich-preview .rte-h2 { font-size: 15.5px; font-weight: 700; font-style: italic; color: #444444; margin: 14px 0 6px; }
.rich-preview .rte-list { margin: 4px 0 12px; padding-left: 22px; }
.rich-preview .rte-list li { margin-bottom: 5px; }
.rich-preview .rte-p { margin: 0 0 12px; }
.rich-preview .rte-p.rte-empty { color: #8a8f9a; font-style: italic; }
.rich-preview .rte-blank { height: 6px; }
.rich-preview .rte-beat { margin: 0 0 10px; padding-left: 2px; }
.rich-preview .rte-label { font-weight: 800; margin-right: 6px; }
.rich-preview .rte-label.rte-video { color: #1F3864; }
.rich-preview .rte-label.rte-audio { color: #1a7a2e; }
.rich-preview strong { font-weight: 800; }
.rich-preview em { font-style: italic; }
.rich-preview .rte-flag { color: #c0281b; font-weight: 800; }

.actions-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.video-cta {
  border: 2px dashed rgba(232, 196, 106, 0.35); border-radius: 14px; padding: 40px; text-align: center; color: var(--text-dim);
  background: radial-gradient(circle at 50% 0%, rgba(232,196,106,0.06), transparent 60%);
}
.video-cta .icon { font-size: 36px; margin-bottom: 12px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.video-cta h3 {
  margin: 0 0 6px; font-size: 19px;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.video-cta .btn { margin-top: 18px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 5, 10, 0.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: linear-gradient(165deg, #17213a, #0a0e1a);
  border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 28px; width: 430px; max-width: 92vw;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.modal.wide { width: 600px; }
.modal h2 {
  margin-top: 0; font-size: 17.5px;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.modal label { display: block; font-size: 12.8px; font-weight: 600; color: var(--text-dim); margin-top: 15px; }
.modal input, .modal select, .modal textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 14.5px;
  font-family: inherit; color: var(--text); background: rgba(0,0,0,0.28);
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none; border-color: var(--glass-border); box-shadow: 0 0 0 3px rgba(232,196,106,0.12);
}
.modal .hint { font-size: 12px; color: var(--text-dim); margin-top: 13px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.delete-choice {
  border: 1px solid var(--hairline); border-radius: 10px; padding: 13px 15px; margin-top: 13px;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.delete-choice h4 { margin: 0 0 4px; font-size: 13.8px; color: var(--silver-1); }
.delete-choice p { margin: 0; font-size: 12.2px; color: var(--text-dim); line-height: 1.5; }
.delete-choice:hover { border-color: var(--glass-border); background: rgba(255,255,255,0.04); }
.delete-choice.danger:hover { border-color: var(--red-border); background: var(--red-bg); }
.delete-choice.danger h4 { color: var(--red); }

.restore-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--hairline); border-radius: 10px; padding: 11px 14px; margin-top: 10px;
}
.restore-row-title { font-size: 13.8px; font-weight: 600; color: var(--silver-1); }
.restore-row-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.restore-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.restore-row-actions .btn { padding: 7px 13px; font-size: 12.5px; }
.health-check { font-size: 12.5px; margin-top: 16px; padding: 12px 14px; background: rgba(0,0,0,0.25); border: 1px solid var(--hairline); border-radius: 9px; line-height: 1.8; color: var(--text-dim); }
.modal-divider { border: none; border-top: 1px solid var(--hairline); margin: 24px 0 16px; }
.modal-subhead { margin: 0 0 4px; font-size: 14.5px; color: var(--silver-1); }

.settings-layout { display: flex; gap: 20px; margin-top: 18px; align-items: flex-start; }
.settings-nav { flex: 0 0 150px; display: flex; flex-direction: column; gap: 4px; }
.settings-nav-item {
  text-align: left; border: 1px solid transparent; background: none; color: var(--text-dim);
  font-size: 13.2px; font-weight: 600; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.settings-nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.settings-nav-item.active { background: var(--gold-grad); color: #241a05; box-shadow: 0 4px 14px rgba(189,138,46,.3); }
.settings-content { flex: 1; min-width: 0; border-left: 1px solid var(--hairline); padding-left: 20px; }
.settings-panel.hidden { display: none; }
.settings-panel label:first-child { margin-top: 0; }
.settings-panel .modal-actions { justify-content: flex-start; margin-top: 20px; }

/* ---------- Login page ---------- */
.login-body { display: flex; flex-direction: column; min-height: 100vh; }
.login-page { display: flex; align-items: center; justify-content: center; flex: 1; width: 100%; padding: 20px; }
.login-card {
  background: linear-gradient(165deg, #17213a, #0a0e1a);
  border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 32px; width: 400px; max-width: 92vw;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.login-logo { display: block; height: 112px; width: auto; margin: 0 auto 22px; filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.55)); }
.login-card h2 {
  margin-top: 0; text-align: center; font-size: 19px;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card label { display: block; font-size: 12.8px; font-weight: 600; color: var(--text-dim); margin-top: 15px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 14.5px;
  font-family: inherit; color: var(--text); background: rgba(0,0,0,0.28);
}
.login-card input:focus {
  outline: none; border-color: var(--glass-border); box-shadow: 0 0 0 3px rgba(232,196,106,0.12);
}
.login-card .hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; margin-top: 4px; }
.login-link {
  text-align: center; font-size: 12.5px; color: var(--gold-2); cursor: pointer; margin: 18px 0 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.login-link:hover { color: var(--gold-1); }
.login-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red);
}
.login-error.success { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.login-error.hidden { display: none; }

.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: linear-gradient(135deg, #1c2942, #0b0e1a); color: var(--silver-1); padding: 12px 17px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,0.4); max-width: 340px; border: 1px solid var(--glass-border);
}
.toast.error { border-color: var(--red-border); color: var(--red); }
.toast.success { border-color: var(--green-border); color: var(--green); }

.spinner {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(232,196,106,0.25); border-top-color: var(--gold-2);
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

code { background: rgba(0,0,0,0.35); border: 1px solid var(--hairline); padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--gold-1); }
