@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   ZellRayy — Studio Design Tokens
   Two moods: "Night Console" (Dark Charcoal) & "Paper Console" (Cream Ink)
   ========================================================================== */

:root {
  --radius: 12px;
  --radius-sm: 6px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- DARK (default) : black / charcoal / warm-cream accent ---------- */
:root,
[data-theme="dark"] {
  --bg: #0a0a0c;
  --bg-soft: #111114;
  --surface: #141417;
  --surface-2: #1c1c20;
  --surface-hover: #222227;
  --border: #26262a;
  --border-soft: #1a1a1e;
  --text: #ded9cd;
  --text-muted: #8e897e;
  --text-dim: #5a5750;
  --accent: #cdbd94;
  --accent-strong: #ded0aa;
  --accent-ink: #12110c;
  --accent-glow: rgba(205, 189, 148, 0.12);
  --success: #7fbf8f;
  --shadow: 0 12px 36px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
  --grain-opacity: .04;
  --code-bg: #0d0d0f;
  color-scheme: dark;
}

/* ---------- LIGHT : cream / beige / ink accent ---------- */
[data-theme="light"] {
  --bg: #f4eee1;
  --bg-soft: #ece3d0;
  --surface: #faf6ee;
  --surface-2: #efe4cb;
  --surface-hover: #e8dcc0;
  --border: #dcceaa;
  --border-soft: #e7dcbe;
  --text: #211f19;
  --text-muted: #756c5b;
  --text-dim: #a89c84;
  --accent: #1c1a16;
  --accent-strong: #000000;
  --accent-ink: #f6f0e2;
  --accent-glow: rgba(28, 26, 22, 0.08);
  --success: #3f7a52;
  --shadow: 0 12px 36px rgba(60,50,20,.10);
  --shadow-sm: 0 2px 10px rgba(60,50,20,.08);
  --grain-opacity: .03;
  --code-bg: #efe4cc;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease), color .35s var(--ease);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

::selection { background: var(--accent); color: var(--accent-ink); }

.font-display { font-family: 'Space Grotesk', 'Inter', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', 'Ubuntu Mono', monospace; }

a { color: inherit; text-decoration: none; }

/* subtle film-grain texture */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- layout atoms ---------- */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.surface-2 { background: var(--surface-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .82rem;
  padding: .65rem 1.15rem;
  border-radius: var(--radius-sm);
  transition: all .2s var(--ease);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4px 14px var(--accent-glow);
  filter: brightness(1.05);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--text-muted);
  background: var(--surface-hover);
  transform: translateY(-1.5px);
}

/* ---------- theme toggle: day/night dial ---------- */
.theme-dial {
  position: relative;
  width: 48px;
  height: 25px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: all .25s var(--ease);
}
.theme-dial:hover {
  border-color: var(--accent);
}
.theme-dial .knob {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  transition: left .3s var(--ease), background .3s var(--ease);
  color: var(--accent-ink);
}
[data-theme="light"] .theme-dial .knob { left: 25.5px; }

/* ---------- Navigation Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  width: 100%;
}

.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 11px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.brand-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.rate-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

/* ---------- 1 Unified Page Layout ---------- */
.page-container {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 18px;
  position: relative;
  z-index: 1;
}

/* Balanced 2-Column Grid with strict child containment */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  width: 100%;
}

.workspace-grid > * {
  min-width: 0;
  width: 100%;
}

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

/* ---------- Generator Form Panel ---------- */
.form-card {
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 15px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text);
}

.step-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.form-group {
  margin-bottom: 13px;
}

.form-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-group label .opt {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-dim);
}

.input-field, textarea.input-field {
  width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8.5px 11px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.input-field:focus, textarea.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

textarea.input-field {
  min-height: 72px;
  line-height: 1.45;
  resize: vertical;
}

.hint-text {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Segmented Output Format */
.segmented-box {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 3px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
  font-family: inherit;
}

.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Tab Switch (URL vs Upload) */
.tab-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  margin-bottom: 5px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* File Upload Box */
.file-upload-box {
  display: block;
  background: var(--code-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 9px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s;
}

.file-upload-box:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-upload-box input[type="file"] { display: none; }

.file-picked-info {
  font-size: 10px;
  color: var(--success);
  margin-top: 3px;
}

/* Quoted Reply Checkbox Box */
.reply-toggle-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 13px;
}

.reply-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.reply-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.reply-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.reply-expanded-fields {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--border-soft);
}

/* Formatting toolbar */
.format-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 5px 0;
}

.format-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
}

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

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 15px 0;
}

/* ---------- Preview Side (Right) ---------- */
.preview-card {
  padding: 18px;
}

.canvas-stage {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 16px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.canvas-stage.trans-grid {
  background-color: #101012;
  background-image: 
    linear-gradient(45deg, #18181c 25%, transparent 25%), 
    linear-gradient(-45deg, #18181c 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #18181c 75%), 
    linear-gradient(-45deg, transparent 75%, #18181c 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.canvas-stage.solid-chat {
  background: #080d11;
}

#previewCanvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
}

.format-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
  margin-top: 13px;
}

.status-msg {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 14px;
}
.status-msg.success { color: var(--success); }
.status-msg.error { color: #f87171; }

/* Console Payload & Codeblock */
.console {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.console-wrapper {
  margin-top: 13px;
}

.console-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.console-title-row span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.copy-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all .15s;
}

.copy-pill:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.copy-pill.copied {
  color: var(--success);
  border-color: var(--success);
}

pre.console-code {
  padding: 10px 12px;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
  word-wrap: normal;
  -webkit-overflow-scrolling: touch;
  line-height: 1.5;
  max-height: 240px;
  width: 100%;
  box-sizing: border-box;
}

pre.console-code .k { color: var(--accent); }
pre.console-code .s { color: #93c5fd; }
pre.console-code .b { color: #fca5a5; }

/* ---------- API Reference & Documentation Section ---------- */
.api-docs-section {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  width: 100%;
  max-width: 100%;
}

.docs-header {
  margin-bottom: 14px;
}

.docs-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.docs-header p {
  font-size: 11.5px;
  color: var(--text-muted);
}

.param-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
  width: 100%;
  max-width: 100%;
}

.param-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 11.5px;
  text-align: left;
}

.param-table th, .param-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.param-table th {
  background: var(--surface-2);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.param-table td code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10.5px;
}

.req-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  font-weight: 600;
}

.opt-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-dim);
}

/* 2-Column Code Snippets */
.code-snippets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  width: 100%;
  max-width: 100%;
}

.code-snippets-grid > * {
  min-width: 0;
  width: 100%;
}

@media (max-width: 720px) {
  .code-snippets-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Enhanced ZellRayy Footer ---------- */
footer.site-footer {
  margin-top: 36px;
  padding: 24px 18px 30px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
}

.footer-link {
  color: var(--text-muted);
  transition: color .2s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.footer-link:hover {
  color: var(--accent);
}

.footer-link.highlight {
  color: var(--accent);
  font-weight: 600;
}

.footer-dot {
  color: var(--text-dim);
  font-size: 10px;
}

.footer-copy {
  font-size: 11px;
  color: var(--text-dim);
}
