:root {
  --bg: #0b1020;
  --surface: #121931;
  --surface-2: #192242;
  --border: #283562;
  --text: #eef2ff;
  --muted: #9aa7cc;
  --primary: #6366f1;
  --primary-hover: #7c7ff8;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top right, #1b2450 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.5px;
}

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 17px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.pill-privacy {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.pill-neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.step-line {
  flex: 1;
  min-width: 24px;
  height: 1px;
  background: var(--border);
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  margin: 2px 0 0;
  font-size: 13px;
}

.small {
  font-size: 12px;
}

.quick-prompt-card {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.32);
  border-radius: 10px;
  padding: 10px 12px;
}

.quick-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(255, 255, 255, 0.015);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.dropzone p {
  margin: 4px 0;
  font-size: 13px;
}

.dropzone-icon {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.link-like {
  color: #a5b4fc;
  text-decoration: underline;
}

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

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.textarea-input,
.textarea-output,
.input-control,
.select-control {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
}

.textarea-input,
.textarea-output {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.textarea-input:focus,
.textarea-output:focus,
.input-control:focus,
.select-control:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

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

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--primary);
}

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

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-chip {
  background: var(--surface-2);
  border-color: var(--border);
  color: #c7d2fe;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.btn-chip:hover {
  border-color: var(--primary);
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.tabs-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.editor-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-form {
  display: grid;
  grid-template-columns: 125px 1fr auto;
  gap: 8px;
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 410px;
  overflow-y: auto;
  padding-right: 4px;
}

.memory-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-card.disabled {
  opacity: 0.5;
}

.memory-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memory-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-select {
  background: var(--surface-2);
  color: #c7d2fe;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
}

.secret-badge {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 8px;
  font-weight: 600;
}

.memory-text-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 4px 6px;
}

.memory-text-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  outline: none;
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}

.btn-delete:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
}

.empty-state {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.target-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.target-btn.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: var(--primary);
  color: #fff;
}

.guide-banner {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #d1fae5;
}

.metrics-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.metric-accent {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions-between {
  justify-content: space-between;
}

.actions-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #111827;
  color: #ecfdf5;
  border: 1px solid var(--accent);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
  .add-form {
    grid-template-columns: 1fr;
  }
}

.ai-compress-card {
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.ai-compress-card summary {
  cursor: pointer;
  font-weight: 700;
  color: #6ee7b7;
}

.ai-preset-row {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}

.ai-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.pill-pro {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.55);
  color: #c7d2fe;
  text-decoration: none;
  cursor: pointer;
}

.pill-pro:hover {
  background: rgba(99, 102, 241, 0.32);
}

.pill-github {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.pill-github:hover {
  border-color: var(--primary);
}

.pro-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pro-header h2 {
  margin: 10px 0 4px;
  font-size: 22px;
}

.pro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.pro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pro-card-featured {
  border-color: rgba(129, 140, 248, 0.65);
  background: linear-gradient(160deg, rgba(99, 102, 241, 0.14), var(--surface) 60%);
}

.pro-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pro-card-top h3 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pro-badge-early {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.pro-price strong {
  font-size: 26px;
  color: #fff;
}

.pro-price span {
  font-size: 12px;
  color: var(--muted);
}

.pro-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.pro-features li::before {
  content: "✓ ";
  color: var(--accent);
  font-weight: 800;
}

.pro-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

.pro-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pro-form input {
  flex: 1 1 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}

.pro-support-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pro-support-link {
  color: #6ee7b7;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.pro-support-link:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .pro-grid {
    grid-template-columns: 1fr;
  }
}

.merge-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #c7d2fe;
  cursor: pointer;
}

.vault-card {
  margin-top: 8px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.vault-card summary {
  cursor: pointer;
  font-weight: 700;
  color: #c7d2fe;
}

.vault-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 6px;
}

.vault-row .input-control {
  flex: 1 1 180px;
}

.limit-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.limit-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 600;
}

.limit-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.limit-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease, background 0.2s ease;
}

.limit-fill.warn {
  background: var(--warn);
}

.limit-fill.over {
  background: var(--danger);
}

.actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.actions-right a.btn-chip {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
