:root {
  --bg: #080c10;
  --bg-2: #0b1117;
  --panel: #101820;
  --panel-2: #141f29;
  --border: #22313d;
  --border-strong: #304657;
  --text: #e7f0f7;
  --muted: #93a7b8;
  --faint: #71879a;
  --accent: #6ef3c5;
  --accent-deep: #3fd6a7;
  --accent-soft: rgba(110, 243, 197, 0.11);
  --orange: #ffb86b;
  --red: #ff6b81;
  --blue: #6cb6ff;
  --purple: #b99cff;
  --radius: 18px;
  --radius-sm: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 720px at 12% -10%, rgba(110, 243, 197, 0.075), transparent 62%),
    radial-gradient(980px 680px at 102% -4%, rgba(108, 182, 255, 0.06), transparent 58%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.3;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.023) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.023) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

::selection {
  background: var(--accent);
  color: #04120c;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  line-height: 1.15;
  letter-spacing: -0.02em;
}

code,
pre,
kbd {
  font-family: var(--mono);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #04120c;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Chrome ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 16, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-inner {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--accent);
  background:
    radial-gradient(circle at 25% 15%, rgba(110, 243, 197, 0.22), transparent 70%),
    linear-gradient(150deg, rgba(110, 243, 197, 0.12), rgba(108, 182, 255, 0.04));
  border: 1px solid rgba(110, 243, 197, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.25);
}

.brand-icon {
  width: 27px;
  height: 27px;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  font-size: 1.04rem;
  letter-spacing: -0.025em;
}

.brand p {
  margin-top: 1px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.connectivity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.64rem;
  white-space: nowrap;
}

.connectivity .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(110, 243, 197, 0.8);
}

.connectivity.is-offline {
  color: var(--orange);
  border-color: rgba(255, 184, 107, 0.3);
}

.connectivity.is-offline .dot {
  background: var(--orange);
  box-shadow: 0 0 9px rgba(255, 184, 107, 0.7);
}

.app-main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 30px 24px 44px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 28px;
}

.intro-copy {
  max-width: 780px;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.intro h2 {
  max-width: 760px;
  margin: 8px 0 10px;
  font-size: clamp(1.65rem, 3.2vw, 2.55rem);
  letter-spacing: -0.045em;
}

.intro p {
  max-width: 720px;
  color: var(--muted);
  font-size: 0.94rem;
}

.intro p code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.88em;
}

.intro-stats {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.intro-stats div {
  text-align: right;
}

.intro-stats strong {
  display: block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.intro-stats span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 24px;
  align-items: start;
}

.builder {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.preview-column {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---------- Cards ---------- */

.card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 31, 41, 0.93), rgba(13, 19, 26, 0.93));
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.17);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  pointer-events: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.step {
  width: 33px;
  height: 33px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(110, 243, 197, 0.2);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.card-head h3 {
  font-size: 1rem;
}

.card-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.81rem;
}

.hint {
  color: var(--faint);
  font-size: 0.73rem;
  line-height: 1.45;
}

.hint code {
  color: var(--muted);
}

/* ---------- Mode tabs ---------- */

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.028);
}

.mode-tabs label {
  position: relative;
  min-width: 0;
}

.mode-tabs input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.mode-tabs span {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.mode-tabs input:checked + span {
  color: var(--text);
  background: linear-gradient(180deg, rgba(110, 243, 197, 0.15), rgba(110, 243, 197, 0.055));
  box-shadow: inset 0 0 0 1px rgba(110, 243, 197, 0.26);
}

.mode-tabs input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-tabs span:hover {
  color: var(--text);
}

/* ---------- Partition options ---------- */

.partition-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.partition-option {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.partition-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.partition-option > span {
  display: flex;
  min-height: 74px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.022);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.partition-option:hover > span {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.partition-option input:checked + span {
  border-color: rgba(110, 243, 197, 0.52);
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--partition-color) 18%, transparent), transparent 70%),
    rgba(110, 243, 197, 0.04);
  box-shadow: inset 0 0 0 1px rgba(110, 243, 197, 0.08), 0 8px 24px rgba(0, 0, 0, 0.16);
}

.partition-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.partition-option[data-partition="gpu"] { --partition-color: var(--orange); }
.partition-option[data-partition="cpu"] { --partition-color: var(--blue); }
.partition-option[data-partition="stud"] { --partition-color: var(--accent); }
.partition-option[data-partition="lmd"] { --partition-color: var(--purple); }

.partition-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.partition-dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--partition-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--partition-color) 55%, transparent);
}

