* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", Arial, sans-serif; background: #0a0a0a; color: #e5e7eb; height: 100%; }
body { display: grid; grid-template-rows: 48px 1fr; height: 100vh; overflow: hidden; }

/* ---------- header ---------- */
header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 0 18px; background: #0d0f15; border-bottom: 1px solid #1f2937; }
header .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
header .brand .logo { width: 26px; height: 26px; display: block; }
header .brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
header .brand .name { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; color: #e5e7eb; }
header .brand .sub { font-size: 9px; color: #6b7280; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-top: 2px; }
header nav { display: flex; gap: 4px; }
header nav a { display: inline-block; padding: 6px 14px; border-radius: 6px; color: #9ca3af; text-decoration: none; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
header nav a:hover { background: #1f2937; color: #fff; }
header nav a.active { background: #f59e0b; color: #1a1a1a; }
header .user { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid #1f2937; }
header .user .who { font-size: 12px; color: #9ca3af; font-weight: 600; }
header .user button.logout { background: transparent; color: #6b7280; border: 1px solid #1f2937; border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 700; cursor: pointer; }
header .user button.logout:hover { color: #f87171; border-color: #7f1d1d; }

/* ---------- login screen ---------- */
body.logged-out { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #161e2e 0%, #0a0a0a 60%); }
.login-shell { width: 100%; max-width: 360px; padding: 32px; }
.login-form { display: flex; flex-direction: column; gap: 10px; background: #111827; border: 1px solid #1f2937; border-radius: 14px; padding: 28px 26px; box-shadow: 0 30px 60px rgba(0,0,0,0.5); }
.login-form .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-form .login-brand .logo { width: 44px; height: 44px; display: block; }
.login-form .login-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.login-form .login-brand .brand-text .name { font-size: 17px; font-weight: 800; letter-spacing: 0.3px; color: #e5e7eb; }
.login-form .login-brand .brand-text .tagline { font-size: 11px; color: #9ca3af; font-style: italic; margin-top: 3px; }
.login-form .login-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; color: #9ca3af; text-transform: uppercase; letter-spacing: 1px; }
.login-form label { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; margin-top: 6px; }
.login-form input { padding: 10px 12px; background: #0a0a0a; border: 1px solid #1f2937; border-radius: 8px; color: #fff; font-size: 14px; font-family: inherit; }
.login-form input:focus { outline: none; border-color: #f59e0b; }
.login-form .err { font-size: 12px; color: #f87171; margin-top: 4px; }
.login-form button.primary { width: 100%; padding: 11px; background: #f59e0b; color: #1a1a1a; border: none; border-radius: 8px; font-size: 14px; font-weight: 800; cursor: pointer; margin-top: 10px; letter-spacing: 0.5px; }
.login-form button.primary:hover { background: #fbbf24; }
.login-form button.primary:disabled { background: #374151; color: #6b7280; cursor: wait; }

#app { overflow: hidden; }

/* ---------- generate view ---------- */
.generate-grid { display: grid; grid-template-columns: 380px 1fr; height: 100%; overflow: hidden; }
.generate-grid aside { background: #111827; border-right: 1px solid #1f2937; overflow-y: auto; padding: 18px 18px 28px; }
.generate-grid main { padding: 20px; overflow: auto; }

.group-title { font-size: 10px; font-weight: 800; color: #f59e0b; text-transform: uppercase; letter-spacing: 1.5px; margin: 22px 0 10px; padding-bottom: 4px; border-bottom: 1px solid #1f2937; }
.group-title:first-of-type { margin-top: 4px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.field input[type=text], .field input[type=url], .field input[type=number], .field textarea, .field select { width: 100%; padding: 7px 9px; background: #0a0a0a; border: 1px solid #374151; border-radius: 6px; color: #fff; font-size: 13px; font-family: inherit; }
.field textarea { font-family: "JetBrains Mono", "Consolas", "Courier New", monospace; font-size: 12px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #f59e0b; }
.field input[type=color] { width: 38px; height: 26px; padding: 0; border: 1px solid #374151; border-radius: 4px; background: #0a0a0a; cursor: pointer; vertical-align: middle; }
.field .color-row { display: flex; align-items: center; gap: 8px; }
.field .color-row input[type=text] { flex: 1; font-family: "Courier New", monospace; font-size: 12px; }
.field .hint { font-size: 10px; color: #6b7280; margin-top: 2px; }

.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 4px 9px; background: #0a0a0a; border: 1px solid #374151; border-radius: 14px; cursor: pointer; user-select: none; }
.checks label.on { background: #f59e0b; color: #1a1a1a; border-color: #f59e0b; font-weight: 700; }
.checks label input { display: none; }

button.gen, button.primary { width: 100%; padding: 12px; background: #f59e0b; color: #1a1a1a; border: none; border-radius: 8px; font-size: 14px; font-weight: 800; cursor: pointer; margin-top: 22px; letter-spacing: 0.5px; }
button.gen:hover, button.primary:hover { background: #fbbf24; }
button.gen:disabled, button.primary:disabled { background: #374151; color: #6b7280; cursor: wait; }
button.secondary { padding: 8px 14px; background: #1f2937; color: #e5e7eb; border: 1px solid #374151; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }
button.secondary:hover { background: #374151; }
button.danger { padding: 8px 14px; background: transparent; color: #f87171; border: 1px solid #7f1d1d; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }
button.danger:hover { background: #450a0a; }

.status { font-size: 11px; color: #9ca3af; margin-top: 10px; min-height: 14px; }
.progress-bar { height: 4px; background: #1f2937; border-radius: 2px; margin-top: 8px; overflow: hidden; display: none; }
.progress-fill { height: 100%; background: #f59e0b; width: 0%; transition: width 0.3s ease; }
.progress-bar.on { display: block; }
.log { font-family: "Courier New", "Consolas", monospace; font-size: 10px; line-height: 1.4; color: #d1d5db; background: #0a0a0a; border: 1px solid #1f2937; border-radius: 6px; padding: 8px 10px; margin-top: 10px; max-height: 240px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; display: none; }
.log.on { display: block; }
.log .err { color: #f87171; }
.log .ok { color: #34d399; }

.preview-grid { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.preview-tpl { display: flex; flex-direction: column; gap: 14px; }
.preview-tpl > .name { font-size: 13px; font-weight: 800; color: #f59e0b; }
.format-section h3 { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 2px; margin: 0 0 8px; }
.preview-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.preview-cell { display: flex; flex-direction: column; align-items: center; }
.preview-cell .lab { font-family: "Courier New", monospace; font-size: 10px; color: #6b7280; margin-bottom: 4px; }
.preview-cell iframe { background: #fff; border: 1px solid #374151; display: block; }

/* ---------- picker view (Generate step 1) ---------- */
.list-view .list-header .sub-h { font-size: 12px; color: #6b7280; margin-top: 4px; max-width: 540px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.picker-card { background: #111827; border: 1px solid #1f2937; border-radius: 12px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; transition: border-color 0.15s, transform 0.15s; }
.picker-card:hover { border-color: #f59e0b; transform: translateY(-2px); }
.picker-card .frame { background: #0a0a0a; padding: 14px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid #1f2937; }
.picker-card .frame iframe { background: #fff; border: 1px solid #1f2937; display: block; }
.picker-card .body { padding: 12px 16px 4px; }
.picker-card .slug-line { font-size: 10px; color: #f59e0b; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.picker-card .slug-line .pill { background: #1f2937; color: #9ca3af; padding: 1px 6px; border-radius: 8px; font-size: 9px; letter-spacing: 0.5px; }
.picker-card .name { font-size: 14px; font-weight: 700; margin: 4px 0 10px; color: #e5e7eb; }
.picker-card .meta { font-size: 10px; color: #6b7280; display: flex; gap: 12px; flex-wrap: wrap; }
.picker-card .pick-cta { margin-top: auto; padding: 10px 16px; font-size: 11px; font-weight: 800; color: #f59e0b; letter-spacing: 0.5px; text-transform: uppercase; border-top: 1px solid #1f2937; }

/* ---------- customize banner + back link ---------- */
.back-row { margin-bottom: 10px; }
.back-link { font-size: 11px; color: #9ca3af; text-decoration: none; font-weight: 700; letter-spacing: 0.3px; }
.back-link:hover { color: #f59e0b; }
.tpl-banner { background: #0a0a0a; border: 1px solid #1f2937; border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.tpl-banner .slug { font-size: 10px; color: #f59e0b; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.tpl-banner .slug .pill { background: #1f2937; color: #9ca3af; padding: 1px 6px; border-radius: 8px; font-size: 9px; letter-spacing: 0.5px; }
.tpl-banner .tname { font-size: 14px; font-weight: 700; margin-top: 3px; }

/* ---------- templates list ---------- */
.list-view { padding: 24px; overflow: auto; height: 100%; }
.list-view .list-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.list-view .list-header h2 { margin: 0; font-size: 18px; font-weight: 800; }
.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tpl-card { background: #111827; border: 1px solid #1f2937; border-radius: 10px; padding: 14px 16px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.tpl-card:hover { border-color: #f59e0b; background: #161e2e; }
.tpl-card .slug { font-size: 11px; font-weight: 800; color: #f59e0b; text-transform: uppercase; letter-spacing: 1px; }
.tpl-card .name { font-size: 14px; font-weight: 700; margin: 4px 0 10px; }
.tpl-card .meta { font-size: 10px; color: #6b7280; display: flex; gap: 14px; }
.tpl-card .meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- editor view ---------- */
.editor-view { display: grid; grid-template-columns: 1fr 480px; height: 100%; overflow: hidden; }
.editor-view .editor-pane { overflow: auto; padding: 18px 20px; }
.editor-view .preview-pane { overflow: auto; padding: 18px 20px; border-left: 1px solid #1f2937; background: #0d0f15; }

.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.editor-header .title { display: flex; flex-direction: column; gap: 2px; }
.editor-header .title .slug-line { font-size: 10px; color: #6b7280; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.editor-header .title input { background: transparent; border: none; color: #fff; font-size: 18px; font-weight: 800; padding: 0; outline: none; min-width: 320px; }
.editor-header .actions { display: flex; gap: 8px; align-items: center; }
.editor-header .version-meta { font-size: 11px; color: #6b7280; margin-right: 6px; }
.editor-header select { background: #0a0a0a; border: 1px solid #374151; border-radius: 6px; color: #e5e7eb; padding: 6px 8px; font-size: 12px; font-family: inherit; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid #1f2937; margin-bottom: 14px; }
.tabs button { padding: 8px 14px; background: transparent; border: none; color: #9ca3af; font-size: 12px; font-weight: 700; cursor: pointer; border-radius: 6px 6px 0 0; }
.tabs button.active { background: #111827; color: #f59e0b; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.body-editor { display: flex; flex-direction: column; gap: 6px; }
.body-editor textarea { width: 100%; min-height: 420px; resize: vertical; padding: 10px 12px; background: #0a0a0a; border: 1px solid #1f2937; border-radius: 8px; color: #e5e7eb; font-family: "JetBrains Mono", "Consolas", "Courier New", monospace; font-size: 12px; line-height: 1.5; }
.body-editor textarea:focus { outline: none; border-color: #f59e0b; }
.body-editor .info { font-size: 10px; color: #6b7280; }
.body-editor .info code { background: #1f2937; padding: 1px 4px; border-radius: 3px; color: #fbbf24; font-size: 10px; }

.schema-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.schema-table th { text-align: left; font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; padding: 0 8px 6px; font-weight: 700; }
.schema-table td { padding: 4px; vertical-align: middle; }
.schema-table input[type=text], .schema-table select { width: 100%; padding: 6px 8px; background: #0a0a0a; border: 1px solid #1f2937; border-radius: 4px; color: #e5e7eb; font-size: 12px; font-family: inherit; }
.schema-table input:focus, .schema-table select:focus { outline: none; border-color: #f59e0b; }
.schema-table .row-remove { background: transparent; color: #6b7280; border: none; cursor: pointer; font-size: 16px; padding: 4px 8px; }
.schema-table .row-remove:hover { color: #f87171; }
.schema-add { margin-top: 10px; }

.preview-pane h3 { margin: 0 0 12px; font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.preview-pane .preview-controls { display: flex; gap: 6px; margin-bottom: 14px; }
.preview-pane .preview-controls button { padding: 5px 12px; background: #1f2937; color: #9ca3af; border: 1px solid #374151; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; }
.preview-pane .preview-controls button.active { background: #f59e0b; color: #1a1a1a; border-color: #f59e0b; }
.preview-pane iframe { background: #fff; border: 1px solid #374151; max-width: 100%; }
.preview-pane .preview-meta { font-family: "Courier New", monospace; font-size: 10px; color: #6b7280; margin-top: 6px; }
.preview-pane .size-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-pane .size-picker button { padding: 3px 8px; background: transparent; border: 1px solid #1f2937; border-radius: 12px; color: #6b7280; font-size: 10px; font-family: "Courier New", monospace; cursor: pointer; }
.preview-pane .size-picker button.active { color: #f59e0b; border-color: #f59e0b; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 12px 16px; border: 1px solid #1f2937; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: #14532d; }
.toast.err { border-color: #7f1d1d; }

.empty { padding: 60px 20px; text-align: center; color: #6b7280; font-size: 13px; }
.empty button { margin-top: 14px; }

/* ---------- from-image upload view ---------- */
.fi-view { padding: 24px; overflow: auto; height: 100%; max-width: 1100px; }
.fi-header { margin-bottom: 18px; }
.fi-header h2 { margin: 6px 0 4px; font-size: 18px; font-weight: 800; }
.fi-header .fi-sub { font-size: 12px; color: #6b7280; max-width: 720px; }
.fi-grid { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }
.fi-col { display: flex; flex-direction: column; }
.fi-label { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; margin-bottom: 6px; }
.fi-col input[type=text], .fi-col textarea { padding: 8px 10px; background: #0a0a0a; border: 1px solid #1f2937; border-radius: 6px; color: #fff; font-size: 13px; font-family: inherit; }
.fi-col input[type=text]:focus, .fi-col textarea:focus { outline: none; border-color: #f59e0b; }
.fi-col textarea { resize: vertical; font-family: inherit; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 60px 20px; background: #0a0a0a; border: 2px dashed #1f2937; border-radius: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.hover { border-color: #f59e0b; background: #161e2e; }
.dropzone .dz-icon { font-size: 28px; color: #f59e0b; }
.dropzone .dz-title { font-size: 14px; font-weight: 700; color: #e5e7eb; }
.dropzone .dz-sub { font-size: 11px; color: #6b7280; }

.dz-preview { margin-top: 14px; }
.dz-preview img { max-width: 100%; max-height: 360px; border: 1px solid #1f2937; border-radius: 8px; background: #fff; display: block; }
.dz-preview .dz-filemeta { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 11px; color: #9ca3af; font-family: monospace; }
.dz-preview .linkish { background: transparent; border: none; color: #f59e0b; font-size: 11px; cursor: pointer; padding: 0; }
.dz-preview .linkish:hover { text-decoration: underline; }

.fi-status { margin-top: 12px; font-size: 12px; min-height: 18px; }
.fi-status.busy { color: #f59e0b; }
.fi-status.err  { color: #f87171; }

