:root {
  color-scheme: dark;
  --ink: #07090d;
  --surface: #0d1118;
  --surface-2: #121824;
  --surface-3: #171e2b;
  --line: rgba(225, 190, 112, .18);
  --line-strong: rgba(225, 190, 112, .42);
  --gold: #d7b267;
  --gold-light: #f4dc9e;
  --gold-deep: #8d6731;
  --text: #f4efe4;
  --muted: #999d9f;
  --green: #62c694;
  --red: #e87976;
  --amber: #e2aa57;
  --blue: #72a9d4;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at 78% -15%, rgba(141, 103, 49, .26), transparent 38rem),
    radial-gradient(circle at -5% 38%, rgba(55, 81, 107, .18), transparent 36rem),
    linear-gradient(145deg, #080a0f 0%, #0a0d13 55%, #07090d 100%);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.royal-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .17;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.topbar {
  height: 78px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, .88);
  backdrop-filter: blur(18px);
}

.brand, .top-actions { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--gold-light);
  font-size: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  box-shadow: inset 0 0 22px rgba(215, 178, 103, .12), 0 0 24px rgba(215, 178, 103, .08);
}
.brand b { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 18px; color: var(--gold-light); }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.health-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(226, 170, 87, .3);
  border-radius: 999px;
  color: var(--amber);
  background: rgba(226, 170, 87, .07);
  font-size: 12px;
}
.health-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 12px currentColor; }
.health-pill.ready { color: var(--green); border-color: rgba(98, 198, 148, .3); background: rgba(98, 198, 148, .07); }
.health-pill.error { color: var(--red); border-color: rgba(232, 121, 118, .3); background: rgba(232, 121, 118, .07); }

.ghost, .primary, .secondary {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .18s ease;
}
.ghost { color: var(--gold-light); background: rgba(215, 178, 103, .05); }
.ghost:hover { background: rgba(215, 178, 103, .12); transform: translateY(-1px); }
.compact { min-height: 36px; padding-inline: 13px; font-size: 12px; }
.primary {
  color: #171107;
  font-weight: 800;
  border-color: #e6c67e;
  background: linear-gradient(145deg, #f0d897, #bd8d40);
  box-shadow: 0 8px 24px rgba(189, 141, 64, .15);
}
.primary:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.07); box-shadow: 0 10px 30px rgba(189, 141, 64, .24); }
.secondary { color: var(--gold-light); background: linear-gradient(145deg, rgba(215, 178, 103, .12), rgba(215, 178, 103, .04)); }
.secondary:hover:not(:disabled) { background: rgba(215, 178, 103, .16); transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .35; transform: none !important; }
.full { width: 100%; }

main { width: min(1540px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 64px; }
.hero {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(28px, 5vw, 58px);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(11, 15, 22, .95), rgba(11, 15, 22, .65)),
    radial-gradient(circle at 84% 30%, rgba(215, 178, 103, .2), transparent 32%);
  box-shadow: inset 0 0 60px rgba(215, 178, 103, .05), 0 24px 80px rgba(0, 0, 0, .28);
}
.hero::after {
  content: "✦";
  position: absolute;
  inset-inline-end: 21%;
  top: -75px;
  color: rgba(215, 178, 103, .055);
  font-size: 280px;
  transform: rotate(12deg);
}
.hero > div:first-child { position: relative; z-index: 1; max-width: 880px; }
.eyebrow { display: block; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.hero h1 { max-width: 900px; margin: 13px 0 15px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 4vw, 54px); line-height: 1.18; font-weight: 500; color: #fff8e8; }
.hero p { max-width: 820px; margin: 0; color: #b9b9b4; line-height: 1.9; font-size: 15px; }
.hero-seal {
  position: relative;
  z-index: 2;
  flex: 0 0 230px;
  min-height: 146px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 178, 103, .13), rgba(7, 9, 13, .76) 70%);
  box-shadow: inset 0 0 0 6px rgba(215, 178, 103, .03), inset 0 0 0 7px rgba(215, 178, 103, .13);
}
.hero-seal span, .hero-seal small { color: var(--muted); font-size: 11px; }
.hero-seal strong { margin: 8px 0 5px; color: var(--gold-light); font-size: 20px; }

.truth-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.truth-grid article {
  min-height: 104px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 17, 24, .74);
}
.truth-grid span { color: var(--gold); font-size: 11px; font-weight: 700; }
.truth-grid strong { display: block; margin: 8px 0 3px; font-size: 22px; }
.truth-grid small { color: var(--muted); }

