/* ============================================
   IDEA FORGE — Dark Editorial Design
   ============================================ */

:root {
  --bg-deep: #0e0e12;
  --bg-surface: #16161d;
  --bg-elevated: #1e1e28;
  --bg-hover: #252532;

  /* Theme accent colors — overridden by data-theme attribute */
  --accent: #c8a87a;
  --accent-dim: #a08860;
  --accent-bright: #e0c89a;
  --accent-glow: rgba(100, 60, 120, 0.06), rgba(40, 80, 60, 0.03);

  /* Legacy aliases — keep pointing at accent for backwards compat */
  --gold: var(--accent);
  --gold-dim: var(--accent-dim);
  --gold-bright: var(--accent-bright);

  --green: #4a8030;
  --green-bright: #5da038;
  --red: #c85050;

  --text-primary: #e8e4de;
  --text-secondary: #9a9590;
  --text-muted: #5a5550;

  --border: #2a2a35;
  --border-light: #3a3a48;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --transition: 150ms ease;
}

/* ---- Color Themes ---- */

[data-theme="forge"] {
  --accent: #c8a87a;
  --accent-dim: #a08860;
  --accent-bright: #e0c89a;
  --accent-glow: rgba(100, 60, 30, 0.07), rgba(40, 80, 60, 0.03);
}

[data-theme="arcane"] {
  --accent: #a078c8;
  --accent-dim: #7d5aa0;
  --accent-bright: #c8a0e8;
  --accent-glow: rgba(100, 40, 140, 0.09), rgba(60, 20, 80, 0.04);
}

[data-theme="circuit"] {
  --accent: #50c8b8;
  --accent-dim: #3a9e90;
  --accent-bright: #80e0d4;
  --accent-glow: rgba(20, 100, 100, 0.08), rgba(10, 60, 80, 0.04);
}

[data-theme="ember"] {
  --accent: #c87850;
  --accent-dim: #a05c38;
  --accent-bright: #e8a070;
  --accent-glow: rgba(140, 50, 20, 0.08), rgba(100, 40, 10, 0.04);
}

[data-theme="frost"] {
  --accent: #6090d0;
  --accent-dim: #4870a8;
  --accent-bright: #88b4e8;
  --accent-glow: rgba(30, 60, 120, 0.09), rgba(20, 40, 100, 0.04);
}

/* ---- Reset & Base ---- */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--gold-dim);
  color: var(--bg-deep);
}

/* ---- Custom Title Bar ---- */

#titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  user-select: none;
  padding: 0 8px 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

#titlebar-drag {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

#titlebar-buttons {
  display: flex;
  gap: 2px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.titlebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.titlebar-btn-close:hover {
  background: var(--red);
  color: #fff;
}

/* ---- App Container ---- */

#app {
  height: calc(100% - 36px);
  margin-top: 36px;
  overflow-y: auto;
  position: relative;
}

/* Ambient background glow */
#app::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(
    ellipse at center,
    color-mix(in srgb, var(--accent) 8%, transparent) 0%,
    color-mix(in srgb, var(--accent) 3%, transparent) 40%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  transition: background 400ms ease;
}

/* ---- Screens ---- */

.screen {
  position: relative;
  z-index: 1;
  padding: 32px 40px;
  min-height: 100%;
  animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Typography ---- */

.app-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 20px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  margin-top: 16px;
}

.helper-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.error-text {
  font-size: 13px;
  color: var(--red);
  margin-top: 12px;
  min-height: 18px;
}

.validating-text {
  font-size: 13px;
  color: var(--gold-dim);
  margin-top: 12px;
}

.link {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}

.link:hover {
  border-bottom-color: var(--gold);
}

/* ---- Buttons ---- */

.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

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

.btn-primary {
  background: var(--gold-dim);
  color: var(--bg-deep);
  border-color: var(--gold);
  font-weight: 600;
}

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

.btn-primary:disabled {
  background: var(--gold-dim);
  opacity: 0.4;
}

.btn-large {
  padding: 14px 32px;
  font-size: 15px;
  width: 100%;
  margin-top: 20px;
}

.btn-forge {
  width: 100%;
  padding: 16px 32px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: var(--bg-deep);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 200ms ease;
  margin-top: 16px;
  letter-spacing: 0.3px;
}

.btn-forge:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(200, 168, 122, 0.2);
}

.btn-forge:active {
  transform: translateY(0);
}

.btn-develop {
  background: var(--green);
  color: #fff;
  border-color: var(--green-bright);
  font-weight: 600;
}

.btn-develop:hover {
  background: var(--green-bright);
}

.btn-secondary {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

.btn-ghost {
  border: none;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: transparent;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--gold);
  border-color: var(--border-light);
}

/* ---- Inputs ---- */

.input-field {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}

