@import url("https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap");

:root {
  --white: #ffffff;
  --black: #1a1a1a;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d4d4d4;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-700: #404040;
  --gray-800: #262626;
  --gray-900: #171717;
  --green: #16a34a;
  --green-light: #22c55e;
  --green-dark: #15803d;
  --red: #dc2626;
  --sky: #38bdf8;
  --amber: #f59e0b;
  --bg: #ffffff;
  --bg-2: #f8fafc;
  --bg-3: #f1f5f9;
  --surface: #ffffff;
  --border-soft: rgba(0, 0, 0, 0.06);
  --accent: #16a34a;
  --accent-dim: rgba(22, 163, 74, 0.1);
  --accent-hover: #15803d;
  --accent-glow: rgba(22, 163, 74, 0.35);
  --text-1: #1a1a1a;
  --text-2: #404040;
  --text-3: #737373;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --topbar-h: 46px;
  --statusbar-h: 32px;
  --sidebar-w: 188px;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-script: "Courier Prime", "Courier New", monospace;
  --page-w: 680px;
  --page-h: 960px;
  --page-pt: 72px;
  --page-pb: 72px;
  --page-pl: 108px;
  --page-pr: 72px;
  /* Drawer */
  --drawer-w: 380px;
  --dr-bg: #0f1117;
  --dr-surface: #1a1d27;
  --dr-surface2: #22263a;
  --dr-border: rgba(255, 255, 255, 0.07);
  --dr-text1: #f1f5f9;
  --dr-text2: #94a3b8;
  --dr-text3: #64748b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button {
  cursor: pointer;
  font-family: var(--font-ui);
  border: none;
  background: none;
}
input {
  font-family: var(--font-ui);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 600;
  position: relative;
}
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(22, 163, 74, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 12px;
  flex-shrink: 0;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.brand-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.fmt-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 600;
}
.fmt-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: var(--bg-3);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  cursor: pointer;
  transition: background 0.13s;
  white-space: nowrap;
  min-width: 148px;
  border: none;
}
.fmt-pill:hover {
  background: var(--gray-200);
}
.fmt-pill .chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-3);
  transition: transform 0.2s;
}
.fmt-pill.open .chevron {
  transform: rotate(180deg);
}
.fmt-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 240px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 6px 0;
  z-index: 9999;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  animation: dropIn 0.15s ease forwards;
}
.fmt-menu.open {
  display: block;
}
@keyframes dropIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fmt-menu-hint {
  padding: 6px 14px 8px;
  font-size: 11px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}
.fmt-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
  transition: background 0.1s;
}
.fmt-menu-item:hover {
  background: var(--bg-3);
}
.fmt-menu-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.fmt-menu-item .fmt-name {
  font-weight: 500;
}
.fmt-menu-item .fmt-kbd {
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}
.text-style-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}
.style-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-3);
  transition:
    background 0.12s,
    color 0.12s;
  font-weight: 700;
}
.style-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.proj-title-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.proj-input {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  text-align: center;
  outline: none;
  width: 240px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition:
    background 0.14s,
    color 0.14s;
}
.proj-input:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.proj-input:focus {
  background: var(--accent-dim);
  color: var(--text-1);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.zoom-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.13s;
}
.zoom-pill:hover {
  background: var(--gray-200);
  color: var(--text-1);
}
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.13s;
}
.tbtn:hover {
  background: var(--gray-200);
  color: var(--text-1);
}
.tbtn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tbtn.primary:hover {
  background: var(--accent-hover);
}
.icon-tbtn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-3);
  transition: all 0.13s;
}
.icon-tbtn:hover {
  background: var(--gray-200);
  color: var(--text-1);
}

