:root {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #e2e8f0;
  --bg-hover: #eef2ff;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  --emerald-50: #ecfdf5;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-border: #a7f3d0;

  --amber-50: #fffbeb;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-border: #fde68a;

  --rose-50: #fff1f2;
  --rose-600: #e11d48;
  --rose-700: #be123c;
  --rose-border: #fecdd3;

  --sky-50: #f0f9ff;
  --sky-600: #0284c7;
  --sky-border: #bae6fd;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 4px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.2);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-sans: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

[hidden] {
  display: none !important;
}

/* -------------------------------------------------------------------------- */
/* App Shell & Top Bar                                                        */
/* -------------------------------------------------------------------------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo-600), #7c3aed);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.28);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.book-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.book-select {
  min-width: 240px;
  max-width: 340px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.divider-v {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

/* -------------------------------------------------------------------------- */
/* Badges & Pills                                                             */
/* -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge--draft {
  background: var(--amber-50);
  color: var(--amber-700);
  border-color: var(--amber-border);
}

.badge--published {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border-color: var(--emerald-border);
}

.badge--indigo {
  background: var(--indigo-50);
  color: var(--indigo-700);
  border-color: var(--indigo-100);
}

.badge--sky {
  background: var(--sky-50);
  color: var(--sky-600);
  border-color: var(--sky-border);
}

.badge--connected {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border-color: var(--emerald-border);
}

.badge--connecting {
  background: var(--amber-50);
  color: var(--amber-700);
  border-color: var(--amber-border);
}

.badge--error {
  background: var(--rose-50);
  color: var(--rose-700);
  border-color: var(--rose-border);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------- */
/* Buttons & Form Controls                                                    */
/* -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.08s ease;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: #94a3b8;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 16px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--indigo-600);
  border-color: var(--indigo-600);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--indigo-700);
  border-color: var(--indigo-700);
}

.btn-ai {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: #4f46e5;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-ai:hover:not(:disabled) {
  filter: brightness(1.06);
  border-color: #4338ca;
}

.btn-success {
  background: var(--emerald-600);
  border-color: var(--emerald-600);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  background: var(--emerald-700);
  border-color: var(--emerald-700);
}

.btn-danger {
  background: var(--rose-50);
  border-color: var(--rose-border);
  color: var(--rose-700);
}

.btn-danger:hover:not(:disabled) {
  background: var(--rose-600);
  border-color: var(--rose-600);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: transparent;
  color: var(--text-primary);
}

.btn-recording {
  background: var(--rose-600) !important;
  border-color: var(--rose-600) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.2);
  animation: pulse-rec 1.3s infinite;
}

@keyframes pulse-rec {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.22);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(225, 29, 72, 0.14);
  }
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

.textarea {
  resize: vertical;
  line-height: 1.6;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--indigo-600);
  cursor: pointer;
}

/* -------------------------------------------------------------------------- */
/* 3-Pane Editorial Workspace                                                 */
/* -------------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(360px, 1.15fr) minmax(370px, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-left {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
}

.pane-center {
  background: var(--bg-app);
  border-right: 1px solid var(--border);
}

.pane-right {
  background: var(--bg-surface);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.pane-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

/* -------------------------------------------------------------------------- */
/* Left Pane: PDF Dropzone & Page List                                        */
/* -------------------------------------------------------------------------- */

.pdf-dropzone {
  border: 1.5px dashed #a5b4fc;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.pdf-dropzone:hover,
.pdf-dropzone--dragover {
  border-color: var(--indigo-600);
  background: var(--indigo-50);
}

.pdf-dropzone-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 6px;
}

.pdf-dropzone-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--indigo-700);
}

.pdf-dropzone-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.pdf-progress {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--indigo-100);
  text-align: left;
}

.pdf-progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--indigo-100);
  overflow: hidden;
  margin-bottom: 6px;
}

