/* alberto studio — DEPARTIFY brand tokens
   Source: manual de marca (docs.departify.app)
   Accent Lime #D8FF62 · Ink #0A0C08 · Forest #0E3D1A
   Radius: card 12 · control 8 · tag 999 · elevation 1/3 */

:root {
  --bg: #0a0c08;
  --panel: #0f110f;
  --panel-2: #14171f;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --fg: #fafafa;
  --fg-80: #e5e5e5;
  --muted: #8a8a8a;
  --fg-40: #6b6b6b;
  --accent: #d8ff62;
  --accent-ink: #0a0c08;
  --accent-soft: rgba(216, 255, 98, 0.12);
  --forest: #0e3d1a;
  --success: #30a46c;
  --warn: #f5a524;
  --danger: #e5484d;
  --radius-card: 12px;
  --radius-control: 8px;
  --elevation-1: 0 1px 0 rgba(0, 0, 0, 0.1);
  --elevation-3: 0 8px 24px rgba(0, 0, 0, 0.12);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
/* 1px grid every 32px at 4% opacity, faded radially — from the manual */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
}
button, input, textarea, select { font: inherit; color: inherit; }
.app { display: flex; flex-direction: column; height: 100vh; position: relative; z-index: 1; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 52px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 22px; height: 22px; display: block; }
.wordmark {
  font-weight: 600; font-size: 14px; letter-spacing: .16em; text-transform: uppercase;
}
.tag { color: var(--fg-40); font-size: 12px; letter-spacing: .01em; }
.bar-right { display: flex; align-items: center; gap: 10px; }
.lang {
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--fg-80);
  border-radius: var(--radius-control); padding: 6px 9px; font-size: 12.5px; cursor: pointer;
}
.lang:focus { border-color: var(--accent); outline: none; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--fg);
  padding: 7px 13px; border-radius: var(--radius-control); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.icon {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: var(--radius-control); cursor: pointer;
}
.icon:hover { color: var(--fg); border-color: var(--line-strong); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--panel-2);
}
.chip.small { font-size: 11px; padding: 2px 8px; }
.chip.clickable { cursor: pointer; }
.chip.clickable:hover { color: var(--fg); border-color: var(--accent); }
.chip.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--line)); }
.chip.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(360px, 1fr) minmax(420px, 1.15fr);
}
.side, .chat, .preview { min-height: 0; display: flex; flex-direction: column; }
.side { border-right: 1px solid var(--line); background: var(--panel); overflow: hidden; }
.chat { border-right: 1px solid var(--line); background: var(--bg); }
.preview { background: var(--panel); }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.side-head h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.projects { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; max-height: 42vh; }
.projects li { margin-bottom: 4px; }
.projects button {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  padding: 8px 10px; border-radius: var(--radius-control); cursor: pointer; display: block;
}
.projects button:hover { background: var(--panel-2); }
.projects button.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.projects .name { display: block; font-weight: 550; }
.projects .meta { display: block; font-size: 11px; color: var(--fg-40); margin-top: 2px; }
.side-foot { border-top: 1px solid var(--line); margin-top: auto; display: flex; flex-direction: column; min-height: 0; }
.tools { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; font-size: 11.5px; color: var(--fg-40); max-height: 34vh; }
.tools li { padding: 4px 10px; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools li b { color: var(--fg-80); font-weight: 500; }

.messages { flex: 1 1 auto; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.empty-state { margin: auto; text-align: center; max-width: 460px; }
.empty-state h1 { font-size: 28px; letter-spacing: -.03em; margin: 0 0 10px; font-weight: 600; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }
.examples { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.msg { max-width: 100%; }
.msg .who { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-40); margin-bottom: 5px; }
.msg .body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 11px 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user .body { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.msg.tool .body { font-family: var(--mono); font-size: 12px; color: var(--muted); background: transparent; border-style: dashed; }
.msg.error .body { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }

.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--panel); }
.composer textarea {
  flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 11px 13px; max-height: 180px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent); }
.send { height: 40px; padding: 0 18px; }