/* ── WORKSPACE ── */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ── LEFT TOOLS PANEL ── */
.tools-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 12px;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 16px;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(100vh - var(--topbar-h) - var(--statusbar-h) - 24px);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  z-index: 100;
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
}
.tools-panel.dragging {
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.15),
    0 4px 16px var(--accent-glow);
  border-color: var(--accent);
  cursor: grabbing !important;
  user-select: none;
  transition: none;
}
.tools-drag-handle {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: var(--text-3);
  cursor: grab;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
  transition:
    color 0.15s,
    background 0.15s;
  user-select: none;
}
.tools-drag-handle:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.tools-drag-handle:active {
  cursor: grabbing;
}
.tools-drag-handle i {
  font-size: 9px;
  opacity: 0.5;
}
.tools-card {
  width: calc(100% - 20px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin: 0 10px;
  border: 1px solid var(--border-soft);
}
.tools-card:first-of-type {
  margin-top: 8px;
}
.tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  user-select: none;
}
.tool-item:last-child {
  border-bottom: none;
}
.tool-item:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.tool-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.tool-item i {
  font-size: 13px;
  width: 16px;
  text-align: center;
}
.tool-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.badge-new {
  font-size: 9px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  margin-left: auto;
}

/* ══════════════════════════════════════════
   DARK SIDE DRAWER (Quantum Moat style)
══════════════════════════════════════════ */

/* Overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: lch(93.05% 0.01 296.81 / 0);
  backdrop-filter: blur(0px);
  z-index: 800;
  pointer-events: none;
  transition:
    background 0.3s,
    backdrop-filter 0.3s;
}
.drawer-overlay.open {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

/* Drawer panel */
.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  background: var(--white);
  border-left: 1px solid var(--dr-border);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.side-drawer.open {
  transform: translateX(0);
}

/* Accent bar at top */
.drawer-accent-bar {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
  transition: background 0.2s;
}

/* Drawer header */
.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.drawer-header-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.drawer-header-info {
  flex: 1;
  min-width: 0;
}
.drawer-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: 0.01em;
}
.drawer-header-sub {
  font-size: 11px;
  color: var(--gray-900);
  margin-top: 1px;
}
.drawer-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dr-text3);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--dr-border);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-1);
}

/* Drawer scrollable body */
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}
.drawer-body::-webkit-scrollbar {
  width: 4px;
}
.drawer-body::-webkit-scrollbar-track {
  background: transparent;
}
.drawer-body::-webkit-scrollbar-thumb {
  background: rgba(223, 221, 221, 0.1);
  border-radius: 99px;
}

/* Section labels */
.dr-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dr-text3);
  padding: 14px 20px 8px;
}

/* Empty state */
.dr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--dr-text3);
  text-align: center;
}
.dr-empty i {
  font-size: 32px;
  opacity: 0.4;
}
.dr-empty p {
  font-size: 13px;
  line-height: 1.6;
}

/* List items */
.dr-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}
.dr-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.dr-list-item:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.dr-item-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.dr-char-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.dr-item-body {
  flex: 1;
  min-width: 0;
}
.dr-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  font-family: var(--font-script);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dr-item-sub {
  font-size: 10px;
  color: var(--dr-text3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dr-item-arrow {
  font-size: 10px;
  color: var(--dr-text3);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity 0.15s,
    transform 0.15s;
}
.dr-list-item:hover .dr-item-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Footer */
.dr-footer {
  padding: 14px 10px 0;
}
.dr-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgb(153 153 153 / 6%);
  border: 1px solid var(--dr-border);
  color: var(--btn-accent, #22c55e);
  transition: all 0.15s;
}
.dr-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--btn-accent, #22c55e);
}

/* Breakdown */
.dr-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 20px;
}
.dr-breakdown-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.dr-breakdown-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.dr-breakdown-left i {
  font-size: 13px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.dr-breakdown-left span {
  font-size: 12px;
  color: var(--dr-text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dr-breakdown-right {
  flex-shrink: 0;
}
.dr-breakdown-count {
  font-size: 14px;
  font-weight: 700;
}
.dr-breakdown-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}
.dr-breakdown-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stats grid */
.dr-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 10px;
}
.dr-stat-card {
  background: var(--gray-100);
  border: 1px solid var(--dr-border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.dr-stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-bottom: 2px;
}
.dr-stat-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.dr-stat-label {
  font-size: 10px;
  color: var(--dr-text3);
  text-align: center;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Timers */
.dr-timer-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px;
}
.dr-timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-100);
  border: 1px solid var(--dr-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.dr-timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dr-timer-row span {
  flex: 1;
  font-size: 12px;
  color: var(--dr-text2);
  font-weight: 500;
}
.dr-timer-row b {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-script);
}

/* ── EDITOR ── */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}
.script-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 40px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  min-height: 0;
  background: var(--bg-3);
}