.pipeline {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 13, 19, .78);
}
.pipeline > em { flex: 1; height: 1px; margin: 0 15px; background: var(--line); }
.pipe-step { display: flex; align-items: center; gap: 10px; min-width: 160px; opacity: .48; transition: .2s; }
.pipe-step i {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold);
  font-style: normal;
  font-size: 12px;
}
.pipe-step b, .pipe-step small { display: block; }
.pipe-step b { font-size: 12px; }
.pipe-step small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.pipe-step.done, .pipe-step.active { opacity: 1; }
.pipe-step.done i { color: #07130c; border-color: var(--green); background: var(--green); }
.pipe-step.active i { color: #1a1206; border-color: var(--gold-light); background: var(--gold); box-shadow: 0 0 18px rgba(215, 178, 103, .2); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(340px, .75fr); align-items: start; gap: 18px; }
.side-column { display: grid; gap: 18px; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(17, 23, 33, .92), rgba(10, 14, 20, .94));
  box-shadow: 0 18px 54px rgba(0, 0, 0, .2);
}
.editor-panel, .stage-panel, .report-panel { padding: 24px; }
.panel-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.panel-head h2, .section-head h2 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 500; color: #fff4d9; }

.kind-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.kind-picker button {
  min-height: 100px;
  padding: 15px;
  text-align: start;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
  cursor: pointer;
  transition: .17s;
}
.kind-picker button:hover { border-color: var(--line-strong); background: rgba(215, 178, 103, .05); }
.kind-picker button.selected { border-color: var(--gold); background: linear-gradient(145deg, rgba(215, 178, 103, .16), rgba(215, 178, 103, .04)); box-shadow: inset 0 0 24px rgba(215, 178, 103, .04); }
.kind-picker i, .kind-picker b, .kind-picker small { display: block; }
.kind-picker i { margin-bottom: 9px; color: var(--gold); font-style: normal; font-size: 19px; }
.kind-picker b { font-size: 13px; }
.kind-picker small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: block; }
.form-grid .wide { grid-column: 1 / -1; }
label > span { display: block; margin-bottom: 7px; color: #d6d3ca; font-size: 12px; font-weight: 700; }
label > small { display: block; margin-top: 5px; color: #777e84; font-size: 10px; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  outline: none;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  background: rgba(5, 8, 12, .66);
  transition: .16s;
}
input, select { min-height: 44px; padding: 0 13px; }
textarea { min-height: 86px; padding: 12px 13px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215, 178, 103, .08); }
input::placeholder, textarea::placeholder { color: #565c62; }
.editor-actions { display: flex; gap: 10px; margin-top: 20px; }
.editor-actions button { min-width: 180px; }

.inheritance-card {
  display: flex;
  gap: 13px;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid rgba(114, 169, 212, .25);
  border-radius: 12px;
  background: rgba(114, 169, 212, .06);
}
.truth-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: none; color: var(--blue); border: 1px solid currentColor; border-radius: 50%; font-weight: 900; }
.inheritance-card b { font-size: 12px; }
.inheritance-card p { margin: 5px 0 4px; color: #cddbe7; font-size: 12px; }
.inheritance-card small { color: #8294a2; line-height: 1.6; }

.gate-list { display: grid; gap: 9px; }
.gate-list > div { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; padding: 12px; border: 1px solid rgba(255, 255, 255, .06); border-radius: 11px; background: rgba(255, 255, 255, .02); }
.gate-list i { width: 27px; height: 27px; display: grid; place-items: center; color: var(--muted); border: 1px solid rgba(255, 255, 255, .12); border-radius: 50%; font-size: 10px; font-style: normal; }
.gate-list b, .gate-list small { display: block; }
.gate-list b { font-size: 11px; }
.gate-list small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.gate-list em { color: var(--muted); font-size: 9px; font-style: normal; }
.gate-list > div.done { border-color: rgba(98, 198, 148, .24); background: rgba(98, 198, 148, .04); }
.gate-list > div.done i { color: #07130c; border-color: var(--green); background: var(--green); }
.gate-list > div.done em { color: var(--green); }
.gate-list > div.current { border-color: var(--line-strong); background: rgba(215, 178, 103, .06); }
.gate-list > div.current i { color: var(--gold-light); border-color: var(--gold); }
.gate-list > div.current em { color: var(--gold); }
.stage-actions { display: grid; gap: 9px; margin-top: 16px; }
.hard-truth { margin: 15px 0 0; padding-top: 13px; color: #8e8f8c; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 10px; line-height: 1.7; }

.empty-report { min-height: 155px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-report i { color: var(--gold); font-size: 24px; font-style: normal; }
.empty-report p { max-width: 280px; margin: 9px 0 0; line-height: 1.7; font-size: 11px; }
.report-summary { display: grid; gap: 10px; }
.report-summary > div { padding: 12px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 10px; background: rgba(255, 255, 255, .02); }
.report-summary b { display: block; margin-bottom: 5px; font-size: 11px; }
.report-summary p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.report-summary .ok { border-color: rgba(98, 198, 148, .25); }
.report-summary .ok b { color: var(--green); }
.report-summary .error { border-color: rgba(232, 121, 118, .25); }
.report-summary .error b { color: var(--red); }
.report-summary .warning { border-color: rgba(226, 170, 87, .2); }
.report-summary .warning b { color: var(--amber); }
.fingerprint { direction: ltr; overflow-wrap: anywhere; font-family: Consolas, monospace; color: #7e8f9c !important; }

.library-section { margin-top: 34px; }
.section-head { margin-bottom: 14px; }
.tabs { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6, 8, 12, .7); }
.tabs button { min-height: 32px; padding: 0 15px; color: var(--muted); border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.tabs button.active { color: #171107; font-weight: 800; background: var(--gold); }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.library-card { min-height: 210px; display: flex; flex-direction: column; padding: 19px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, rgba(16, 21, 30, .9), rgba(9, 12, 17, .92)); }
.library-card-head { display: flex; justify-content: space-between; gap: 10px; }
.library-card .kind { color: var(--gold); font-size: 10px; font-weight: 800; }
.library-card h3 { margin: 7px 0 3px; font-size: 17px; }
.library-card .ids { color: var(--muted); font-family: Consolas, monospace; font-size: 10px; direction: ltr; text-align: right; }
.status-badge { height: 25px; display: inline-flex; align-items: center; padding: 0 8px; color: var(--amber); border: 1px solid rgba(226, 170, 87, .25); border-radius: 999px; background: rgba(226, 170, 87, .06); font-size: 9px; white-space: nowrap; }
.status-badge.release_ready { color: var(--green); border-color: rgba(98, 198, 148, .28); background: rgba(98, 198, 148, .06); }
.status-badge.validated, .status-badge.backed_up { color: var(--blue); border-color: rgba(114, 169, 212, .28); background: rgba(114, 169, 212, .06); }
.card-truth { margin: 14px 0; color: #888e94; font-size: 10px; line-height: 1.65; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.card-actions button { min-height: 31px; padding: 0 10px; color: var(--gold-light); border: 1px solid var(--line); border-radius: 8px; background: rgba(215, 178, 103, .05); cursor: pointer; font-size: 10px; }
.card-actions button:hover { border-color: var(--gold); }
.card-actions button.danger { color: var(--red); border-color: rgba(232, 121, 118, .2); background: rgba(232, 121, 118, .04); }
.library-empty { grid-column: 1 / -1; min-height: 170px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
.release-files { margin: 12px 0; padding: 10px; color: var(--muted); border: 1px solid rgba(255, 255, 255, .06); border-radius: 9px; font-size: 9px; line-height: 1.7; direction: ltr; text-align: left; }

#toast {
  position: fixed;
  z-index: 50;
  inset-inline-start: 22px;
  bottom: 22px;
  max-width: min(410px, calc(100vw - 44px));
  padding: 13px 17px;
  color: #07130c;
  border-radius: 10px;
  background: var(--green);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: .2s;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { color: #230706; background: var(--red); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { overflow-x: auto; }
  .pipeline > em { min-width: 35px; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 68px; padding-block: 10px; }
  .brand small, .health-pill { display: none; }
  .ghost { padding-inline: 11px; font-size: 10px; }
  main { width: min(100% - 22px, 1540px); padding-top: 18px; }
  .hero { min-height: 0; display: block; padding: 25px 20px; }
  .hero h1 { font-size: 31px; }
  .hero-seal { width: 100%; min-height: 100px; margin-top: 22px; border-radius: 14px; }
  .truth-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline { padding: 12px; }
  .pipe-step { min-width: 130px; }
  .pipe-step small { display: none; }
  .side-column, .form-grid, .library-grid { grid-template-columns: 1fr; }
  .kind-picker { grid-template-columns: 1fr; }
  .kind-picker button { min-height: 78px; }
  .editor-actions { display: grid; }
  .editor-actions button { width: 100%; }
  .section-head { align-items: end; }
}
