:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-accent: #eef2ff;
  --surface: rgba(255, 255, 255, .88);
  --surface-solid: #ffffff;
  --surface-muted: #f8fafc;
  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --ready: #7c3aed;
  --ready-soft: #f5f3ff;
  --success: #059669;
  --success-hover: #047857;
  --success-text: #047857;
  --success-soft: #d1fae5;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 32px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

/* Compact file explorer and editor preview. Keep native keyboard/touch scrolling. */
#preview { margin-top: 22px; }
.file-preview { display: grid; grid-template-columns: minmax(140px, .8fr) minmax(0, 1.2fr); margin: 18px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-solid); }
#files, #content { min-width: 0; max-height: 360px; overflow: auto; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
#files:hover, #content:hover, #files:focus-within, #content:focus { scrollbar-color: var(--muted) transparent; }
#files::-webkit-scrollbar, #content::-webkit-scrollbar { width: 8px; height: 8px; }
#files::-webkit-scrollbar-track, #content::-webkit-scrollbar-track, #files::-webkit-scrollbar-corner, #content::-webkit-scrollbar-corner { background: transparent; }
#files::-webkit-scrollbar-thumb, #content::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 45%, transparent); border: 2px solid transparent; background-clip: padding-box; border-radius: 4px; }
#files::-webkit-scrollbar-thumb:hover, #content::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
#files { padding: 6px 0; border-right: 1px solid var(--border); background: var(--surface-muted); }
.file { display: block; width: 100%; border: 0; border-left: 2px solid transparent; background: transparent; color: var(--text); text-align: left; padding: 7px 10px; font: 12px ui-monospace, "Cascadia Code", monospace; overflow-wrap: anywhere; }
.file:hover { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.file[aria-pressed="true"] { border-left-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file:focus-visible, #content:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
#content { margin: 0; padding: 14px; font: 12px/1.6 ui-monospace, "Cascadia Code", monospace; tab-size: 4; }
#target { overflow-wrap: anywhere; font-weight: 650; }
#hint, #result { font-size: 13px; }
#result { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
#preview .button { margin-top: 16px; }
.inline-action { display: inline; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.inline-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 680px) {
  .file-preview { grid-template-columns: 1fr; }
  #files { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--border); }
}

html { min-width: 320px; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0, var(--bg-accent), transparent 32rem),
    linear-gradient(180deg, var(--bg), var(--surface-solid));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: translateY(0);
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease, backdrop-filter .2s ease;
}

/* Keyboard focus always keeps the header's navigation within view. */
.app-header.is-hidden:not(:focus-within) { transform: translateY(-100%); box-shadow: none; pointer-events: none; }

.header-inner {
  display: flex;
  width: min(1120px, calc(100% - 40px));
  min-height: 60px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-strong);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -.025em;
  text-decoration: none;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.header-actions, .github-link { display: flex; align-items: center; }
.header-actions { gap: 14px; }
.account { gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 4px rgba(148, 163, 184, .14); }
.account.is-connected .status-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(5, 150, 105, .13); }
.github-link { justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 8px; text-decoration: none; }
.github-link:hover { opacity: 0.8; }
.github-link:focus-visible, .app-footer a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.github-link img { display: block; width: 30px; height: 30px; object-fit: contain; }

