:root {
  color-scheme: light;
  --bg: #f2f5f7;
  --panel: #ffffff;
  --panel-2: #eaf1f3;
  --ink: #142028;
  --muted: #647581;
  --line: #d5e0e5;
  --accent: #0c8b84;
  --accent-2: #e4b34a;
  --accent-3: #345d79;
  --danger: #b42318;
  --success: #087443;
  --shadow: 0 18px 50px rgba(26, 42, 52, .12);
}

:root.dark {
  color-scheme: dark;
  --bg: #0d1418;
  --panel: #141f25;
  --panel-2: #1b2a31;
  --ink: #edf6f8;
  --muted: #a7b8c0;
  --line: #2c424b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(12,139,132,.14), transparent 24%),
    radial-gradient(circle at 82% 8%, rgba(228,179,74,.16), transparent 22%);
  animation: atmosphere 9s ease-in-out infinite alternate;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
  min-height: 74px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(16px);
}
.brand, .header-nav, .header-actions, .hero-actions, .panel-title, .action-row, .output-panel, .footer { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  font-weight: 900;
}
.brand small { display: block; color: var(--muted); font-size: 12px; }
.header-nav { justify-content: center; gap: 22px; }
.header-nav a { color: var(--muted); font-weight: 800; font-size: 14px; }
.header-actions { justify-content: flex-end; gap: 10px; }

.button, .icon-button, .text-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
}
.button.primary { color: #fff; background: var(--accent); }
.button.secondary, .icon-button { color: var(--ink); background: var(--panel-2); }
.button.quiet { color: var(--ink); background: var(--panel); border: 1px solid var(--line); }
.icon-button { width: 42px; height: 42px; }
.text-button { color: var(--accent); background: transparent; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 640px);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 74px);
  padding: 54px 6vw 86px;
}
.hero h1 {
  margin: 0;
  max-width: 820px;
  font-size: clamp(46px, 7vw, 90px);
  line-height: .92;
}
.hero p {
  max-width: 760px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.7;
}
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
.hero-actions { gap: 12px; flex-wrap: wrap; }
.hero-product {
  min-height: 520px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(140deg, rgba(12,139,132,.14), rgba(228,179,74,.18)), var(--panel);
  box-shadow: var(--shadow);
  animation: floatPanel 5s ease-in-out infinite;
}
.mini-window {
  position: relative;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.mini-window > span {
  position: absolute;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
}
.mini-window > span:nth-child(1) { left: 18px; background: #ef6b5f; }
.mini-window > span:nth-child(2) { left: 34px; background: #e4b34a; }
.mini-window > span:nth-child(3) { left: 50px; background: #2fa876; }
.mini-toolbar {
  height: 54px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.mini-page {
  position: absolute;
  left: 46px;
  top: 92px;
  width: 54%;
  height: 72%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(var(--panel-2) 0 0) 32px 54px / 70% 10px no-repeat,
    linear-gradient(var(--panel-2) 0 0) 32px 84px / 58% 10px no-repeat,
    linear-gradient(120deg, transparent 45%, rgba(12,139,132,.25) 45% 55%, transparent 55%) var(--panel);
}
.mini-side {
  position: absolute;
  right: 28px;
  top: 92px;
  width: 30%;
  height: 72%;
  border-radius: 8px;
  background:
    linear-gradient(var(--accent) 0 0) 18px 22px / 68% 12px no-repeat,
    linear-gradient(var(--line) 0 0) 18px 64px / 78% 10px no-repeat,
    linear-gradient(var(--line) 0 0) 18px 96px / 60% 10px no-repeat,
    var(--panel-2);
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 22px;
  padding: 30px 32px 72px;
}
.tool-rail, .workbench, .editor-shell, .catalog-grid article, .architecture, .engine-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.tool-rail {
  position: sticky;
  top: 94px;
  align-self: start;
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  padding: 14px;
}
.rail-head { display: flex; justify-content: space-between; padding: 10px 6px 12px; }
.rail-head small, .tool-item small { color: var(--muted); }
.tool-search {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
}
.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0;
}
.category-tabs button, .catalog-grid button, .catalog-grid a {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  display: inline-flex;
}
.category-tabs button.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.rail-list { overflow: auto; padding-right: 4px; }
.tool-item {
  display: grid;
  gap: 3px;
  width: 100%;
  margin-bottom: 6px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.tool-item:hover { transform: translateX(4px); }
.tool-item span { font-weight: 900; }
.tool-item.active {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}

.workbench { padding: 24px; }
.workbench-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.workbench h2, .section-head h2, .architecture h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
}
.workbench-head p:not(.eyebrow), .section-head p, .architecture p { color: var(--muted); line-height: 1.65; }
.status-card {
  align-self: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}
.status-card.server { color: var(--accent-3); }
.status-card.module { color: #986500; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 230px;
  padding: 24px;
  border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 8px;
  text-align: center;
  background: var(--panel-2);
  cursor: pointer;
}
.dropzone input { display: none; }
.dropzone.is-dragging { outline: 4px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.drop-visual {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 38px;
  font-weight: 800;
}
.dropzone span, .empty { color: var(--muted); }

.queue-panel, .settings-grid, .output-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.panel-title { justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.file-list { padding: 6px; }
.file-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  animation: slideIn .22s ease both;
}
.file-row + .file-row { border-top: 1px solid var(--line); }
.file-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { color: var(--muted); }
.file-row button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
}
.thumb {
  display: grid;
  place-items: center;
  width: 52px;
  height: 66px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(var(--panel-2) 0 0) 10px 16px / 60% 5px no-repeat,
    linear-gradient(var(--panel-2) 0 0) 10px 28px / 72% 5px no-repeat,
    var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.empty { margin: 0; padding: 18px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}
.setting span, .editor-properties span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.setting input, .setting select, .setting textarea, .editor-properties input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
}
.setting textarea { min-height: 88px; padding-top: 10px; resize: vertical; }
.setting[hidden] { display: none; }
.action-row { gap: 14px; margin-top: 18px; }
.progress { flex: 1; color: var(--muted); font-size: 14px; }
.progress div { height: 10px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: var(--panel-2); }
.progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s ease; }
.output-panel { justify-content: space-between; gap: 18px; padding: 16px; border-left: 5px solid var(--success); }
.output-panel p { margin: 5px 0 0; color: var(--muted); }
.quest-strip {
  position: relative;
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 14px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, transparent), color-mix(in srgb, var(--accent-2) 16%, transparent)),
    var(--panel);
}
.quest-strip span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.quest-strip strong { position: relative; z-index: 1; }
.quest-strip i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s ease;
}