.partition-option strong {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.partition-option small {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.63rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Node chips ---------- */

.node-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.node-chip {
  position: relative;
}

.node-chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.node-chip > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.022);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.node-chip:hover > span {
  color: var(--text);
  border-color: var(--border-strong);
}

.node-chip input:checked + span {
  color: var(--text);
  border-color: rgba(110, 243, 197, 0.5);
  background: rgba(110, 243, 197, 0.1);
  box-shadow: inset 0 0 0 1px rgba(110, 243, 197, 0.08);
}

.node-chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.node-chip input:disabled + span {
  opacity: 0.34;
  cursor: not-allowed;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.gpu-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 7px rgba(255, 184, 107, 0.7);
}

/* ---------- Node summary ---------- */

.node-summary {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.node-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.node-summary-head h4 {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.node-summary-head .sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.node-summary-head .sub code {
  color: var(--text);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chip--accent {
  color: var(--accent);
  border-color: rgba(110, 243, 197, 0.26);
  background: rgba(110, 243, 197, 0.07);
}

.chip--gpu {
  color: var(--orange);
  border-color: rgba(255, 184, 107, 0.28);
  background: rgba(255, 184, 107, 0.07);
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.spec {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.028);
}

.spec-label {
  display: block;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spec strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eligible-text {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.72rem;
}

.eligible-text .dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.eligible-text.is-warn .dot {
  background: var(--orange);
}

.eligible-text.is-error .dot {
  background: var(--red);
}

.eligible-text strong {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

/* ---------- Resources ---------- */

.resource-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.resource {
  min-width: 0;
}

.resource-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.resource-head label {
  font-size: 0.87rem;
  font-weight: 600;
}

.number-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.23);
}

.number-wrap:focus-within {
  border-color: rgba(110, 243, 197, 0.5);
  box-shadow: 0 0 0 3px rgba(110, 243, 197, 0.09);
}

.number-wrap input {
  width: 64px;
  padding: 4px 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.86rem;
  text-align: right;
}

.number-wrap span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.64rem;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  margin: 0;
  border-radius: 999px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 0%), rgba(255, 255, 255, 0.075) var(--fill, 0%) 100%);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid var(--bg-2);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(110, 243, 197, 0.45), 0 2px 10px rgba(0, 0, 0, 0.42);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid var(--bg-2);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(110, 243, 197, 0.45), 0 2px 10px rgba(0, 0, 0, 0.42);
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.resource-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.71rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: #b8ffe8;
}

.link-btn:disabled {
  color: var(--faint);
  cursor: not-allowed;
  text-decoration: none;
}

/* ---------- Segmented GPU ---------- */

.segmented {
  display: grid;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.segmented--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 9px 8px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.segmented input:checked + span {
  color: var(--text);
  background: linear-gradient(180deg, rgba(110, 243, 197, 0.14), rgba(110, 243, 197, 0.05));
  box-shadow: inset 0 0 0 1px rgba(110, 243, 197, 0.24);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented span:hover {
  color: var(--text);
}

.segmented input:disabled + span {
  opacity: 0.3;
  cursor: not-allowed;
}

.gpu-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 15px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.stepper {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
}

.stepper input {
  width: 44px;
  padding: 7px 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
}

.stepper input:focus {
  border-color: rgba(110, 243, 197, 0.5);
  box-shadow: 0 0 0 3px rgba(110, 243, 197, 0.09);
}

.stepper-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.stepper-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
}

.stepper-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#gpu-count-unit {
  margin-left: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  white-space: nowrap;
}

.gpu-note {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: right;
}

.gpu-note strong {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

/* ---------- Settings ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field--full {
  grid-column: 1 / -1;
}

.field > label {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field textarea:focus,
textarea:focus {
  border-color: rgba(110, 243, 197, 0.5);
  box-shadow: 0 0 0 3px rgba(110, 243, 197, 0.09);
}

.field input::placeholder,
textarea::placeholder {
  color: #506475;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 1px;
}

.preset {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.preset:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
}

.preset:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

input:disabled,
textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.advanced {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.advanced summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary::before {
  content: "+";
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--faint);
  font-size: 0.74rem;
  line-height: 1;
}

.advanced[open] summary::before {
  content: "−";
}

.advanced-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
}

.script-editor {
  min-height: 196px;
  resize: vertical;
  line-height: 1.65;
  tab-size: 2;
}

.script-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 9px;
}

.script-foot .link-btn {
  flex-shrink: 0;
}

/* ---------- Preview ---------- */

.preview {
  padding: 0;
}

.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 20px 14px;
}

.preview-head h2 {
  margin-top: 3px;
  font-size: 1.13rem;
  letter-spacing: -0.03em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.61rem;
  white-space: nowrap;
}

.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status-badge.is-ready {
  color: var(--accent);
  border-color: rgba(110, 243, 197, 0.28);
  background: rgba(110, 243, 197, 0.07);
}

.status-badge.is-ready .dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(110, 243, 197, 0.8);
}

