@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --paper: #0b0f19;
  --surface: #111827;
  --surface-muted: #232d42;
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --ink-faint: #94a3b8;
  --forest: #4f46e5;
  --forest-light: #6366f1;
  --lime: #10b981;
  --lime-ink: #ecfdf5;
  --coral: #f59e0b;
  --blue: #22d3ee;
  --line: #1f2937;
  --focus: #818cf8;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); font-family: 'Inter', sans-serif; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline-color: var(--focus); }
button { cursor: pointer; }
a { color: inherit; }
code { color: #c7d2fe; font-family: ui-monospace, "Cascadia Code", monospace; font-size: .95em; }
studio-app, single-generator-view, apps-view { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.boot-state { padding: 4rem 2rem; color: var(--ink-soft); text-align: center; }

.topbar { background: rgba(17, 24, 39, .96); color: #f8fafc; border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1440px, 100%); min-height: 76px; margin: auto; padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); }
.brand-name { font-family: 'Inter', sans-serif; font-size: 21px; line-height: 1.05; letter-spacing: 0; }
.brand-kicker { margin-top: 5px; color: #94a3b8; font: 600 10px/1.3 'Inter', sans-serif; text-transform: uppercase; }
.local-signal { display: inline-flex; align-items: center; gap: 9px; padding: 9px 12px; border: 1px solid rgba(16,185,129,.33); border-radius: 7px; color: #34d399; font-size: 12px; white-space: nowrap; }
.local-signal::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(215,239,136,.12); }

.workspace { width: min(1440px, 100%); margin: auto; padding: 24px 28px 56px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 4px 0 21px; }
.eyebrow { margin: 0 0 7px; color: #818cf8; font: 700 10px/1.2 'Inter', sans-serif; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 700 30px/1.08 'Inter', sans-serif; letter-spacing: 0; }
.heading-note { max-width: 490px; margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.view-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: #111827; border: 1px solid var(--line); border-radius: 8px; scrollbar-width: thin; }
.view-tab { flex: 0 0 auto; min-height: 40px; padding: 0 16px; border: 0; border-radius: 5px; color: #94a3b8; background: transparent; font-size: 12px; font-weight: 700; transition: background .18s ease, color .18s ease, transform .18s ease; }
.view-tab:hover { color: #e2e8f0; background: #232d42; }
.view-tab[aria-selected="true"] { color: #c7d2fe; background: rgba(99,102,241,.16); box-shadow: inset 0 0 0 1px rgba(99,102,241,.4); }
.view-tab:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.view-panel { padding-top: 21px; animation: arrive .28s ease both; }
.view-panel[hidden] { display: none; }
@keyframes arrive { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font: 700 20px/1.15 'Inter', sans-serif; letter-spacing: 0; }
.section-head p { max-width: 590px; margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.panel-pad { padding: 19px; }
.panel-title { margin: 0 0 14px; font-size: 13px; font-weight: 750; }
.generator-layout { display: grid; grid-template-columns: minmax(270px, 350px) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.form-stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: #cbd5e1; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea, .search-field { width: 100%; min-width: 0; height: 39px; padding: 0 11px; border: 1px solid #1f2937; border-radius: 5px; background: #1a2234; color: #f8fafc; font-size: 12px; }
.field textarea { height: auto; min-height: 100px; padding: 10px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-field:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.18); outline: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button { min-height: 38px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; color: #e2e8f0; background: var(--surface-muted); font-size: 11px; font-weight: 750; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button-primary { background: #4f46e5; color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--forest-light); }
.button-accent { background: #059669; color: #ecfdf5; }
.button-accent:hover:not(:disabled) { background: #10b981; }
.button-outline { border-color: var(--line); background: transparent; color: #cbd5e1; }
.button-danger { background: #4c1d24; color: #fecaca; }
.field-hint { margin: -1px 0 0; color: var(--ink-faint); font-size: 10px; line-height: 1.45; }
.form-divider { height: 1px; margin: 1px 0; background: var(--line); }
.preview-panel { display: flex; flex-direction: column; min-height: 510px; overflow: hidden; }
.preview-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--line); background: #111827; }
.preview-tabs { display: flex; gap: 3px; }
.preview-tab { padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: #94a3b8; font: 500 11px 'Inter', sans-serif; }
.preview-tab[aria-selected="true"] { background: #4f46e5; color: white; }
.preview-actions { display: flex; gap: 6px; }
.preview-actions .button { min-height: 32px; padding: 0 9px; }
.code-preview { flex: 1; width: 100%; min-height: 400px; margin: 0; padding: 20px; overflow: auto; background: #0b0f19; color: #e2e8f0; font: 12px/1.75 ui-monospace, "Cascadia Code", monospace; tab-size: 2; white-space: pre; }
.preview-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 9px 13px; background: #111827; color: #94a3b8; font: 10px 'Inter', sans-serif; }

.apk-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 17px; }
.apk-item { display: flex; min-height: 228px; flex-direction: column; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid var(--line); border-top: 3px solid var(--forest); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.apk-item:nth-child(2) { border-top-color: var(--blue); }
.apk-item:nth-child(3) { border-top-color: var(--coral); }
.apk-item:nth-child(4) { border-top-color: #87a93c; }
.apk-type { color: var(--ink-faint); font: 700 9px 'Inter', sans-serif; text-transform: uppercase; }
.apk-item h3 { margin: 7px 0 0; font: 700 17px/1.15 'Inter', sans-serif; letter-spacing: 0; }
.apk-item p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.apk-item .button { display: flex; align-items: center; justify-content: center; text-decoration: none; }

.manual-guide { margin-top: 30px; }
.manual-guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.manual-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: #111827; }
.manual-step { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border: 1px solid rgba(99,102,241,.45); border-radius: 5px; background: rgba(99,102,241,.14); color: #a5b4fc; font: 700 11px 'Inter', sans-serif; }
.manual-card h3 { margin: 13px 0 7px; color: #f1f5f9; font: 650 14px/1.3 'Inter', sans-serif; }
.manual-card p, .manual-guide-note { margin: 0; color: #aab6c6; font-size: 12px; line-height: 1.65; }
.manual-guide-note { margin-top: 13px; }
.footer-note { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 21px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-faint); font: 11px 'Inter', sans-serif; }
.footer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.support-link { display: inline-flex; min-height: 36px; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; color: #e2e8f0; background: #111827; font: 600 11px 'Inter', sans-serif; text-decoration: none; transition: background .15s ease, border-color .15s ease; }
.support-link:hover { background: #232d42; border-color: #4b5563; }
.support-link svg { width: 16px; height: 16px; flex: 0 0 16px; }
.support-pix { border-color: rgba(16,185,129,.35); color: #a7f3d0; }
.support-pix:hover { background: rgba(16,185,129,.14); border-color: #10b981; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100vw - 32px)); padding: 13px 16px; border: 1px solid rgba(255,255,255,.14); border-radius: 6px; background: var(--forest); color: white; box-shadow: 0 12px 30px rgba(10,31,24,.24); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast[data-visible="true"] { opacity: 1; transform: translateY(0); }
.toast[data-tone="error"] { background: #8e382c; }

@media (max-width: 980px) {
  .apk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .generator-layout { grid-template-columns: minmax(245px, .8fr) minmax(0, 1.2fr); }
}
@media (max-width: 720px) {
  .topbar-inner { min-height: 66px; padding: 10px 16px; }
  .brand img { width: 36px; height: 36px; }
  .brand-name { font-size: 18px; }
  .brand-kicker { font-size: 9px; }
  .local-signal { padding: 7px 9px; font-size: 10px; }
  .workspace { padding: 20px 15px 38px; }
  .page-heading { align-items: start; flex-direction: column; gap: 9px; margin-bottom: 16px; }
  h1 { font-size: 27px; }
  .heading-note { font-size: 12px; }
  .generator-layout { grid-template-columns: 1fr; }
  .preview-panel { min-height: 390px; }
  .code-preview { min-height: 285px; }
}
@media (max-width: 460px) {
  .topbar-inner { gap: 8px; }
  .local-signal { font-size: 0; gap: 0; width: 27px; height: 27px; justify-content: center; padding: 0; }
  .local-signal::before { width: 8px; height: 8px; }
  .view-tab { min-height: 38px; padding: 0 12px; font-size: 11px; }
  .panel-pad { padding: 14px; }
  .field-grid, .apk-grid, .manual-guide-grid { grid-template-columns: 1fr; }
  .preview-top { align-items: flex-start; flex-direction: column; }
  .preview-actions { width: 100%; }
  .preview-actions .button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}