.editor-panel, .catalog, .architecture, .product-suite { margin: 0 32px 72px; }
.section-head { max-width: 850px; margin-bottom: 22px; }
.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  overflow: hidden;
}
.editor-toolbar {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.editor-toolbar button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  font-weight: 850;
}
.editor-toolbar button.active, .editor-toolbar #apply-edits { color: #fff; border-color: var(--accent); background: var(--accent); }
.editor-stage {
  position: relative;
  min-height: 620px;
  display: grid;
  place-items: start center;
  padding: 24px;
  overflow: auto;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25% 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%) 0 0 / 24px 24px,
    var(--panel-2);
}
#pdf-canvas, #overlay-canvas {
  grid-area: 1 / 1;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .14);
}
#overlay-canvas { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); background: transparent; cursor: crosshair; }
#editor-empty {
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  padding: 18px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
}
.editor-properties {
  padding: 18px;
  border-left: 1px solid var(--line);
}
.editor-properties label { display: block; margin-bottom: 14px; }
.editor-properties p { color: var(--muted); line-height: 1.6; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.catalog-grid article { min-height: 190px; padding: 18px; box-shadow: none; }
.catalog-grid article { transition: transform .2s ease, box-shadow .2s ease; }
.catalog-grid article:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
}
.catalog-grid span { color: var(--accent); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.catalog-grid h3 { margin: 10px 0; }
.catalog-grid p { color: var(--muted); line-height: 1.55; }

.architecture {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 24px;
  padding: 28px;
}
.engine-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.engine-grid article { min-height: 120px; padding: 18px; box-shadow: none; }
.engine-grid strong { display: block; margin-bottom: 8px; }
.engine-grid span { color: var(--muted); }
.product-suite {
  scroll-margin-top: 96px;
}
.suite-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.suite-card, .admin-board article, .blog-grid article {
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.suite-card span, .admin-board span, .blog-grid span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.suite-card strong, .admin-board strong {
  display: block;
  margin: 10px 0;
  font-size: 34px;
  line-height: 1;
}
.suite-card p, .blog-grid p, .admin-board small, .api-panel p {
  color: var(--muted);
  line-height: 1.6;
}
.suite-card ul {
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}
.suite-card li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.suite-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}
.suite-card code {
  display: block;
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-2);
}
.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}
.meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.admin-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.admin-table {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.admin-table div {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.admin-table div:first-child {
  color: var(--muted);
  background: var(--panel-2);
  font-size: 13px;
  text-transform: uppercase;
}
.admin-table button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
  font-weight: 800;
}
.api-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.api-panel pre {
  margin: 0;
  padding: 20px;
  overflow: auto;
  border-radius: 8px;
  color: #dff7ef;
  background: #111c22;
}
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.blog-grid h3 {
  margin: 12px 0;
  font-size: 24px;
  line-height: 1.1;
}
.footer {
  justify-content: space-between;
  gap: 20px;
  padding: 28px 32px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 48px));
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: toastIn .22s ease both;
  font-weight: 850;
}
.confetti {
  position: fixed;
  inset: 0;
  z-index: 39;
  pointer-events: none;
}
.confetti span {
  position: absolute;
  left: 50%;
  top: 22%;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: hsl(calc(var(--i) * 31), 75%, 56%);
  transform: rotate(calc(var(--i) * 18deg));
  animation: pop 1.2s ease-out forwards;
  animation-delay: calc(var(--i) * 18ms);
}

@keyframes atmosphere {
  from { transform: translateY(0); opacity: .8; }
  to { transform: translateY(18px); opacity: 1; }
}
@keyframes floatPanel {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  to {
    opacity: 0;
    transform: translate(calc((var(--i) - 9) * 28px), calc(220px + (var(--i) % 5) * 28px)) rotate(420deg);
  }
}

@media (max-width: 1160px) {
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .suite-grid, .admin-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr auto; }
  .header-nav { display: none; }
  .hero, .workspace, .architecture, .editor-shell, .api-panel { grid-template-columns: 1fr; }
  .tool-rail { position: static; max-height: none; }
  .editor-properties { border-left: 0; border-top: 1px solid var(--line); }
  .catalog-grid, .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .app-header, .workspace { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 36px 16px 56px; }
  .hero h1 { font-size: 42px; }
  .hero-product { min-height: 340px; }
  .workbench-head, .action-row, .output-panel, .footer { flex-direction: column; align-items: stretch; }
  .settings-grid, .catalog-grid, .engine-grid, .suite-grid, .admin-board, .blog-grid { grid-template-columns: 1fr; }
  .editor-panel, .catalog, .architecture, .product-suite { margin-left: 16px; margin-right: 16px; }
  .admin-table div { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 58px minmax(0, 1fr); }
  .file-row button, .file-row small { grid-column: 2; }
}
