/* =============================================
   Present — Clinical Documentation Tool
   Dark slate + phosphor green monitor vibes
   IBM Plex for medical-tech precision
   ============================================= */

:root {
  --bg: #0d1117;
  --bg-panel: #111820;
  --bg-panel-alt: #0f1923;
  --border: #1e2d3d;
  --border-bright: #2a4060;
  --green: #00e5a0;
  --green-dim: #00a872;
  --green-glow: rgba(0, 229, 160, 0.15);
  --green-glow-sm: rgba(0, 229, 160, 0.08);
  --amber: #f5a623;
  --red: #ff4d4d;
  --text: #c9d8e8;
  --text-dim: #5a7a96;
  --text-bright: #e8f4ff;
  --text-label: #3a6080;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --radius: 4px;
  --radius-lg: 8px;
}

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

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Subtle scanline overlay */
.scanline {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ===================== HEADER ===================== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Present gift box SVG logo */
.logo-svg {
  width: 28px;
  height: 28px;
  color: var(--green);
  filter: drop-shadow(0 0 6px rgba(0, 229, 160, 0.5));
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-bright);
  letter-spacing: 0.04em;
}

.logo-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  margin-left: 0.3rem;
}

.header-right { display: flex; align-items: center; gap: 1rem; }

.model-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.privacy-status {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--green);
  border: 1px solid rgba(0, 229, 160, 0.28);
  background: var(--green-glow-sm);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  white-space: nowrap;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}
.status-dot.loading {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  animation: blink 1s infinite;
}
.status-dot.error { background: var(--red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===================== AUTOCOPY TOAST ===================== */
.autocopy-toast {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-panel);
  border: 1px solid var(--green-dim);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 0.45rem 1rem;
  border-radius: 20px;
  box-shadow: 0 0 16px var(--green-glow);
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.autocopy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================== MAIN ===================== */
main {
  flex: 1;
  padding: 1.5rem 2rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  height: calc(100vh - 56px - 52px - 3rem);
  min-height: 600px;
}

/* ===================== PANELS ===================== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}

.panel-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-label);
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid var(--border);
}

.panel-header h2 {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: 0.02em;
  flex: 1;
}

/* Edit hint badge in output panel header */
.edit-hint {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--green-dim);
  opacity: 0.75;
  pointer-events: none;
  user-select: none;
}

/* ===================== TABS ===================== */
.input-mode-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}
.tab-btn svg { width: 14px; height: 14px; }
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--green);
  background: var(--green-glow-sm);
}

.tab-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.tab-content.hidden { display: none; }

/* ===================== MIC AREA ===================== */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem 1.5rem;
  gap: 0.75rem;
  flex-shrink: 0;
}

.mic-visualizer {
  position: relative;
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}

.mic-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--green-dim);
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.3s;
}
.mic-ring-1 { width: 80px; height: 80px; }
.mic-ring-2 { width: 80px; height: 80px; }
.mic-ring-3 { width: 80px; height: 80px; }

.recording .mic-ring-1 { animation: ripple 1.5s ease-out infinite; }
.recording .mic-ring-2 { animation: ripple 1.5s ease-out 0.4s infinite; }
.recording .mic-ring-3 { animation: ripple 1.5s ease-out 0.8s infinite; }

@keyframes ripple {
  0% { transform: scale(1); opacity: 0.6; border-color: var(--green); }
  100% { transform: scale(2.2); opacity: 0; }
}

.mic-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border-bright);
  background: var(--bg-panel-alt);
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  position: relative;
  z-index: 1;
}
.mic-btn svg { width: 22px; height: 22px; }
.mic-btn:hover {
  border-color: var(--green-dim);
  color: var(--green);
  box-shadow: 0 0 16px var(--green-glow);
}
.recording .mic-btn {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-glow-sm);
  box-shadow: 0 0 24px var(--green-glow);
}

.mic-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

.recording-timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green);
}
.rec-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1s infinite;
}

/* ===================== TRANSCRIPT ===================== */
.transcript-box {
  flex: 1;
  margin: 0 1rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  transition: border-color 0.2s;
}

/* Highlight the transcript box border when editable */
.transcript-box:has(.transcript-text.is-editable) {
  border-color: var(--border-bright);
}

.transcript-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  transition: color 0.2s;
}

/* Transcript label colour shifts green when editable */
.transcript-box:has(.transcript-text.is-editable) .transcript-label {
  color: var(--green-dim);
}

/* Transcript as textarea — matches the old div's look exactly */
.transcript-text {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  /* textarea resets */
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-sans);
  width: 100%;
  /* readonly state — looks non-interactive */
  cursor: default;
}
.transcript-text::placeholder {
  color: var(--text-dim);
  font-style: italic;
}
/* Editable state — indicate interactivity */
.transcript-text.is-editable {
  cursor: text;
  color: var(--text-bright);
}
.transcript-text.is-editable:focus {
  background: rgba(0, 229, 160, 0.03);
}