.status-badge.is-warn {
  color: var(--orange);
  border-color: rgba(255, 184, 107, 0.28);
  background: rgba(255, 184, 107, 0.07);
}

.status-badge.is-warn .dot {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(255, 184, 107, 0.7);
}

.status-badge.is-error {
  color: var(--red);
  border-color: rgba(255, 107, 129, 0.28);
  background: rgba(255, 107, 129, 0.07);
}

.status-badge.is-error .dot {
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 107, 129, 0.7);
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 20px 15px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  white-space: nowrap;
}

.pill strong {
  color: var(--text);
  font-weight: 600;
}

.pill--accent {
  border-color: rgba(110, 243, 197, 0.24);
  background: rgba(110, 243, 197, 0.06);
}

.pill--accent strong {
  color: var(--accent);
}

.terminal {
  margin: 0 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #070b0f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 14px 34px rgba(0, 0, 0, 0.24);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.terminal-dots {
  display: flex;
  gap: 5px;
}

.terminal-dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.terminal-dots i:nth-child(1) { background: #ff6b81; }
.terminal-dots i:nth-child(2) { background: #ffb86b; }
.terminal-dots i:nth-child(3) { background: #6ef3c5; }

.terminal-title {
  min-width: 0;
  margin-left: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.terminal-bar .icon-btn {
  margin-left: auto;
}

.terminal pre {
  max-height: 520px;
  margin: 0;
  padding: 17px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.terminal code {
  color: #d7e7f2;
  font-family: var(--mono);
  font-size: 0.79rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tok-comment { color: #5f7487; }
.tok-directive { color: var(--blue); }
.tok-flag { color: var(--accent); }
.tok-value { color: var(--orange); }

.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 13px 20px 0;
  padding: 11px 13px;
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  background: rgba(110, 243, 197, 0.025);
}

.submit-copy {
  min-width: 0;
}

.submit-copy .eyebrow {
  display: block;
  margin-bottom: 2px;
  font-size: 0.57rem;
}

.submit-copy code {
  display: block;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.77rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.validation {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 15px 20px 0;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 0.73rem;
  line-height: 1.45;
}

.msg .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.msg--error {
  color: #ffc3cb;
  border-color: rgba(255, 107, 129, 0.24);
  background: rgba(255, 107, 129, 0.07);
}

.msg--warn {
  color: #ffd8aa;
  border-color: rgba(255, 184, 107, 0.24);
  background: rgba(255, 184, 107, 0.07);
}

.msg--info {
  color: #badbff;
  border-color: rgba(108, 182, 255, 0.22);
  background: rgba(108, 182, 255, 0.06);
}

.msg--ok {
  color: var(--accent);
  border-color: rgba(110, 243, 197, 0.22);
  background: rgba(110, 243, 197, 0.06);
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 15px 20px 0;
}

.copy-hint {
  padding: 10px 20px 18px;
  color: var(--faint);
  font-size: 0.69rem;
  line-height: 1.4;
}

.copy-hint.is-warn { color: var(--orange); }
.copy-hint.is-error { color: var(--red); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 0.77rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn .icon {
  width: 14px;
  height: 14px;
}

.btn--primary {
  border-color: rgba(110, 243, 197, 0.5);
  background: linear-gradient(135deg, var(--accent), #4bd6ad);
  color: #04120c;
  box-shadow: 0 8px 22px rgba(110, 243, 197, 0.16);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn--secondary {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.075);
}

.btn--ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.btn--sm {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.71rem;
}

.btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn--icon .icon {
  width: 15px;
  height: 15px;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Reference ---------- */

.reference {
  padding: 0;
}

.reference summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.reference summary::-webkit-details-marker {
  display: none;
}

.reference summary::after {
  content: "+";
  color: var(--faint);
  font-size: 0.9rem;
}

.reference[open] summary::after {
  content: "−";
}

.summary-meta {
  margin-left: auto;
  color: var(--faint);
  font-size: 0.61rem;
  white-space: nowrap;
}

.reference-body {
  padding: 0 20px 20px;
}

.reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 11px;
}

.table-wrap,
.map-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

#node-table {
  min-width: 650px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: rgba(255, 255, 255, 0.022);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.57rem;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: var(--muted);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

td:first-child {
  color: var(--text);
  font-family: var(--mono);
}

.mark {
  text-align: center;
}

.mark .icon {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.dash {
  color: #435563;
}

.reference-body > .hint {
  margin-top: 10px;
}

/* ---------- Dialog ---------- */

.dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 56px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 19px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog::backdrop {
  background: rgba(3, 6, 9, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  font-size: 1.08rem;
}

.dialog-head p {
  max-width: 620px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.dialog-body {
  flex: 1;
  min-height: 0;
  padding: 20px 22px;
  overflow: auto;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 15px 22px;
  border-top: 1px solid var(--border);
}

.dialog-actions-right {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.map-table {
  min-width: 540px;
}

.map-table th,
.map-table td {
  text-align: center;
}

.map-table th:first-child,
.map-table td:first-child {
  text-align: left;
}

.map-table td:first-child {
  color: var(--text);
  font-size: 0.76rem;
}

.map-table td {
  padding: 10px 9px;
}

.map-check {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.map-check:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-node-head {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.map-node-head .gpu-dot {
  width: 4px;
  height: 4px;
}

.dialog-body > .hint {
  margin-top: 10px;
}

/* ---------- Footer and toast ---------- */

.app-footer {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px 24px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 0.68rem;
}

.app-footer code {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 200;
  max-width: min(90vw, 480px);
  padding: 11px 17px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #111b24;
  color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.48);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-success {
  border-color: rgba(110, 243, 197, 0.4);
  color: #d9fff4;
}

.toast.is-error {
  border-color: rgba(255, 107, 129, 0.42);
  color: #ffd9de;
}

.toast.is-info {
  border-color: rgba(108, 182, 255, 0.38);
  color: #d6eaff;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .card {
    animation: rise 0.42s ease both;
  }

  .builder .card:nth-child(2) { animation-delay: 0.04s; }
  .builder .card:nth-child(3) { animation-delay: 0.08s; }
  .builder .card:nth-child(4) { animation-delay: 0.12s; }
  .builder .card:nth-child(5) { animation-delay: 0.16s; }
  .builder .card:nth-child(6) { animation-delay: 0.2s; }
  .builder .card:nth-child(7) { animation-delay: 0.24s; }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(7px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-column {
    position: static;
  }

  .intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .intro-stats {
    align-self: stretch;
    justify-content: space-between;
    padding-top: 2px;
  }

  .intro-stats div {
    text-align: left;
  }

  .preview {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .header-inner,
  .app-main,
  .app-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-main {
    padding-top: 22px;
  }

  .connectivity span#connectivity-text {
    display: none;
  }

  .connectivity {
    padding: 6px;
  }

  .partition-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resource-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .spec-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gpu-detail {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .gpu-note {
    text-align: left;
  }

  .preview-head {
    padding: 18px 16px 12px;
  }

  .summary-pills {
    padding: 0 16px 13px;
  }

  .terminal {
    margin: 0 16px;
  }

  .submit-row,
  .validation {
    margin-left: 16px;
    margin-right: 16px;
  }

  .preview-actions {
    padding: 14px 16px 0;
  }

  .copy-hint {
    padding: 10px 16px 17px;
  }

  .reference summary {
    padding: 14px 16px;
  }

  .reference-body {
    padding: 0 16px 16px;
  }

  .summary-meta {
    display: none;
  }

  .card {
    padding: 18px;
  }

  .intro h2 {
    font-size: clamp(1.55rem, 7vw, 2.15rem);
  }

  .app-footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 520px) {
  .brand p {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  #install-btn .btn-label {
    display: none;
  }

  #install-btn {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .mode-tabs span {
    padding: 9px 8px;
    font-size: 0.77rem;
  }

  .segmented span {
    font-size: 0.72rem;
  }

  .preview-actions .btn {
    flex: 1 1 auto;
  }

  .submit-row {
    align-items: flex-start;
  }

  .script-foot {
    flex-direction: column;
  }

  .intro-stats {
    gap: 12px;
  }

  .intro-stats strong {
    font-size: 1.05rem;
  }

  .intro-stats span {
    font-size: 0.55rem;
  }

  .dialog-head,
  .dialog-body,
  .dialog-actions {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .app-header,
  .builder,
  .preview-actions,
  .copy-hint,
  .reference,
  .app-footer,
  .toast {
    display: none !important;
  }

  body {
    background: #fff;
    color: #111;
  }

  .app-main {
    padding: 0;
  }

  .layout {
    display: block;
  }

  .preview {
    border: 0;
    box-shadow: none;
  }

  .terminal {
    border: 1px solid #bbb;
    background: #fff;
  }

  .terminal code {
    color: #111;
  }
}
