/* ========================================================
   RulesForge — AI Rules & AGENTS.md Generator Stylesheet
   Modern Dark Glassmorphism Design System (Compacted)
   ======================================================== */

:root {
  color-scheme: dark;
  --bg: #070d19;
  --panel: #0e1728;
  --panel-border: #22334d;
  --panel-hover: #15233c;
  --text: #eef5fc;
  --text-muted: #8fa4c0;
  --text-dim: #607693;
  --mint: #5be0be;
  --mint-glow: rgba(91, 224, 190, 0.18);
  --blue: #86a6ff;
  --amber: #f5c479;
  --red: #ff7f8a;
  --radius: 14px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse 75% 35% at 55% 0%, rgba(32, 78, 105, 0.28), transparent 85%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}
.wrap { max-width: 1540px; margin: 0 auto; padding: 0 24px; }

/* Unified Custom Scrollbars (Tabs, Code Preview, Inputs, Global) */
* {
  scrollbar-width: thin;
  scrollbar-color: #3b506d #091322;
}
::-webkit-scrollbar,
.artifact-tabs-container::-webkit-scrollbar,
.code-preview::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track,
.artifact-tabs-container::-webkit-scrollbar-track,
.code-preview::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  background: #091322;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb,
.artifact-tabs-container::-webkit-scrollbar-thumb,
.code-preview::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: #3b506d;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover,
.artifact-tabs-container::-webkit-scrollbar-thumb:hover,
.code-preview::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
  background: #5b7da8;
}
::-webkit-scrollbar-corner {
  background: #091322;
}

/* Topbar & Brand */
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(143, 172, 215, 0.12); }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 20px; letter-spacing: -0.5px; }
.brand-icon { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--mint), #8eaaff); display: grid; place-items: center; color: #06121f; font-weight: 900; font-size: 15px; letter-spacing: -0.5px; box-shadow: 0 4px 20px var(--mint-glow); }
.brand span span { color: var(--mint); }
.nav-badge { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; color: var(--mint); background: rgba(91, 224, 190, 0.08); border: 1px solid rgba(91, 224, 190, 0.25); padding: 5px 11px; border-radius: 100px; display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); }