/* ===================== TEXT INPUT ===================== */
.text-input-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.5rem;
  min-height: 0;
}

.text-input-area label {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.text-input-area textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.65;
  padding: 0.85rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.text-input-area textarea:focus { border-color: var(--border-bright); }
.text-input-area textarea::placeholder { color: var(--text-dim); font-style: italic; }

/* ===================== ACTION BAR ===================== */
.action-bar {
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}

.btn-process {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--green);
  color: #0a1a10;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
.btn-process:hover:not(:disabled) {
  background: #00ffb3;
  box-shadow: 0 0 20px var(--green-glow);
}
.btn-process:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
}
.btn-icon svg { width: 14px; height: 14px; }

.btn-clear {
  padding: 0.6rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-clear:hover {
  border-color: var(--border-bright);
  color: var(--text);
}

/* ===================== OUTPUT ===================== */
.output-area {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: relative;
  min-height: 0;
}

.output-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  color: var(--text-dim);
}
.empty-icon svg { width: 48px; height: 48px; opacity: 0.25; }
.output-empty p { font-size: 0.82rem; opacity: 0.5; }

.output-content {
  padding: 1.25rem;
  outline: none;        /* suppress contenteditable focus ring */
  transition: background 0.2s;
}
/* Subtle focus tint when the output area is being edited */
.output-content[contenteditable="true"]:focus {
  background: rgba(0, 229, 160, 0.02);
}

/* Problem Block */
.problem-block {
  margin-bottom: 1.5rem;
  animation: fadeSlideIn 0.3s ease forwards;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.problem-title {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.05em;
  padding: 0.4rem 0.75rem;
  border-left: 3px solid var(--green);
  background: var(--green-glow-sm);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 0.5rem;
}

/* Boilerplate blocks rendered as italic prose, visually distinct from problem titles */
.boilerplate-block {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.65;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border-left: 2px solid var(--border-bright);
  margin-bottom: 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.problem-items {
  list-style: none;
  padding: 0 0 0 0.5rem;
}
.problem-items li {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  padding: 0.2rem 0 0.2rem 1.1rem;
  position: relative;
}
.problem-items li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-dim);
}

/* Streaming output */
.output-streaming { padding: 1.25rem; }
.thinking-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--green-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.think-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 0.8s infinite;
}
.stream-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.btn-copy svg { width: 12px; height: 12px; }
.btn-copy:hover { border-color: var(--green-dim); color: var(--green); }
.btn-copy.copied { border-color: var(--green); color: var(--green); }

/* ===================== PROGRESS ===================== */
.progress-bar-wrap {
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}
.progress-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--green-dim), var(--green));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--green-glow);
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  display: block;
  margin-top: 0.35rem;
  letter-spacing: 0.05em;
}

/* ===================== FOOTER ===================== */
footer {
  text-align: center;
  padding: 0.9rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  background: var(--bg-panel);
  flex-shrink: 0;
}
footer a { color: var(--green-dim); text-decoration: none; }
footer a:hover { color: var(--green); }
.footer-sep { margin: 0 0.75rem; opacity: 0.3; }

/* ===================== SCROLLBARS ===================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ===================== ERROR ===================== */
.error-msg {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--red);
  padding: 1rem 1.25rem;
  background: rgba(255,77,77,0.05);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  main { padding: 1rem; }
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: unset;
  }
  .panel { height: 500px; }
  .panel-output { height: auto; min-height: 400px; }
  header { padding: 0 1rem; }
  .logo-tag { display: none; }
  .privacy-status { display: none; }
}

/* ===================== SETTINGS GEAR BUTTON ===================== */
.btn-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-settings:hover {
  color: var(--green);
  border-color: var(--green-dim);
  background: var(--green-glow-sm);
}

/* ===================== SETTINGS DRAWER ===================== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.settings-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100dvh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.settings-drawer.open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}
.settings-header h2 {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-bright);
  flex: 1;
}
.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-btn-reset {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: transparent;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.settings-btn-reset:hover {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(245, 166, 35, 0.07);
}

.settings-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.settings-close:hover {
  color: var(--text-bright);
  border-color: var(--border-bright);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.settings-section-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 0.25rem;
}
.settings-section-desc strong { color: var(--text); font-weight: 500; }
.settings-section-desc code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--green-dim);
  background: rgba(0, 229, 160, 0.08);
  padding: 0 4px;
  border-radius: 2px;
}

.settings-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.settings-check input {
  width: 16px;
  height: 16px;
  margin-top: 0.1rem;
  accent-color: var(--green);
}

.settings-check span {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.settings-check strong {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
}

.settings-check small {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
  margin-top: 0.5rem;
}
.settings-label-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 400;
}

.settings-textarea {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  resize: vertical;
  width: 100%;
  transition: border-color 0.2s;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.settings-textarea:focus {
  outline: none;
  border-color: var(--green-dim);
  background: rgba(0, 229, 160, 0.02);
}
.settings-textarea-sm { min-height: 120px; }
.settings-textarea-lg { min-height: 280px; }

/* ===================== BOILERPLATE LIST ===================== */
.boilerplate-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bp-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  overflow: hidden;
}