.tabs { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 5px 11px; border-radius: var(--radius-control); cursor: pointer; font-size: 13px; }
.tab:hover { color: var(--fg); }
.tab.active { background: var(--panel-2); color: var(--fg); border-color: var(--line-strong); }
.spacer { flex: 1; }

.tabpanes { flex: 1 1 auto; min-height: 0; position: relative; }
.pane { position: absolute; inset: 0; display: none; flex-direction: column; }
.pane.active { display: flex; }
#previewFrame { flex: 1; border: 0; background: #fff; width: 100%; }
.files { flex: 0 0 42%; overflow-y: auto; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.files button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 5px 8px; border-radius: var(--radius-control); cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.files button:hover { background: var(--panel-2); color: var(--fg); }
.viewer { flex: 1; overflow: auto; margin: 0; padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--fg-80); }
.snapshots { overflow-y: auto; padding: 10px; }
.snapshots .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-card); margin-bottom: 7px; background: var(--panel-2); }
.snapshots .row .t { font-size: 13px; }
.snapshots .row .d { font-size: 11px; color: var(--fg-40); }
.info { overflow-y: auto; padding: 16px; font-size: 13px; line-height: 1.65; }
.info h3 { margin: 0 0 8px; font-size: 15px; }
.info code { font-family: var(--mono); font-size: 12px; background: var(--accent-soft); padding: 2px 6px; border-radius: 5px; color: var(--accent); }
.info table { border-collapse: collapse; width: 100%; }
.info td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.info td:first-child { color: var(--muted); width: 34%; }
.muted { color: var(--muted); }

/* ── dialogs ──────────────────────────────────────────────────────── */

dialog {
  background: var(--panel); color: var(--fg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-card); padding: 0; box-shadow: var(--elevation-3);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 460px; }
dialog h3 { margin: 0; font-size: 17px; font-weight: 600; }
dialog h4 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
dialog input, dialog textarea, dialog select {
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  padding: 9px 11px; color: var(--fg); outline: none;
}
dialog input:focus, dialog textarea:focus, dialog select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 4px 0 0; padding: 0; }
dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .hint { font-size: 12px; color: var(--fg-40); margin: 0; }
dialog .src { font-family: var(--mono); font-size: 11px; color: var(--fg-40); }
dialog .kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; font-size: 12.5px; }
dialog .kv dt { color: var(--muted); }
dialog .kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* ── the design catalogue (a tab: it never blocks the studio) ────────── */

.styles-pane { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px 28px; }
.style-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.style-head h3 { margin: 0; font-size: 16px; }
.style-head .hint { color: var(--fg-40); font-size: 12.5px; margin: 0; max-width: 74ch; }
.style-controls { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.style-controls input {
  flex: 1 1 200px; background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-control); padding: 9px 11px; color: var(--fg); outline: none;
}
.style-controls input:focus { border-color: var(--accent); }
.style-select { display: flex; flex-direction: column; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.style-select select {
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  padding: 9px 11px; color: var(--fg); outline: none; min-width: 230px;
}
.style-select select:focus { border-color: var(--accent); }
.families { display: flex; gap: 6px; flex-wrap: wrap; }
.families .chip.on, .types .chip.on {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600;
}
.style-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; align-content: start;
}
.style-card {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, transform .15s;
}
.style-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.style-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.style-card .style-name { font-weight: 600; font-size: 13.5px; }
.style-card .style-note { font-size: 11.5px; color: var(--fg-40); line-height: 1.4; }
.mini { display: grid; gap: 4px; padding: 8px; border: 1px solid; min-height: 56px; }
.mini-bar { height: 6px; border-radius: 3px; }
.mini-line { height: 4px; border-radius: 2px; width: 70%; }
.mini-line.short { width: 40%; }
.mini-pill { height: 10px; width: 34px; border-radius: 999px; }
.style-types { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.style-types h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.types { display: flex; gap: 6px; flex-wrap: wrap; }
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.composer-head { display: flex; gap: 6px; flex: 0 0 100%; }
.chip.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }

/* ── the studio holds the same bar it asks of generated apps ───────── */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (pointer: coarse) {
  .btn, .chip.clickable, .icon { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr 1fr; }
  .side { display: none; }
}