.pdf-progress-fill {
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, var(--indigo-500), #7c3aed, var(--indigo-500));
  background-size: 200% 100%;
  animation: progress-slide 1.2s linear infinite;
}

@keyframes progress-slide {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}

.pdf-progress-text {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--indigo-700);
}

.left-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.page-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-card {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.page-card:hover {
  border-color: #a5b4fc;
  background: var(--bg-subtle);
}

.page-card--active {
  border-color: var(--indigo-600);
  background: var(--indigo-50);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.14);
}

.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.page-card-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-card-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.mini-badge--ai {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.mini-badge--mode {
  background: var(--sky-50);
  color: var(--sky-600);
  border-color: var(--sky-border);
  font-family: var(--font-mono);
}

.page-card-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* -------------------------------------------------------------------------- */
/* Center Pane: Page Content & AI Suggestion Card                             */
/* -------------------------------------------------------------------------- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-body {
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-text-editor {
  min-height: 148px;
  font-size: 13.5px;
  background: var(--bg-subtle);
}

.card-footer-end {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-card {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 42%);
}

.ai-card .card-header {
  border-bottom-color: #ede9fe;
}

.ai-meta-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-block-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #5b21b6;
  letter-spacing: 0.01em;
}

.ai-block-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.55;
}

.ai-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-primary);
}

.vocab-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vocab-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #ddd6fe;
  color: #5b21b6;
}

.ai-quote {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid #e9d5ff;
  font-size: 13px;
  color: var(--text-primary);
}

.ai-mode-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------------------- */
/* Right Pane: Tabs (Interaction Settings / Live Voice Sandbox)               */
/* -------------------------------------------------------------------------- */

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px 0;
  gap: 6px;
  flex-shrink: 0;
}

.tab-btn {
  padding: 9px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}

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

.tab-btn--active {
  background: var(--bg-surface);
  color: var(--indigo-700);
  border-color: var(--border);
  position: relative;
}

.tab-btn--active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--bg-surface);
}

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.settings-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.prompt-preview-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.prompt-preview-details summary {
  padding: 8px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.prompt-preview-pre {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* -------------------------------------------------------------------------- */
/* Voice Sandbox Tab                                                          */
/* -------------------------------------------------------------------------- */

.sandbox-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px;
  gap: 12px;
}

.sandbox-status-card {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sandbox-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.sandbox-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sandbox-ptt-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #6366f1, #f59e0b, #e11d48);
  transition: width 0.06s linear;
}

.meter-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.transcript-box {
  flex: 1;
  min-height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.bubble-row--user {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble-row--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble-row--system {
  align-self: center;
  align-items: center;
  max-width: 96%;
}

.bubble {
  padding: 8px 12px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-row--user .bubble {
  background: var(--indigo-600);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.bubble-row--assistant .bubble {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}

.bubble-row--system .bubble {
  background: #ffffff;
  color: var(--text-secondary);
  border: 1px dashed var(--border-strong);
  font-size: 11.5px;
  padding: 4px 11px;
  border-radius: 999px;
}

.bubble-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sandbox-text-form {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* -------------------------------------------------------------------------- */
/* Empty States, Modals, and Toasts                                           */
/* -------------------------------------------------------------------------- */

.empty-state {
  margin: auto;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.modal-error {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--rose-50);
  border: 1px solid var(--rose-border);
  color: var(--rose-700);
  font-size: 12.5px;
}

.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid var(--indigo-500);
  animation: toast-in 0.18s ease-out;
}

.toast--success {
  border-left-color: #10b981;
}

.toast--error {
  border-left-color: #f43f5e;
}

.toast--info {
  border-left-color: #6366f1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------------------------------------------------------------- */
/* Responsive Layout                                                          */
/* -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px 1fr 360px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .pane {
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .pane-scroll {
    max-height: 520px;
  }

  .book-selector-group {
    padding-left: 0;
    border-left: none;
  }
}