/* Hero */
.hero { padding: 40px 0 26px; }
.hero-eyebrow { color: var(--mint); font-size: 11px; letter-spacing: 1.8px; text-transform: uppercase; font-weight: 850; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
h1 { font-size: clamp(28px, 3.8vw, 46px); letter-spacing: -1.6px; line-height: 1.15; margin: 0 0 14px; font-weight: 850; max-width: 900px; }
h1 em { font-style: normal; background: linear-gradient(95deg, #7af8d4, #a4b4ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-muted); max-width: 820px; font-size: 15px; line-height: 1.65; margin: 0; }

/* Grid Layout & Panels */
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 0.85fr); gap: 24px; align-items: start; padding-bottom: 60px; }
.panel { background: linear-gradient(160deg, rgba(16, 26, 44, 0.95), rgba(11, 19, 34, 0.98)); border: 1px solid var(--panel-border); border-radius: 18px; box-shadow: 0 14px 45px rgba(0, 0, 0, 0.28); overflow: hidden; }
.panel-head { padding: 14px 20px; min-height: 72px; box-sizing: border-box; border-bottom: 1px solid rgba(143, 172, 215, 0.12); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.preview-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; min-height: 72px; box-sizing: border-box; flex-wrap: nowrap; }
.preview-head-meta { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.preview-head-meta .overline { margin: 0; display: inline-block; white-space: nowrap; flex-shrink: 0; font-size: 10px; font-weight: 850; letter-spacing: 1.4px; }
.overline { font-size: 10px; font-weight: 850; letter-spacing: 1.6px; text-transform: uppercase; color: var(--mint); display: block; }
.panel h2 { font-size: 18px; margin: 3px 0 0; letter-spacing: -0.4px; line-height: 1.2; }
.panel-body { padding: 22px 24px; }

/* Form Fields */
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.field label, .field-title { font-size: 13px; font-weight: 750; color: #e4eefa; }
.hint { font-size: 11px; color: var(--text-dim); font-weight: 400; }
input[type=text], textarea, select { width: 100%; border: 1px solid #2d405b; border-radius: 11px; background: #091322; color: var(--text); padding: 11px 13px; outline: none; transition: border-color .16s, box-shadow .16s; }
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-glow); }
input::placeholder, textarea::placeholder { color: #647b99; }
textarea { min-height: 85px; resize: vertical; line-height: 1.6; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Presets & Platform Grid */
.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.preset-btn { font-size: 11px; font-weight: 650; color: #b7cde6; background: #152236; border: 1px solid #2d415d; border-radius: 100px; padding: 5px 11px; transition: all .15s; }
.preset-btn:hover { background: #1f3350; border-color: var(--mint); color: #fff; transform: translateY(-1px); }
.platform-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.platform-toolbar-actions { display: flex; gap: 6px; }
.platform-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 8px; }
.platform-card { background: #0b1424; border: 1px solid #293d57; border-radius: 12px; padding: 11px 10px; text-align: left; color: #bcd0e8; transition: all .16s; position: relative; }
.platform-card:hover { background: #14233a; border-color: #55b79e; }
.platform-card.active { border-color: var(--mint); background: rgba(91, 224, 190, 0.1); color: #f1fffa; box-shadow: inset 0 0 0 1px var(--mint); }
.pl-header { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 780; margin-bottom: 3px; }
.pl-icon { font-size: 16px; line-height: 1; }
.pl-file { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; color: var(--mint); display: block; margin-top: 2px; }
.pl-tag { font-size: 9px; opacity: 0.72; display: block; margin-top: 3px; line-height: 1.3; }
.platform-card .pl-toggle { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; border-radius: 4px; border: 1px solid #3c5475; background: #091322; display: grid; place-items: center; font-size: 10px; color: transparent; transition: all .15s; }
.platform-card.active .pl-toggle { background: var(--mint); border-color: var(--mint); color: #061720; font-weight: 900; }

/* Buttons */
.button { border-radius: 11px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 13px; font-weight: 750; padding: 10px 16px; transition: all .16s; }
.button.primary { color: #05161f; background: linear-gradient(105deg, #64edc5, #a3d9d3); }
.button.primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.button.secondary { color: #dbeaff; background: #1b2d46; border-color: #314663; }
.button.secondary:hover { background: #243b5c; color: #fff; }
.button.ghost { color: #a9bed7; background: transparent; border-color: #2b3e57; }
.button.ghost:hover { background: #142236; color: #fff; }
.button.small { padding: 0 9px; height: 27px; font-size: 11px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; font-weight: 750; white-space: nowrap; flex-shrink: 0; }
.button.zip { background: linear-gradient(105deg, #5be0be, #4aa6ff); color: #04141e; font-weight: 850; border: none; box-shadow: 0 3px 12px rgba(91, 224, 190, 0.22); }
.button.zip:hover { filter: brightness(1.12); transform: translateY(-1px); }

/* Studio Navigation Tabs (Stage F) */
.studio-tabs-bar { display: flex; flex-wrap: wrap; align-items: center; background: #08121f; border-bottom: 1px solid rgba(143, 172, 215, 0.12); padding: 10px 14px; gap: 8px; }
.studio-tab-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: 30px; font-size: 12px; font-weight: 600; color: #8ea7c7; background: #0e192a; border: 1px solid #1f324c; border-radius: 8px; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all .15s ease; box-sizing: border-box; }
.studio-tab-btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.studio-tab-btn:hover { background: #15263f; color: #fff; border-color: #3b577d; }
.studio-tab-btn.active { background: rgba(91, 224, 190, 0.12); border-color: var(--mint); color: #e6fcf5; font-weight: 750; box-shadow: 0 0 12px rgba(91, 224, 190, 0.15); }
.studio-tab-btn .tab-badge { background: #1b2e47; color: #9cb5d1; font-size: 10px; padding: 1px 6px; border-radius: 10px; }
.studio-tab-btn.active .tab-badge { background: var(--mint); color: #051a24; font-weight: 800; }
.studio-tab-pane { display: none; }
.studio-tab-pane.active { display: block; }

/* Artifact Tabs Explorer */
.artifact-tabs-container {
  background: #08121f;
  border-bottom: 1px solid rgba(143, 172, 215, 0.12);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-height: 116px;
  overflow-y: auto;
  box-sizing: border-box;
}
.artifact-tab { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; height: 28px; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: #111e32; border: 1px solid #243750; border-radius: 7px; color: #9cb5d1; white-space: nowrap; cursor: pointer; transition: all .15s; box-sizing: border-box; }
.artifact-tab:hover { background: #192a46; border-color: #3e5a82; color: #fff; }
.artifact-tab.active { background: rgba(91, 224, 190, 0.12); border-color: var(--mint); color: #e6fcf5; font-weight: 700; box-shadow: 0 0 10px rgba(91, 224, 190, 0.15); }
.artifact-tab-icon { font-size: 12px; }

/* Preview Section */
.preview-panel { position: sticky; top: 20px; }
.file-badge { background: #18283e; color: var(--mint); border: 1px solid rgba(91, 224, 190, 0.35); border-radius: 6px; padding: 0 7px; height: 24px; display: inline-flex; align-items: center; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; font-weight: 700; box-sizing: border-box; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.spec-badge { font-size: 10px; color: #adc4dd; border: 1px solid #283d57; border-radius: 100px; padding: 0 7px; height: 20px; display: inline-flex; align-items: center; box-sizing: border-box; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.preview-controls { display: flex; gap: 5px; align-items: center; flex-shrink: 0; }
.code-preview { margin: 0; padding: 22px 24px; background: #08111e; color: #d2e4f6; font: 12px/1.75 ui-monospace, "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 650px; min-height: 480px; overflow-y: auto; tab-size: 2; }
.preview-foot { padding: 12px 20px; background: #101a2d; border-top: 1px solid rgba(143, 172, 215, 0.12); display: flex; justify-content: space-between; align-items: center; color: var(--text-dim); font-size: 11px; }
.notice { background: rgba(245, 196, 121, 0.07); border: 1px solid rgba(245, 196, 121, 0.22); padding: 13px 15px; border-radius: 11px; font-size: 11px; color: #ded1b4; line-height: 1.6; margin-top: 18px; }
.notice strong { color: var(--amber); }

/* Accordions & Card Items */
.accordion-box { background: #091322; border: 1px solid #243750; border-radius: 12px; margin-top: 14px; overflow: hidden; }
.accordion-header { padding: 12px 16px; background: #0f1c30; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.accordion-header h3 { margin: 0; font-size: 13px; font-weight: 750; color: #e2eefb; display: flex; align-items: center; gap: 8px; }
.accordion-body { padding: 16px; }
.card-item { background: #0d182a; border: 1px solid #20334d; border-radius: 10px; padding: 12px; margin-bottom: 12px; position: relative; }
.card-item:last-child { margin-bottom: 0; }
.card-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.btn-remove-item { background: transparent; border: 1px solid #4a2830; color: #ff8e99; font-size: 10px; padding: 2px 7px; border-radius: 5px; }
.btn-remove-item:hover { background: #3b171f; border-color: #ff5264; color: #fff; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; border: 1px solid rgba(91, 224, 190, 0.4); background: #11342d; color: #e5fff7; padding: 11px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); opacity: 0; transform: translateY(10px); pointer-events: none; transition: all .2s; z-index: 100; }
.toast.show { opacity: 1; transform: none; }

/* Consolidated Responsive Media Queries */
@media (max-width: 1050px) {
  .layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .code-preview { max-height: 480px; }
  .platform-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .studio-tabs-bar { padding: 8px 10px; gap: 6px; }
  .studio-tab-btn { padding: 5px 9px; font-size: 11px; }
  .platform-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-item-header { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .platform-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
}