.main-content { width: min(780px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 80px; }
.intro { margin-bottom: 34px; }
.eyebrow { margin: 0 0 9px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.intro h1 { margin: 0; color: var(--text-strong); font-size: clamp(31px, 5vw, 44px); font-weight: 750; letter-spacing: -.045em; line-height: 1.08; }
.intro > p:not(.eyebrow) { max-width: 680px; margin: 15px 0 0; color: var(--muted); font-size: 16px; }
.security-notes { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; color: var(--muted); font-size: 11px; font-weight: 650; }
.security-notes span::before { content: "✓"; margin-right: 6px; color: var(--success); }

.workflow, .package-flow { display: grid; gap: 22px; }
#package-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.workflow-card { min-width: 0; scroll-margin-top: 88px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(8px); }
.workflow-card.is-active { border-color: var(--ready); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ready) 8%, transparent), var(--shadow); }
.card-heading { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 23px 25px; border-bottom: 1px solid var(--border); }
.step-badge { display: grid; width: 31px; height: 31px; place-items: center; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-muted); font-size: 12px; font-weight: 800; }
.is-active .step-badge { color: white; border-color: var(--ready); background: #7c3aed; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading h2 { margin: 0; color: var(--text-strong); font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.card-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.step-state, .configured-pill, .app-state { flex: 0 0 auto; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.step-state, .app-state { color: var(--muted); background: var(--surface-muted); border-color: var(--border); }
.is-active .step-state { color: var(--ready); background: var(--ready-soft); border-color: var(--ready); }
.workflow-card.is-complete { border-color: var(--success); }
#connect-panel.is-complete .card-heading { border-bottom: 0; }
.workflow-card.is-complete .step-badge { color: white; border-color: var(--success); background: var(--success); }
.workflow-card.is-complete .step-state { color: var(--success-text); background: var(--success-soft); border-color: var(--success); }
.workflow-card.is-busy { border-color: var(--primary); }
.is-busy .step-state { color: var(--primary); background: var(--primary-soft); border-color: var(--primary); }
.workflow-card.has-error { border-color: var(--danger); }
.has-error .step-state { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.has-error .step-badge { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.card-body { padding: 24px 25px; }
.step-actions { margin-top: 20px; }
.permission-copy { color: var(--muted); font-size: 11px; }

.info-panel { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 20px; padding: 12px 14px; color: #3730a3; border: 1px solid #c7d2fe; border-radius: 9px; background: var(--primary-soft); font-size: 11px; }
.info-panel svg { flex: 0 0 auto; width: 17px; fill: currentColor; }
.info-panel p { margin: 0; }

.button { display: inline-flex; min-height: 42px; padding: 0 17px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 750; text-decoration: none; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button svg { width: 17px; fill: currentColor; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { color: var(--text); border-color: var(--border-strong); background: var(--surface-solid); }
.button-secondary:hover { background: var(--surface-muted); }
.button-success { color: white; background: var(--success); }
.button-success:hover { background: var(--success-hover); }
.button-small { min-height: 36px; padding: 0 12px; }

.device-card { display: grid; grid-template-columns: minmax(150px, 1fr) auto auto; gap: 12px; align-items: center; margin-top: 19px; padding: 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-muted); }
.device-card > div { display: grid; gap: 2px; }
.device-label { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.device-code-row { display: contents; }
.device-card strong { color: var(--text-strong); font-family: ui-monospace, "Cascadia Code", monospace; font-size: 21px; letter-spacing: .08em; }
.device-status { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 10px; }

.field-grid { display: grid; gap: 17px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.full-width { grid-column: 1 / -1; }
.field { display: grid; align-content: start; gap: 7px; margin-bottom: 18px; }
.field-grid > .field { margin-bottom: 0; }
.field > span { color: var(--text); font-size: 11px; font-weight: 750; }
.field small, .automation-copy small, .check-field small { color: var(--muted); font-size: 10px; font-weight: 450; }
input, select, textarea { width: 100%; color: var(--text-strong); border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-solid); outline: none; }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 86px; padding: 11px 12px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.input-suffix { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-solid); overflow: hidden; }
.input-suffix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.input-suffix input { border: 0; border-radius: 0; box-shadow: none; }
.input-suffix span { padding: 0 12px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; }
.availability-status { min-height: 15px; }
.availability-status.is-checking { color: var(--muted); }
.availability-status.is-available { color: var(--success); font-weight: 650; }
.availability-status.is-unavailable { color: var(--danger); font-weight: 650; }
.field .field-error { color: var(--danger); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.input-suffix:has(input[aria-invalid="true"]) { border-color: var(--danger); }
.field small a, #reconnect-notice a, #creation-recovery a { color: inherit; text-underline-offset: 2px; }

.automation-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 19px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); }
.automation-copy { display: grid; gap: 2px; }
.automation-copy strong, .check-field strong { color: var(--text); font-size: 11px; }
.automation-copy code, .card-heading code { font-size: .92em; }
.configured-pill { color: var(--success-text); background: var(--success-soft); }
.automation-copy { min-width: 0; }
.automation-copy a { color: var(--primary); font-size: 11px; text-underline-offset: 2px; }
.app-confirmation { margin-top: 5px; font-size: 11px; }
.is-disabled .configured-pill { color: var(--muted); background: var(--border); }
.is-disabled .automation-copy strong, .field.is-disabled > span { color: var(--muted); }
input:disabled { color: var(--muted); border-color: var(--border); background: var(--surface-muted); cursor: not-allowed; }
.check-field { display: flex; gap: 10px; align-items: flex-start; padding-top: 4px; color: var(--text); }
.check-field input { flex: 0 0 auto; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); }
.check-field > span { display: grid; gap: 2px; }
.create-actions { display: flex; flex-direction: column; align-items: flex-start; }
.create-actions .button { min-width: 220px; }

.notice { width: 100%; margin: 0 0 16px; padding: 11px 13px; border-radius: 8px; font-size: 11px; }
.notice-error { color: var(--danger); border: 1px solid #fecaca; background: var(--danger-soft); }
#connect-error { margin-top: 16px; margin-bottom: 0; }
#reconnect-notice { position: sticky; top: 78px; z-index: 11; }

.creation-status { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.creation-status p { margin: 0; }
.spinner { flex: 0 0 auto; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
#template-suggestion { display: flex; align-items: center; gap: 8px; }
#suggestion-spinner { width: 14px; height: 14px; }
.review-status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.review-status p { margin: 0; }
#create[aria-busy="true"] { opacity: 1; cursor: progress; }
#create .spinner { width: 16px; height: 16px; border-color: #ffffff55; border-top-color: white; }
.creation-progress { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.creation-progress p { margin: 0; color: var(--muted); font-size: 12px; }
.progress-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-heading p { color: var(--text); }
#creation-elapsed { flex-shrink: 0; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.progress-track { height: 4px; margin: 12px 0; overflow: hidden; border-radius: 4px; background: var(--border); }
.progress-track span { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--primary); animation: progress-slide 1.5s ease-in-out infinite; }
#creation-error { margin-top: 16px; }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
@media (prefers-reduced-motion: reduce) {
  .app-header { transition: none; }
  .spinner, .progress-track span { animation: none; }
  .progress-track span { width: 100%; opacity: .5; }
}
.creation-result { width: 100%; }
.creation-result p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.creation-result p a { color: var(--primary); text-underline-offset: 2px; }
.success-actions { display: flex; gap: 10px; margin-top: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-footer { display: flex; width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 27px 0 38px; justify-content: space-between; gap: 20px; color: var(--muted); border-top: 1px solid var(--border); font-size: 10px; }
.app-footer a { color: inherit; text-decoration: none; }
.app-footer a:hover { color: var(--text-strong); }

@media (max-width: 680px) {
  .header-inner, .main-content, .app-footer { width: min(calc(100% - 24px), 780px); }
  .brand { font-size: 16px; }
  .account { display: none; }
  .main-content { padding: 38px 0 58px; }
  .intro { margin-bottom: 26px; }
  .intro > p:not(.eyebrow) { font-size: 14px; }
  .security-notes { gap: 6px 12px; }
  .workflow, .package-flow { gap: 15px; }
  .card-heading { grid-template-columns: 31px minmax(0, 1fr); padding: 19px 17px; }
  .card-body { padding: 20px 17px; }
  .title-row { align-items: flex-start; gap: 8px; flex-wrap: wrap; }
  .title-row .step-state { margin-left: auto; }
  .two-columns { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .device-card { grid-template-columns: 1fr auto; }
  .device-card .button-primary { grid-column: 1 / -1; }
  .automation-row { align-items: flex-start; flex-wrap: wrap; gap: 10px; }
  .automation-copy { flex: 1 1 160px; }
  .configured-pill, .app-state { margin-top: 1px; margin-left: auto; }
  .create-actions .button { width: 100%; min-width: 0; }
  .success-actions { width: 100%; flex-direction: column; }
  .progress-heading { flex-direction: column; gap: 4px; }
  .app-footer { flex-direction: column; gap: 4px; }
}

@media (forced-colors: active) {
  #files, #content { scrollbar-color: auto; }
  .file[aria-pressed="true"], .workflow-card.is-active, .workflow-card.is-complete { border-color: Highlight; }
}

/* Theme 03 — Glass Factory
   More expressive, with translucent panels and cool pastel depth.
*/
:root {
  color-scheme: light;
  --bg: #eef7fb;
  --bg-accent: #e7efff;
  --surface: rgba(255,255,255,.70);
  --surface-solid: rgba(255,255,255,.93);
  --surface-muted: rgba(243,249,252,.78);
  --text: #30475b;
  --text-strong: #153148;
  --muted: #6e8293;
  --border: rgba(159,195,214,.52);
  --border-strong: rgba(127,171,195,.68);
  --primary: #3f78b6;
  --primary-hover: #32679e;
  --primary-soft: rgba(225,239,255,.76);
  --ready: #7c64b7;
  --ready-soft: rgba(240,233,252,.78);
  --success: #4d987b;
  --success-hover: #3c8065;
  --success-text: #35745c;
  --success-soft: rgba(228,247,238,.82);
  --danger: #b75f63;
  --danger-soft: rgba(255,235,235,.82);
  --shadow: 0 8px 24px rgba(55,100,126,.09), 0 28px 70px rgba(55,100,126,.10);
}

body {
  background:
    radial-gradient(circle at 8% 30%, rgba(99,165,201,0.18) 0 40px, transparent 41px),
    radial-gradient(circle at 90% 15%, rgba(146,112,191,0.16) 0 50px, transparent 51px),
    radial-gradient(circle at 85% 50%, rgba(236,161,177,0.18) 0 70px, transparent 71px),
    radial-gradient(circle at 15% 70%, rgba(116,197,169,0.15) 0 60px, transparent 61px),
    linear-gradient(135deg, #edf7fb 0%, #f5f3ff 48%, #fff8fa 100%);
}

.app-header.is-scrolled {
  background: rgba(255,255,255,.62);
  border-bottom-color: rgba(159,195,214,.45);
  box-shadow: 0 8px 30px rgba(56,96,120,.05);
  backdrop-filter: blur(10px) saturate(130%);
}

.intro {
  position: relative;
  isolation: isolate;
  filter: saturate(.96);
  min-height: 0;
  padding: 0;
  border-radius: 16px;
  /* Fill the entire hero while preserving the image's proportions. */
  background: url('/assets/hero.png') 100% 50% / cover no-repeat;
}

.intro::after {
  content: "";
  position: absolute;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  inset: 0;
  opacity: 1;
  background: linear-gradient(90deg, rgba(238,247,251,.98) 0%, rgba(238,247,251,.90) 32.67%, rgba(238,247,251,.24) 63.78%, rgba(238,247,251,0) 70%);
}

.workflow-card {
  border-color: rgba(159,195,214,.55);
  background: rgba(255,255,255,.68);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(125%);
}
.workflow-card.is-active { box-shadow: 0 0 0 3px rgba(124,100,183,.09), 0 12px 30px rgba(55,100,126,.10), 0 34px 80px rgba(55,100,126,.12); }
.card-heading { border-bottom-color: rgba(159,195,214,.42); }
.is-active .step-badge { background: var(--ready); border-color: var(--ready); }
.step-badge, .step-state, .app-state { background: rgba(245,250,252,.72); }

input, select, textarea, .input-suffix, .button-secondary { background: rgba(255,255,255,.83); }
input:focus, select:focus, textarea:focus, .input-suffix:focus-within { box-shadow: 0 0 0 3px rgba(63,120,182,.10), 0 8px 24px rgba(63,120,182,.06); }
.automation-row, .creation-progress, #files { background: rgba(241,248,251,.70); }
.button-primary { box-shadow: 0 8px 20px rgba(63,120,182,.20); }
.button-success { box-shadow: 0 8px 20px rgba(77,152,123,.18); }
.app-footer { border-top-color: rgba(159,195,214,.45); }

@media (max-width: 680px) {
  .intro::after {
    background: linear-gradient(90deg, rgba(238,247,251,.99) 0%, rgba(238,247,251,.96) 52.8%, rgba(238,247,251,.60) 80%);
  }
}

/* Keep the white GitHub asset visible on the light header. */
.github-link img { filter: brightness(0) saturate(100%) opacity(.72); }