.input-field:focus {
  border-color: var(--gold-dim);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.textarea-field {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

.select-field {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%239a9590' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.select-field option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ---- Setup Screen ---- */

.setup-container {
  max-width: 420px;
  margin: 0 auto;
  padding-top: 40px;
  text-align: center;
}

.setup-subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  margin-bottom: 28px;
  font-size: 15px;
}

.setup-key-section {
  text-align: left;
  margin-top: 20px;
}

.key-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.key-input-wrap .input-field {
  padding-right: 60px;
}

.btn-show-key {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  transition: color var(--transition);
}

.btn-show-key:hover {
  color: var(--gold);
}

.setup-model-row {
  text-align: left;
  margin-top: 16px;
}

/* ---- Provider Pills ---- */

.provider-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.provider-pill {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.provider-pill:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.provider-pill.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--bg-deep);
}

/* ---- Main Screen ---- */

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

/* ---- Model Status Bar ---- */

.model-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin-bottom: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}

.model-status-bar:hover {
  border-color: var(--border-light);
  background: var(--bg-elevated);
}

.model-status-provider {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.model-status-model {
  font-size: 12px;
  color: var(--text-secondary);
}

.model-status-model::before {
  content: '·';
  margin-right: 8px;
  color: var(--text-muted);
}

/* ---- Category Bar ---- */

.category-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-pill {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.category-pill:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.category-pill.active {
  background: var(--bg-elevated);
  border-color: var(--gold-dim);
  color: var(--gold);
}

/* ---- Mode Cards ---- */

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.mode-card:hover {
  border-color: var(--border-light);
  background: var(--bg-elevated);
}

.mode-card.active {
  border-color: var(--gold-dim);
  background: var(--bg-elevated);
}

.mode-icon {
  font-size: 22px;
  line-height: 1;
}

.mode-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.mode-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Mode Inputs ---- */

#mode-inputs {
  margin-bottom: 4px;
}

.mode-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 150ms ease;
}

/* ---- Result Area ---- */

.result-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-top: 20px;
  line-height: 1.7;
  font-size: 14px;
  color: var(--text-primary);
  animation: fadeIn 300ms ease;
  max-height: 480px;
  overflow-y: auto;
}

.result-box strong {
  color: var(--gold);
}

.result-box em {
  color: var(--text-secondary);
  font-style: italic;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---- Loading Spinner ---- */

.forge-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  font-style: italic;
}

/* ---- Header Actions ---- */

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

/* ---- Library Panel ---- */

.library-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: slideIn 180ms ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.library-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--gold);
  font-weight: 600;
}

.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-item {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
  position: relative;
}

.library-item:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.library-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 20px;
}

.library-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 8px;
}

.library-item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}

.library-item:hover .library-item-delete {
  opacity: 1;
}

.library-item-delete:hover {
  color: var(--red);
}

.library-item-pipeline {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  white-space: nowrap;
}

.library-item:hover .library-item-pipeline {
  opacity: 1;
}

.library-item-pipeline:hover {
  color: var(--accent);
}

.library-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 16px;
  font-style: italic;
}

/* ---- Settings Defaults ---- */

.settings-defaults-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: left;
}

/* ---- Theme Picker ---- */

.theme-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.theme-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.theme-swatch:hover {
  transform: scale(1.1);
}

.theme-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

