/* ==========================================================================
   Prompt Lab — app workspace (app.html only)
   Modern, intuitive layout on top of the shared style.css.
   ========================================================================== */

.app-body {
  --ink: #14213d;
  --muted: #5b6472;
  --line: #e4e7ee;
  --accent: #4f46e5;
  --accent-2: #7c3aed;

  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f6f7fb;
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  flex: none;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
}

.app-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.app-header .logo-svg {
  width: 24px;
  height: 24px;
}

.app-header .img-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: contain;
}

.app-header .header-tools {
  gap: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Usage chip + pills */
.usage-chip {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #e0e7ff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.account-email {
  font-size: 12.5px;
  color: #6b7280;
  white-space: nowrap;
}

.chip-btn {
  background: #fff;
  color: #4338ca;
  border: 1px solid #d8dff5;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.chip-btn:hover {
  background: #eef2ff;
  filter: none;
}

.chip-btn.accent {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border: none;
}

.chip-btn.accent:hover {
  filter: brightness(1.08);
}

.accent-btn {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: none;
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

.accent-btn:hover {
  filter: brightness(1.08);
  color: #fff;
}

/* Main split layout */
.split-view {
  flex: 1;
  min-height: 0;
}

.panel {
  overflow: auto;
}

.input-panel {
  background: #fff;
  border-right: 1px solid var(--line);
  gap: 12px;
  padding: 18px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#model-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%235b6472' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  background-color: #f1f3f9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 34px 9px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

#api-key-input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  background: #fff;
}

#prompt-input {
  flex: 1;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.65;
  resize: vertical;
  font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#prompt-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Action row */
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 10px 22px -10px rgba(99, 102, 241, 0.8);
  border-radius: 12px;
  padding: 11px 20px;
}

.run-btn:hover {
  filter: brightness(1.07);
}

.button-row .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  padding: 11px 16px;
}

/* Version nav */
.version-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f5fa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px;
  width: 100%;
}

.version-nav button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1;
}

.version-nav button:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #d8dff5;
}

#version-label {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: #9aa1b8;
  text-align: center;
}

/* Output panel */
.output-panel {
  background: #f6f7fb;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b90a5;
}

#output-display {
  flex: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

#output-display h1,
#output-display h2,
#output-display h3,
#output-display h4,
#output-display h5,
#output-display h6 {
  margin: 14px 0 6px;
  line-height: 1.3;
  color: #1e1e2f;
}

#output-display h1 { font-size: 20px; }
#output-display h2 { font-size: 17px; }
#output-display h3 { font-size: 15px; }
#output-display h4, #output-display h5, #output-display h6 { font-size: 14px; }

#output-display p { margin: 8px 0; }

#output-display ul,
#output-display ol {
  margin: 8px 0;
  padding-left: 22px;
  white-space: normal;
}

#output-display li { margin: 3px 0; }

#output-display pre {
  font-family: ui-monospace, monospace;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

#output-display code {
  font-family: ui-monospace, monospace;
  background: #1e293b;
  color: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

#output-display blockquote {
  margin: 8px 0;
  padding: 2px 14px;
  border-left: 3px solid #d1d5db;
  color: #4b5563;
  white-space: normal;
}

#output-display hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

#output-display .md-quote-line { margin: 4px 0; }

#output-display a { color: #2563eb; }

#output-display .md-code .md-lang {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding-bottom: 6px;
}

/* Compare */
.compare-panel {
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 16px 20px;
}

.compare-panel h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b90a5;
}

.compare-grid {
  margin-top: 12px;
}

.compare-column select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #f1f3f9;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.compare-output {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfd;
  padding: 14px;
  min-height: 110px;
  max-height: 300px;
  overflow: auto;
  font-size: 13.5px;
  line-height: 1.6;
}

.compare-output h1,
.compare-output h2,
.compare-output h3 {
  margin: 10px 0 4px;
  line-height: 1.3;
}

.compare-output p { margin: 6px 0; }
.compare-output ul,
.compare-output ol {
  margin: 6px 0;
  padding-left: 20px;
  white-space: normal;
}

.compare-output pre {
  font-family: ui-monospace, monospace;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  overflow-x: auto;
}

.compare-output code {
  font-family: ui-monospace, monospace;
  background: #1e293b;
  color: #e2e8f0;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

.compare-output blockquote {
  margin: 6px 0;
  padding: 1px 12px;
  border-left: 3px solid #cbd5e1;
  color: #4b5563;
  white-space: normal;
}

.compare-output a { color: #2563eb; }
.compare-output .md-code .md-lang { display: none; }

/* Share modal */
.share-modal .modal-actions {
  justify-content: flex-end;
}

.share-link-input {
  font-family: ui-monospace, monospace;
}

@media (max-width: 820px) {
  .app-body {
    height: auto;
    overflow: visible;
  }

  .app-header {
    height: auto;
    padding: 10px 14px;
  }

  .app-header .header-tools {
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
  }

  .usage-chip {
    width: 100%;
    text-align: center;
  }

  .account-email {
    width: 100%;
    text-align: center;
  }

  .split-view {
    height: auto;
  }

  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .output-panel {
    min-height: 40vh;
  }

  #output-display {
    min-height: 260px;
  }
}