/* ==========================================================================
   CodeForge — Main Stylesheet
   Dark-first, developer-focused, Windows PWA optimized
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables / Design Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Base colors — dark theme */
  --bg-base: #0d0d14;
  --bg-surface: #13131e;
  --bg-elevated: #1a1a28;
  --bg-hover: #1f1f30;
  --bg-active: #252540;
  --bg-input: #111120;

  /* Borders */
  --border-subtle: rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);

  /* Text */
  --text-primary: #e4e4f0;
  --text-secondary: #8888aa;
  --text-muted: #5555777;
  --text-inverse: #0d0d14;

  /* Accent — electric cyan */
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.12);
  --accent-hover: #33ddff;

  /* Semantic colors */
  --success: #00e676;
  --success-dim: rgba(0, 230, 118, 0.12);
  --warning: #ffd740;
  --warning-dim: rgba(255, 215, 64, 0.12);
  --error: #ff5252;
  --error-dim: rgba(255, 82, 82, 0.12);
  --info: #448aff;

  /* Syntax highlight colors */
  --syn-key: #cf9fff;
  --syn-str: #a8ff82;
  --syn-num: #ffd740;
  --syn-bool: #00d4ff;
  --syn-null: #ff7070;
  --syn-punct: #6679aa;

  /* Layout */
  --sidebar-width: 230px;
  --title-bar-height: 38px;
  --header-height: 64px;
  --border-radius: 6px;
  --border-radius-lg: 10px;

  /* Fonts */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-med: 0.22s ease;
}

/* Light theme overrides */
.theme-light {
  --bg-base: #f0f0f8;
  --bg-surface: #ffffff;
  --bg-elevated: #e8e8f4;
  --bg-hover: #e0e0ee;
  --bg-active: #d8d8ef;
  --bg-input: #f8f8ff;
  --border-subtle: rgba(0,0,0,0.06);
  --border-default: rgba(0,0,0,0.10);
  --border-strong: rgba(0,0,0,0.18);
  --text-primary: #1a1a2e;
  --text-secondary: #5555777;
  --text-muted: #8888aa;
  --text-inverse: #ffffff;
  --syn-key: #7c3aed;
  --syn-str: #166534;
  --syn-num: #b45309;
  --syn-bool: #0369a1;
  --syn-null: #dc2626;
  --syn-punct: #6b7280;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  user-select: none;
}

/* Allow text selection in content areas */
.tool-content,
textarea,
input[type="text"],
input[type="search"],
input[type="number"],
pre,
code {
  user-select: text;
}

/* --------------------------------------------------------------------------
   Scrollbar styling
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Title Bar (Window Controls Overlay)
   -------------------------------------------------------------------------- */
.title-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--title-bar-height);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 12px;
  z-index: 1000;
  -webkit-app-region: drag;
  app-region: drag;

  /* Support for Window Controls Overlay API */
  padding-left: env(titlebar-area-x, 12px);
  padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 8px);
  top: env(titlebar-area-y, 0);
  left: env(titlebar-area-x, 0);
  width: env(titlebar-area-width, 100%);
  height: env(titlebar-area-height, 38px);
}

.title-bar-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.app-icon-small {
  font-size: 15px;
  color: var(--accent);
  line-height: 1;
}

.app-name-small {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.title-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.title-bar-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.title-bar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.offline-indicator {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--warning);
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--warning-dim);
  display: none; /* shown via JS when offline */
}

.offline-indicator.visible {
  display: block;
}

/* --------------------------------------------------------------------------
   App Shell
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  height: 100vh;
  padding-top: calc(var(--title-bar-height) + env(titlebar-area-y, 0px));
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-search {
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px 7px 30px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236679aa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 9px center;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

/* Tool navigation list */
.tool-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 14px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-name {
  flex: 1;
}

.nav-item-favorite {
  font-size: 12px;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.nav-item-favorite:hover,
.nav-item-favorite.active {
  opacity: 1;
  color: var(--warning);
}

.nav-item.hidden {
  display: none;
}

/* Sidebar footer / pro panel */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
}

.pro-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pro-badge.unlocked {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.pro-icon {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.pro-text {
  flex: 1;
  min-width: 0;
}

.pro-text strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pro-text small {
  font-size: 10px;
  color: var(--text-secondary);
}

.pro-cta {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.pro-cta:hover {
  background: var(--accent-dim);
}

/* --------------------------------------------------------------------------
   Main Panel
   -------------------------------------------------------------------------- */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Tool Header */
.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
  gap: 16px;
}

.tool-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tool-icon-large {
  font-size: 24px;
  flex-shrink: 0;
}

.tool-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.tool-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Tool Content */
.tool-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --------------------------------------------------------------------------
   Welcome Screen
   -------------------------------------------------------------------------- */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 700px;
  margin-top: 24px;
}

.welcome-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-lg);
  padding: 20px 12px;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.welcome-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.welcome-card-icon {
  font-size: 28px;
}

.welcome-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Tool Layout Primitives
   -------------------------------------------------------------------------- */

/* Two-column panel split */
.panel-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
}

/* Single full-width panel */
.panel-single {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Panel card */
.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panel-card-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Form Controls
   -------------------------------------------------------------------------- */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast);
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.textarea-fill {
  flex: 1;
  min-height: 0;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236679aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* Radio / Checkbox row */
.toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-btn {
  padding: 5px 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error-dim);
  color: var(--error);
  border-color: var(--error);
}

.btn-danger:hover {
  background: var(--error);
  color: white;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px 8px;
  min-width: 32px;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Code / Pre blocks
   -------------------------------------------------------------------------- */
pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius);
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Status / Alert banners
   -------------------------------------------------------------------------- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-size: 12px;
  font-family: var(--font-mono);
}