.theme-swatch[data-theme="forge"]  { background: #c8a87a; }
.theme-swatch[data-theme="arcane"] { background: #a078c8; }
.theme-swatch[data-theme="circuit"]{ background: #50c8b8; }
.theme-swatch[data-theme="ember"]  { background: #c87850; }
.theme-swatch[data-theme="frost"]  { background: #6090d0; }

.theme-swatch-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: pointer;
}

/* ---- Library Sort Controls ---- */

.library-sort {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  flex-wrap: wrap;
}

.library-sort-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.library-sort-btn:hover {
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.library-sort-btn.active {
  background: var(--bg-elevated);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ---- Library Backdrop ---- */

.library-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
}

/* ---- Library Search ---- */

.library-search-wrap {
  padding: 8px 8px 0;
  flex-shrink: 0;
}

.library-search-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.library-search-input:focus {
  border-color: var(--accent-dim);
}

.library-search-input::placeholder {
  color: var(--text-muted);
}

/* ---- Vibe Chips ---- */

.vibe-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.vibe-chip {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.vibe-chip:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ---- Field Optional Label ---- */

.field-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  font-size: 11px;
}

/* ---- Intake Screen ---- */

.intake-container {
  max-width: 520px;
  margin: 0 auto;
}

.intake-preview {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

.intake-fields {
  margin-bottom: 8px;
}

/* ---- Pill Group ---- */

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

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

.pill.active {
  background: var(--bg-elevated);
  border-color: var(--gold-dim);
  color: var(--gold);
}

/* ---- Export Screen ---- */

.export-container {
  max-width: 580px;
  margin: 0 auto;
}

.export-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.export-tab {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: none;
}

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

.export-tab.active {
  background: var(--bg-surface);
  color: var(--gold);
  border-color: var(--border-light);
}

.export-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 20px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 340px;
  overflow-y: auto;
  margin: 0;
}

.export-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---- Copy Confirmation ---- */

.btn-copied {
  background: var(--green) !important;
  border-color: var(--green-bright) !important;
  color: #fff !important;
}

/* ---- Scrollbar ---- */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

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

@media (max-width: 640px) {
  .screen {
    padding: 24px 20px;
  }

  .mode-cards {
    grid-template-columns: 1fr;
  }

  .app-title {
    font-size: 28px;
  }

  /* Export screen: stack columns vertically on mobile */
  .export-split-view {
    flex-direction: column !important;
  }

  .export-split-col {
    width: 100% !important;
  }

  .export-box {
    min-height: 30vh !important;
  }
}

/* ---- Phase 1 New Styles ---- */

/* Scope Bar */
.scope-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.scope-pill {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.scope-pill:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.scope-pill.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--bg-deep);
}

/* Multi-select box */
.multi-select-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 120px;
  overflow-y: auto;
  padding: 8px;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
}

.multi-select-item:hover {
  background: var(--bg-hover);
}

/* Result Meta (Status & Annotation) */
.result-meta {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: fadeIn 300ms ease;
}

.result-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.result-annotation {
  min-height: 80px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Projects Screen */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card {
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.project-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.project-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.project-type-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.project-desc-preview {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Pipeline Screen (P1.3) ---- */

.pipeline-container {
  max-width: 620px;
  margin: 0 auto;
}

.pipeline-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pipeline-header .screen-title {
  margin-bottom: 0;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Stage strip */
.pipeline-stage-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.pipeline-chip {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text-muted);
}

.pipeline-chip--done {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-deep));
  border-color: var(--accent-dim);
  color: var(--accent-bright);
}

/* Stage cards */
.pipeline-stages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pipeline-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.pipeline-card--done {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.pipeline-card-header {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 0 10px;
  margin-bottom: 1rem;
}

.pipeline-card-num {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-deep);
  flex-shrink: 0;
}

.pipeline-card--done .pipeline-card-num {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-deep));
}

.pipeline-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipeline-card-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.pipeline-card-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.pipeline-card-status {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-deep);
  white-space: nowrap;
}

.pipeline-card--done .pipeline-card-status {
  border-color: var(--accent-dim);
  color: var(--accent-bright);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-deep));
}

.pipeline-card-note {
  font-size: 13px;
  color: var(--text-muted);
}

.pipeline-card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pipeline-artifact-preview {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.pipeline-card-actions .btn {
  width: 100%;
}

/* Mobile gate */
.pipeline-mobile-gate {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.pipeline-gate-msg {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pipeline-gate-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Import zone */
.pipeline-import-zone {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.pipeline-import-textarea {
  min-height: 160px;
}

.pipeline-import-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Streaming output area */
.pipeline-stream-area {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pipeline-stream-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

.pipeline-stream-error {
  margin: 0;
}

/* Per-stage provider + model override row (Option B) */
.pipeline-model-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.pipeline-model-default-info {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pipeline-model-overrides {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pipeline-model-overrides .pipeline-provider-select {
  flex: 0 0 auto;
  width: auto;        /* override .input-field width: 100% */
  max-width: 48%;
  font-size: 12px;
  padding: 5px 8px;
  height: auto;
}

.pipeline-model-overrides .pipeline-model-input {
  flex: 1;
  width: 0;           /* allow flex to control width, not .input-field's 100% */
  min-width: 0;
  font-size: 12px;
  padding: 5px 8px;
  height: auto;
}

/* Category selector (P1.9) */
.pipeline-category-section {
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.pipeline-category-prompt {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pipeline-category-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.pipeline-category-row .select-field {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
  height: auto;
}

.pipeline-category-save-btn {
  width: 100%;
}

.pipeline-category-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pipeline-category-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 20px;
  padding: 3px 10px;
}

.pipeline-category-change-btn {
  font-size: 12px;
  padding: 3px 8px;
}

/* Context Documents section (P1.10 / D027) */
.pipeline-context-section {
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.pipeline-context-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pipeline-context-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pipeline-context-count {
  font-size: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 20px;
  padding: 1px 8px;
}

.pipeline-context-empty {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px 0;
  font-style: italic;
}

.pipeline-context-doc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.pipeline-context-doc-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.pipeline-context-doc-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-context-doc-level {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.pipeline-context-add-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.pipeline-context-btn-remove {
  font-size: 11px;
  padding: 2px 6px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.pipeline-context-add-form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-context-form-actions {
  display: flex;
  gap: 8px;
}

.pipeline-context-form-error {
  margin: 0;
}

/* Result area — pipeline as primary CTA */
.result-pipeline-primary {
  width: 100%;
  margin-bottom: 10px;
}

.result-actions-secondary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.result-actions-secondary .btn-secondary {
  flex: 1;
}

.result-develop-btn {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