/* ── PAGES ── */
.script-page {
  width: var(--page-w);
  min-width: var(--page-w);
  max-width: var(--page-w);
  height: var(--page-h);
  min-height: var(--page-h);
  max-height: var(--page-h);
  background: #fff;
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.12),
    0 1px 4px rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.script-page::before {
  content: attr(data-page-label);
  position: absolute;
  bottom: 22px;
  right: 28px;
  font-family: var(--font-script);
  font-size: 10pt;
  color: #bbb;
  pointer-events: none;
}

/* Title page */
.title-page {
  display: flex;
  flex-direction: column;
  font-family: var(--font-script);
  color: #111;
}
.title-page-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--page-pt) var(--page-pr) 60px var(--page-pl);
  gap: 0;
}
.title-field-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
}
.tp-field {
  font-family: var(--font-script);
  font-size: 12pt;
  color: #111;
  text-align: center;
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  max-width: 340px;
  padding: 4px 8px;
  border-radius: 3px;
  transition: background 0.15s;
  line-height: 1.6;
}
.tp-field::placeholder {
  color: #bbb;
}
.tp-field:hover {
  background: rgba(22, 163, 74, 0.04);
}
.tp-field:focus {
  background: rgba(22, 163, 74, 0.07);
}
.tp-field.tp-title {
  font-size: 18pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.tp-field.tp-byline {
  font-style: italic;
}
.tp-field.tp-author {
  font-weight: 700;
}
.tp-separator {
  width: 160px;
  height: 1px;
  background: rgba(0, 0, 0, 0.15);
  margin: 20px auto;
}
.title-page-footer {
  display: flex;
  justify-content: space-between;
  padding: 0 var(--page-pr) var(--page-pb) var(--page-pl);
  font-family: var(--font-script);
  font-size: 10pt;
  color: #444;
  gap: 20px;
}
.tp-footer-field {
  font-family: var(--font-script);
  font-size: 10pt;
  color: #444;
  border: none;
  outline: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s;
  max-width: 220px;
  width: 220px;
}
.tp-footer-field::placeholder {
  color: #bbb;
}
.tp-footer-field:hover {
  background: rgba(22, 163, 74, 0.04);
}
.tp-footer-field:focus {
  background: rgba(22, 163, 74, 0.07);
}
.tp-footer-field.tp-copyright {
  text-align: left;
}
.tp-footer-field.tp-contact {
  text-align: right;
}

/* Content page */
.content-page {
  padding: var(--page-pt) var(--page-pr) var(--page-pb) var(--page-pl);
  overflow: hidden;
  position: relative;
}
.page-content {
  height: 100%;
  overflow: hidden;
  position: relative;
  font-family: var(--font-script);
  font-size: 12pt;
  line-height: 1.85;
  color: #111;
}

/* Script lines */
.script-line {
  position: relative;
  outline: none;
  border-radius: 2px;
  padding: 0 2px;
  transition: background 0.1s;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  min-height: 1.85em;
  color: #111;
  font-family: var(--font-script);
  font-size: 12pt;
  line-height: 1.85;
  display: block;
}
.script-line:focus {
  background: rgba(22, 163, 74, 0.05);
}
.script-line.active {
  background: rgba(22, 163, 74, 0.07);
}
.script-line::after {
  content: attr(data-tag);
  position: absolute;
  right: -96px;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #1a1a1a;
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s,
    transform 0.18s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.script-line.scene-heading::after {
  background: #1a2e1a;
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.25);
}
.script-line.action::after {
  background: #1a1e2e;
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.25);
}
.script-line.character::after {
  background: #2e1a1a;
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.25);
}
.script-line.dialogue::after {
  background: #2e2a1a;
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.25);
}
.script-line.parenthetical::after {
  background: #2a1a2e;
  color: #c4b5fd;
  border-color: rgba(196, 181, 253, 0.25);
}
.script-line.transition::after {
  background: #2e1e1a;
  color: #fdba74;
  border-color: rgba(253, 186, 116, 0.25);
}
.script-line:hover::after,
.script-line:focus::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.scene-heading {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-top: 24px;
  margin-bottom: 4px;
}
.action {
  margin: 0;
}
.character {
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 0;
  margin-left: 196px;
}
.dialogue {
  margin: 0;
  margin-left: 96px;
  margin-right: 96px;
}
.parenthetical {
  margin: 0;
  margin-left: 136px;
  margin-right: 136px;
  color: #444;
}
.transition {
  text-align: right;
  text-transform: uppercase;
  margin-top: 14px;
  margin-bottom: 4px;
  color: #333;
}

