:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #171717;
  --panel-2: #1c1c1c;
  --border: #303030;
  --border-soft: #252525;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --muted-2: #7f7f7f;
  --white: #f4f4f4;
  --ink: #111111;
  --danger: #ff7b7b;
  --success: #79d29b;
  --warning: #ffd166;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.landing {
  width: min(870px, calc(100% - 48px));
  margin: 0 auto;
  padding: 104px 0 56px;
}
.eyebrow {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}
.hero-title {
  font-size: clamp(48px, 7vw, 74px);
  line-height: .98;
  letter-spacing: -0.055em;
  margin: 0;
  font-weight: 760;
}
.hero-copy {
  max-width: 790px;
  color: #a4a4a4;
  font-size: 19px;
  line-height: 1.72;
  margin: 26px 0 56px;
}
.import-card {
  border: 1px solid var(--border);
  background: rgba(26,26,26,.82);
  border-radius: 17px;
  padding: 39px 33px 34px;
  box-shadow: 0 16px 50px rgba(0,0,0,.18);
}
.field-label {
  display: block;
  font-size: 16px;
  font-weight: 720;
  margin-bottom: 18px;
}
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; }
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #8b8b8b;
  pointer-events: none;
}
.url-input {
  width: 100%;
  height: 54px;
  border-radius: 11px;
  border: 1px solid #333;
  background: #090909;
  color: #f2f2f2;
  padding: 0 17px 0 48px;
  outline: none;
}
.url-input:focus { border-color: #686868; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.primary-btn {
  height: 54px;
  border: 0;
  border-radius: 12px;
  background: #d6d6d6;
  color: #111;
  padding: 0 26px;
  font-weight: 760;
  white-space: nowrap;
}
.primary-btn:hover { background: #ececec; }
.primary-btn:disabled { opacity: .55; cursor: wait; }
.permission-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 21px;
  color: #b8b8b8;
  line-height: 1.45;
  font-size: 15px;
}
.permission-row input { margin-top: 2px; width: 18px; height: 18px; accent-color: #e6e6e6; }
.status-box {
  margin-top: 18px;
  border-radius: 12px;
  padding: 14px 15px;
  border: 1px solid var(--border-soft);
  background: #111;
  color: #bdbdbd;
  display: none;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
}
.status-box.show { display: block; }
.status-box.error { color: #ffb6b6; border-color: rgba(255,123,123,.28); background: rgba(120,20,20,.14); }
.status-box.success { color: #a4e2ba; border-color: rgba(121,210,155,.22); background: rgba(24,82,46,.14); }
.status-box.warn { color: #ffe1a0; border-color: rgba(255,209,102,.22); background: rgba(120,86,20,.12); }

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  border-top: 1px solid var(--border-soft);
  margin-top: 57px;
  padding-top: 39px;
}
.step { display: flex; gap: 14px; align-items: baseline; }
.step-no { color: #999; font-size: 13px; font-variant-numeric: tabular-nums; }
.step-label { font-size: 16px; font-weight: 720; }
.footnote { color: #8d8d8d; line-height: 1.65; margin-top: 45px; font-size: 15px; max-width: 870px; }

.projects { margin-top: 38px; display: none; }
.projects.show { display: block; }
.section-title { font-size: 14px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; color: #8e8e8e; margin-bottom: 12px; }
.project-list { display: grid; gap: 8px; }
.project-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 13px 15px; border: 1px solid var(--border-soft); border-radius: 11px; background: #101010;
}
.project-meta { min-width: 0; }
.project-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-url { color: #858585; font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-actions { display: flex; gap: 8px; }
.ghost-btn {
  border: 1px solid #3a3a3a; background: #111; color: #ddd; border-radius: 9px; padding: 9px 12px; font-weight: 650;
}
.ghost-btn:hover { background: #1b1b1b; }

/* Editor */
.editor-shell { min-height: 100vh; background: #0b0b0b; }
.editor-topbar {
  height: 60px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 14px; border-bottom: 1px solid #252525; background: #0b0b0b;
}
.top-left, .top-right { display: flex; align-items: center; gap: 8px; }
.top-right { justify-content: flex-end; }
.back-btn { background: none; border: 0; color: #ddd; font-size: 24px; width: 36px; height: 36px; border-radius: 8px; }
.back-btn:hover { background: #191919; }
.project-title { font-weight: 730; font-size: 15px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-state { color: #858585; font-size: 12px; }
.view-switch { display: flex; border: 1px solid #2f2f2f; border-radius: 10px; overflow: hidden; background: #141414; }
.view-btn { border: 0; background: transparent; color: #999; padding: 8px 12px; }
.view-btn.active { background: #272727; color: #fff; }
.code-btn, .download-btn { border-radius: 10px; padding: 9px 14px; font-weight: 730; }
.code-btn { border: 1px solid #3b3b3b; background: #151515; color: #eee; }
.download-btn { border: 0; background: #e3e3e3; color: #111; }
.download-btn:hover { background: #fff; }

.editor-body { height: calc(100vh - 60px); display: grid; grid-template-columns: 222px 1fr 315px; min-height: 0; }
.side-panel { background: #151515; border-right: 1px solid #2a2a2a; overflow: auto; }
.right-panel { background: #151515; border-left: 1px solid #2a2a2a; overflow: auto; }
.panel-heading { padding: 21px 17px 13px; color: #efefef; font-size: 13px; font-weight: 770; }
.panel-sub { padding: 0 17px 13px; color: #777; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 760; }
.layer-list { padding: 0 9px 16px; }
.layer-row { width: 100%; border: 0; background: transparent; color: #b6b6b6; text-align: left; padding: 9px 10px; border-radius: 8px; display:flex; gap:9px; align-items:center; }
.layer-row:hover { background:#1f1f1f; color:#fff; }
.add-grid { padding: 0 9px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-btn { border: 1px solid #343434; background:#111; color:#cfcfcf; padding: 9px 8px; border-radius: 8px; font-size: 12px; }
.add-btn:hover { background:#1b1b1b; }

.canvas-wrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; background:#242424; }
.canvas-toolbar { height: 46px; display: flex; align-items:center; justify-content:space-between; padding: 0 14px; border-bottom: 1px solid #2f2f2f; background:#191919; }
.canvas-hint { color:#777; font-size:12px; }
.open-btn { border: 1px solid #3b3b3b; background:#131313; color:#d2d2d2; border-radius: 8px; padding:7px 10px; font-size:12px; }
.canvas-stage { flex: 1; min-height: 0; padding: 22px; display:flex; justify-content:center; overflow:auto; }
.preview-frame {
  width: 100%; max-width: 1200px; height: 100%; min-height: 560px; border: 0; border-radius: 12px; background:white;
  box-shadow: 0 20px 45px rgba(0,0,0,.25);
}
.preview-frame.tablet { max-width: 820px; }
.preview-frame.mobile { max-width: 420px; }

.inspector-empty { padding: 72px 28px; text-align:center; color:#9e9e9e; }
.inspector-empty .big { font-size: 38px; opacity:.55; margin-bottom: 12px; }
.inspector-empty strong { display:block; color:#e5e5e5; font-size:15px; margin-bottom: 8px; }
.inspector-empty span { display:block; font-size:13px; line-height:1.55; }
.inspector { padding: 16px; }
.inspector-title { display:flex; justify-content:space-between; gap:10px; align-items:center; border-bottom:1px solid #282828; padding-bottom:13px; margin-bottom:14px; }
.inspector-title strong { font-size:13px; }
.inspector-title span { color:#7c7c7c; font-size:11px; }
.control-group { margin-bottom: 14px; }
.control-group label { display:block; font-size:11px; color:#8d8d8d; margin-bottom:7px; }
.control-group input, .control-group textarea, .control-group select {
  width:100%; border:1px solid #353535; background:#0e0e0e; color:#e8e8e8; border-radius:8px; padding:9px 10px; outline:none;
}
.control-group textarea { min-height: 82px; resize: vertical; }
.control-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.small-help { color:#6e6e6e; font-size:10px; line-height:1.45; margin-top:6px; }
.danger-btn { border:1px solid rgba(255,123,123,.3); color:#ffaeae; background:rgba(90,16,16,.18); border-radius:8px; padding:9px 11px; width:100%; }

.overlay { position:fixed; inset:0; background:rgba(0,0,0,.72); display:none; align-items:center; justify-content:center; z-index:1000; padding:24px; }
.overlay.show { display:flex; }
.modal { width:min(980px, 100%); max-height:min(760px, calc(100vh - 48px)); display:flex; flex-direction:column; background:#171717; border:1px solid #343434; border-radius:14px; overflow:hidden; box-shadow:0 30px 100px rgba(0,0,0,.55); }
.modal-head { display:flex; justify-content:space-between; gap:20px; align-items:center; padding:15px 17px; border-bottom:1px solid #2b2b2b; }
.modal-head strong { font-size:14px; }
.modal-close { border:0; background:transparent; color:#aaa; font-size:22px; }
.code-editor { flex:1; min-height:520px; width:100%; border:0; resize:none; padding:18px; background:#0c0c0c; color:#e5e5e5; font:12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; outline:none; }
.modal-foot { display:flex; justify-content:flex-end; gap:8px; padding:12px; border-top:1px solid #2b2b2b; }

/* Validation panel */
.validation-list { padding: 4px 16px 16px; display:grid; gap:7px; }
.validation-row { display:flex; gap:8px; align-items:flex-start; padding:8px 9px; border:1px solid #2c2c2c; border-radius:8px; background:#111; }
.validation-dot { width:8px; height:8px; border-radius:50%; background:#888; margin-top:5px; flex:0 0 auto; }
.validation-row.ok .validation-dot { background:#70d18d; }
.validation-row.warn .validation-dot { background:#ffd166; }
.validation-row.fail .validation-dot { background:#ff7070; }
.validation-text { min-width:0; }
.validation-label { font-size:11px; color:#ddd; }
.validation-detail { font-size:10px; color:#777; margin-top:2px; line-height:1.4; }

#toast-root { position:fixed; right:18px; bottom:18px; z-index:2000; display:grid; gap:8px; }
.toast { max-width:380px; border:1px solid #363636; background:#171717; color:#eee; border-radius:10px; padding:11px 13px; box-shadow:0 12px 35px rgba(0,0,0,.32); font-size:13px; line-height:1.45; }
.toast.error { border-color:rgba(255,123,123,.25); }
.toast.success { border-color:rgba(121,210,155,.25); }

@media (max-width: 900px) {
  .landing { width:min(700px, calc(100% - 32px)); padding-top:72px; }
  .url-row { grid-template-columns:1fr; }
  .steps { grid-template-columns:1fr 1fr; }
  .editor-body { grid-template-columns: 190px 1fr; }
  .right-panel { display:none; }
  .editor-topbar { grid-template-columns:1fr auto; }
  .view-switch { display:none; }
  .top-right { display:flex; }
  .code-btn { display:none; }
}
@media (max-width: 640px) {
  .landing { width:calc(100% - 22px); padding-top:46px; }
  .hero-title { font-size:48px; }
  .hero-copy { font-size:16px; margin-bottom:36px; }
  .import-card { padding:26px 18px 20px; }
  .steps { grid-template-columns:1fr; }
  .editor-body { grid-template-columns:1fr; }
  .side-panel { display:none; }
  .editor-topbar { padding:0 8px; }
  .project-title { max-width:130px; }
  .save-state { display:none; }
}