.status-bar.success {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(0, 230, 118, 0.2);
}

.status-bar.error {
  background: var(--error-dim);
  color: var(--error);
  border: 1px solid rgba(255, 82, 82, 0.2);
}

.status-bar.warning {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(255, 215, 64, 0.2);
}

.status-bar.info {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.2);
}

/* --------------------------------------------------------------------------
   JSON Tree Viewer
   -------------------------------------------------------------------------- */
.json-tree {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
}

.json-key { color: var(--syn-key); }
.json-string { color: var(--syn-str); }
.json-number { color: var(--syn-num); }
.json-boolean { color: var(--syn-bool); }
.json-null { color: var(--syn-null); }
.json-punct { color: var(--syn-punct); }

.json-collapsible {
  cursor: pointer;
  padding: 0 4px;
  border-radius: 3px;
  transition: background var(--transition-fast);
}

.json-collapsible:hover {
  background: var(--bg-hover);
}

.json-collapsed::after {
  content: ' … ';
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Diff Viewer
   -------------------------------------------------------------------------- */
.diff-line {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  padding: 0 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-added {
  background: rgba(0, 230, 118, 0.1);
  color: var(--success);
  border-left: 3px solid var(--success);
}

.diff-removed {
  background: rgba(255, 82, 82, 0.1);
  color: var(--error);
  border-left: 3px solid var(--error);
  text-decoration: line-through;
  opacity: 0.8;
}

.diff-unchanged {
  color: var(--text-secondary);
  border-left: 3px solid transparent;
}

/* --------------------------------------------------------------------------
   Regex Matcher highlights
   -------------------------------------------------------------------------- */
.regex-output {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  padding: 12px;
}

.regex-match {
  background: rgba(255, 215, 64, 0.25);
  border-bottom: 2px solid var(--warning);
  border-radius: 2px;
}

.regex-group-0 { background: rgba(0, 212, 255, 0.2); border-bottom: 2px solid var(--accent); }
.regex-group-1 { background: rgba(167, 139, 250, 0.2); border-bottom: 2px solid var(--syn-key); }

/* --------------------------------------------------------------------------
   Color preview swatch
   -------------------------------------------------------------------------- */
.color-swatch {
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius);
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.color-field-group {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 8px;
  align-items: center;
}

.color-label-small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   JWT sections
   -------------------------------------------------------------------------- */
.jwt-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.jwt-section-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.jwt-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.jwt-header-label { color: var(--error); }
.jwt-payload-label { color: var(--success); }
.jwt-sig-label { color: var(--warning); }

.jwt-body {
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

.jwt-disclaimer {
  font-size: 11px;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--warning-dim);
  border: 1px solid rgba(255,215,64,0.2);
  border-radius: var(--border-radius);
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--border-radius-lg);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInToast 0.2s ease forwards;
  max-width: 280px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--accent); }

.toast.fade-out {
  animation: fadeOutToast 0.3s ease forwards;
}

@keyframes slideInToast {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutToast {
  to { transform: translateX(20px); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--border-radius-lg);
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform var(--transition-med);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.pro-feature-list {
  list-style: none;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pro-feature-list li {
  font-size: 13px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-subtle);
}

.pro-unlock-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.pro-unlock-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pro-unlock-row {
  display: flex;
  gap: 8px;
}

.pro-code-input {
  flex: 1;
  font-family: var(--font-mono) !important;
  letter-spacing: 1px;
}

.pro-unlock-hint {
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}


/* --------------------------------------------------------------------------
   Copy button animation
   -------------------------------------------------------------------------- */
.btn-copy.copied {
  background: var(--success-dim);
  color: var(--success);
  border-color: var(--success);
}

/* --------------------------------------------------------------------------
   Utility classes
   -------------------------------------------------------------------------- */
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-small { font-size: 12px; }
.text-xs { font-size: 11px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .sidebar {
    display: none;
  }
  .panel-split {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Focus visible accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   Store / IAP specific styles
   -------------------------------------------------------------------------- */
.store-buy-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.store-note {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  padding: 0 4px;
}

.store-unlocked-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}



/* --------------------------------------------------------------------------
   LemonSqueezy Pro Modal — clean layout
   -------------------------------------------------------------------------- */

.ls-buy-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Primary buy button — full width, prominent */
.ls-buy-btn {
  width: 100%;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 20px;
  border-radius: var(--border-radius);
  letter-spacing: 0.2px;
}

/* Subtitle under buy button */
.store-note {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  margin-bottom: 0;
  line-height: 1.5;
}

/* "Already purchased?" divider */
.ls-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
}

.ls-divider::before,
.ls-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.ls-divider span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* License key block */
.ls-key-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ls-key-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Input + button in one row */
.ls-key-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.ls-key-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  letter-spacing: 0.8px;
  padding: 9px 12px !important;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ls-key-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.ls-key-input::placeholder {
  color: var(--text-muted);
  letter-spacing: 0;
  font-size: 11px;
  font-family: var(--font-mono);
}

.ls-activate-btn {
  flex-shrink: 0;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Privacy link */
.ls-privacy-link {
  text-align: center;
  margin-top: 12px;
  font-size: 11px;
}

.ls-privacy-link a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.ls-privacy-link a:hover {
  color: var(--accent);
}

/* Pro unlocked state */
.ls-unlocked-section {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.ls-deactivate-btn {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  opacity: 0.45;
}

.ls-deactivate-btn:hover {
  opacity: 1;
}