/* ── STATUS BAR ── */
.status-bar {
  height: var(--statusbar-h);
  min-height: var(--statusbar-h);
  background: var(--bg-2);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 0;
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
  z-index: 50;
}
.stat-counter {
  display: flex;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 16px;
}
.stat-dots {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.stat-item {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
}
.stat-item b {
  color: var(--text-2);
  font-weight: 500;
}
.timer-writing b {
  color: var(--accent) !important;
}
.timer-thinking b {
  color: var(--sky) !important;
}
.stat-saved {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
}
.stat-saved.active {
  color: var(--accent);
}
.help-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  margin-left: 12px;
  transition: all 0.13s;
}
.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── SH OVERLAY / POPUP ── */
.sh-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.sh-overlay.open {
  display: flex;
}
.sh-popup {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.16);
  animation: popupIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes popupIn {
  from {
    opacity: 0;
    transform: scale(0.93) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.sh-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.sh-popup-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.01em;
}
.sh-popup-title i {
  color: var(--accent);
  font-size: 13px;
}
.sh-close-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 11px;
  transition:
    background 0.13s,
    color 0.13s;
}
.sh-close-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.sh-popup-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sh-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sh-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.sh-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.sh-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 6px;
  background: var(--bg-3);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.sh-type-btn:hover {
  background: var(--gray-200);
  border-color: var(--gray-300);
}
.sh-type-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.sh-type-abbr {
  font-family: var(--font-script);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.sh-type-btn:not(.active) .sh-type-abbr {
  color: var(--text-1);
}
.sh-type-btn.active .sh-type-abbr {
  color: var(--accent);
}
.sh-type-name {
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sh-type-btn.active .sh-type-name {
  color: rgba(22, 163, 74, 0.7);
}
.sh-popup-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.sh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.sh-btn-cancel {
  background: var(--bg-3);
  border: 1px solid var(--border-soft);
  color: var(--text-2);
}
.sh-btn-cancel:hover {
  background: var(--gray-200);
  color: var(--text-1);
}
.sh-btn-insert {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.sh-btn-insert:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 48px;
  right: 20px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  background: var(--text-1);
  color: #fff;
  border: 1px solid var(--border-soft);
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all 0.22s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.success {
  background: var(--accent);
  border-color: var(--accent);
}
.toast.error {
  background: var(--red);
  border-color: var(--red);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(22, 163, 74, 0.22);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(22, 163, 74, 0.42);
}

/* ── SH INLINE PICKER ── */
.sh-inline-picker {
  position: fixed;
  z-index: 8000;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 72px;
  animation: shPickIn 0.13s ease forwards;
}
@keyframes shPickIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.sh-pick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-script);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition:
    background 0.1s,
    color 0.1s;
  white-space: nowrap;
}
.sh-pick-btn:hover {
  background: var(--bg-3);
  color: var(--text-1);
}
.sh-pick-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 160px;
    --drawer-w: 320px;
  }
  .sh-type-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 700px) {
  .tools-panel {
    display: none;
  }
  .side-drawer {
    width: 100%;
  }
  .script-line::after {
    display: none;
  }
  .proj-input {
    width: 160px;
  }
  .text-style-btns {
    display: none;
  }
}