.bp-entry-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.bp-entry-header:hover {
  background: rgba(255,255,255,0.03);
}

.bp-entry-key-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--green-dim);
  background: rgba(0, 229, 160, 0.1);
  border: 1px solid rgba(0, 229, 160, 0.2);
  padding: 2px 7px;
  border-radius: 3px;
}

.bp-entry-key-input {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-bright);
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  min-width: 80px;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.bp-entry-key-input::placeholder { color: var(--text-dim); text-transform: none; }

.bp-entry-toggle {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}
.bp-chevron {
  width: 10px;
  height: 10px;
  transition: transform 0.2s;
}
.bp-entry.expanded .bp-chevron { transform: rotate(180deg); }

.bp-entry-body {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
}
.bp-entry.expanded .bp-entry-body {
  display: flex;
}

.bp-field-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.bp-entry-trigger {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  resize: none;
  width: 100%;
  min-height: 60px;
  transition: border-color 0.2s;
}
.bp-entry-trigger:focus {
  outline: none;
  border-color: var(--green-dim);
}
.bp-entry-trigger::placeholder { color: var(--text-dim); font-style: italic; }

.bp-entry-text {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  resize: vertical;
  width: 100%;
  min-height: 80px;
  transition: border-color 0.2s;
}
.bp-entry-text:focus {
  outline: none;
  border-color: var(--green-dim);
}

.bp-entry-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.25rem;
}
.bp-btn-delete {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: transparent;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s;
}
.bp-btn-delete:hover {
  color: var(--red);
  border-color: var(--red);
  background: rgba(255, 77, 77, 0.07);
}

.settings-btn-add {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--green-dim);
  border: 1px dashed var(--green-dim);
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  justify-content: center;
  margin-top: 0.25rem;
  transition: all 0.2s;
}
.settings-btn-add:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-glow-sm);
}

/* ===================== SETTINGS FOOTER ===================== */
.settings-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-alt);
  flex-shrink: 0;
}

.btn-settings-save {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--bg);
  background: var(--green);
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-settings-save:hover {
  background: var(--green-dim);
  box-shadow: 0 0 16px var(--green-glow);
}

.settings-save-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--green-dim);
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.3s;
}
.settings-save-status.visible { opacity: 1; }

/* ===================== PER-PROBLEM COPY BUTTONS ===================== */

/* Problem title row: flex so copy btn sits at the far right */
.problem-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.problem-title-row .problem-title {
  flex: 1;
  min-width: 0;
}

/* Per-problem copy button — hidden by default, shown on hover */
.btn-copy-problem {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  pointer-events: none;
}

.problem-block:hover .btn-copy-problem,
.problem-block:focus-within .btn-copy-problem {
  opacity: 1;
  pointer-events: auto;
}

.btn-copy-problem:hover {
  color: var(--green);
  background: var(--green-glow-sm);
  border-color: var(--border-bright);
}

.btn-copy-problem.copied {
  color: var(--green);
  background: var(--green-glow-sm);
  border-color: var(--green-dim);
}

/* Keep contenteditable from consuming clicks on copy button */
.problem-block[contenteditable="true"] .btn-copy-problem {
  pointer-events: auto;
}

/* ===================== SPLIT COPY BUTTON (Copy All + Dropdown) ===================== */

.copy-split-btn {
  display: flex;
  align-items: center;
  position: relative;
  border-radius: 6px;
  overflow: visible;
}

.btn-copy.btn-copy-main {
  border-radius: 6px 0 0 6px;
  border-right: 1px solid rgba(0, 229, 160, 0.2);
  padding: 0.3rem 0.65rem;
  gap: 0.35rem;
  font-size: 0.72rem;
  white-space: nowrap;
}

.btn-copy.btn-copy-chevron {
  border-radius: 0 6px 6px 0;
  padding: 0.3rem 0.45rem;
  min-width: 26px;
  justify-content: center;
  display: flex;
  align-items: center;
}

.btn-copy.btn-copy-chevron svg {
  transition: transform 0.18s ease;
}

.btn-copy.btn-copy-chevron[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* Dropdown menu */
.copy-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 200px;
  max-width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 500;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.copy-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.copy-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-dropdown-item:hover {
  background: var(--green-glow-sm);
  color: var(--green);
}

.copy-dropdown-all {
  color: var(--text-bright);
  font-size: 0.72rem;
}

.copy-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.copy-dropdown-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--border-bright);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 600;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.copy-dropdown-item:hover .copy-dropdown-num {
  background: var(--green-dim);
  color: var(--bg);
}
