:root {
  color-scheme: dark;
  --bg-0: #06101b;
  --bg-1: #0b1626;
  --bg-2: #111b2d;
  --panel: rgba(10, 18, 33, 0.88);
  --panel-strong: rgba(9, 17, 31, 0.97);
  --stroke: rgba(165, 201, 255, 0.16);
  --stroke-strong: rgba(165, 201, 255, 0.28);
  --text: #edf4ff;
  --muted: rgba(237, 244, 255, 0.68);
  --soft: rgba(237, 244, 255, 0.1);
  --accent: #7be7ff;
  --accent-2: #ffbb72;
  --good: #66efb5;
  --warn: #ffd26e;
  --bad: #ff7f8a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.44);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html, body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 18%, rgba(123, 231, 255, 0.12), transparent 24%),
    radial-gradient(circle at 84% 10%, rgba(255, 187, 114, 0.10), transparent 22%),
    linear-gradient(155deg, var(--bg-0) 0%, var(--bg-1) 42%, var(--bg-2) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent 120px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 72px 72px, 72px 72px;
  mask-image: radial-gradient(circle at center, black 0%, black 68%, transparent 100%);
  opacity: 0.3;
}

body::after {
  background:
    radial-gradient(circle at 50% 100%, rgba(123, 231, 255, 0.16), transparent 42%),
    radial-gradient(circle at 12% 84%, rgba(255, 187, 114, 0.08), transparent 18%);
  opacity: 0.9;
}

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

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

input,
textarea,
select {
  outline: none;
}

::selection {
  background: rgba(123, 231, 255, 0.28);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100vw - 18px));
  margin: 9px auto 20px;
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(12, 22, 42, 0.92), rgba(8, 14, 26, 0.88));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(260px, 0.9fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), transparent 35%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.14) inset,
    0 18px 28px rgba(123, 231, 255, 0.16);
}

.topbar__copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topbar__title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.topbar__hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.topbar__metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.mini-stat--compact {
  min-width: 92px;
  padding: 9px 11px;
  gap: 4px;
  border-radius: 14px;
}

.mini-stat--compact span {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mini-stat--compact strong {
  font-size: 0.95rem;
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel--stack {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.hero {
  padding: clamp(20px, 3vw, 30px);
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.8fr);
  gap: 22px;
  align-items: start;
}

.hero__copy {
  display: grid;
  gap: 12px;
}

.eyebrow,
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(123, 231, 255, 0.06);
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
  max-width: 16ch;
}

.lede {
  margin: 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.45vw, 1.1rem);
  line-height: 1.7;
}

.hero__controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.hero__stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mini-stat {
  display: grid;
  gap: 8px;
  padding: 14px 15px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(14, 23, 41, 0.9), rgba(9, 16, 30, 0.95));
}

.mini-stat span {
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-stat strong {
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  letter-spacing: -0.03em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border-radius: 14px;
  border: 1px solid rgba(165, 201, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(123, 231, 255, 0.34);
  background: rgba(123, 231, 255, 0.08);
}

.btn:disabled,
.btn:disabled:hover,
.btn:disabled:focus-visible {
  transform: none;
  border-color: rgba(165, 201, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(237, 244, 255, 0.42);
  opacity: 0.68;
}

.btn--primary {
  color: #061019;
  border-color: rgba(123, 231, 255, 0.38);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 700;
}

.btn--accent {
  border-color: rgba(123, 231, 255, 0.28);
  background: linear-gradient(135deg, rgba(123, 231, 255, 0.2), rgba(255, 187, 114, 0.16));
  font-weight: 700;
}

.btn--danger {
  border-color: rgba(255, 127, 138, 0.3);
  background: linear-gradient(135deg, rgba(255, 127, 138, 0.18), rgba(255, 187, 114, 0.08));
  color: #ffeef1;
  font-weight: 700;
}

.btn--danger:hover,
.btn--danger:focus-visible {
  border-color: rgba(255, 127, 138, 0.46);
  background: rgba(255, 127, 138, 0.14);
}

.btn--ghost {
  background: rgba(5, 11, 22, 0.62);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(236px, 276px) minmax(0, 1fr) minmax(312px, 350px);
  gap: 12px;
  align-items: start;
}

.sidebar-column,
.right-column {
  display: grid;
  gap: 16px;
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel__head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.panel__head h2 {
  margin: 4px 0 0;
  font-size: clamp(1rem, 1.45vw, 1.25rem);
  letter-spacing: -0.03em;
}

.project-list {
  display: grid;
  gap: 8px;
}

.file-tree {
  display: grid;
  gap: 6px;
}

.project-item {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(14, 23, 41, 0.92), rgba(9, 16, 30, 0.96));
  text-align: left;
  color: var(--text);
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.project-item:hover,
.project-item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(123, 231, 255, 0.34);
}

.project-item.is-active {
  background: linear-gradient(135deg, rgba(123, 231, 255, 0.14), rgba(255, 187, 114, 0.08));
  border-color: rgba(123, 231, 255, 0.34);
}

.project-item__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.project-item__desc,
.roadmap span,
.share-note,
.save-status,
.editor-path,
.tree-file__path,
.tree-folder__summary {
  color: var(--muted);
}

.project-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.78rem;
}

.roadmap {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.roadmap li {
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 6px;
}

.roadmap strong {
  letter-spacing: -0.02em;
}

.editor-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  min-height: 100%;
}

.editor-panel__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 14px;
}

.editor-meta-grid {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 38px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(5, 11, 22, 0.72);
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

#shareUrl {
  cursor: copy;
}

.field textarea {
  min-height: 62px;
  resize: vertical;
  line-height: 1.55;
}

.field input::placeholder,
.field textarea::placeholder {
  color: rgba(237, 244, 255, 0.34);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(123, 231, 255, 0.54);
  box-shadow: 0 0 0 3px rgba(123, 231, 255, 0.12);
  transform: translateY(-1px);
}

.field input:disabled,
.field textarea:disabled,
.field select:disabled,
.editor:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  background: rgba(5, 11, 22, 0.5);
  color: rgba(237, 244, 255, 0.52);
}

.field--wide {
  min-width: 0;
}

.settings-panel {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.settings-form-grid .field--wide {
  grid-column: 1 / -1;
}

.settings-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-footer__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.toolbar-actions,
.editor-footer__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor {
  width: 100%;
  min-height: 66vh;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.96), rgba(8, 14, 26, 0.96));
  color: #f4f9ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  resize: vertical;
  white-space: pre;
}

.editor:focus {
  border-color: rgba(123, 231, 255, 0.54);
  box-shadow: 0 0 0 3px rgba(123, 231, 255, 0.12);
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}

.editor-path {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  word-break: break-all;
}

.save-status {
  margin-top: 3px;
  font-size: 0.84rem;
}

.preview-frame {
  width: 100%;
  min-height: 42vh;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: #ffffff;
}

.console-output {
  margin: 0;
  min-height: 220px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: #06111d;
  color: #d9e8ff;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

.share-note {
  margin: 0;
  line-height: 1.6;
  font-size: 0.88rem;
}

.project-dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--stroke);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(12, 22, 42, 0.98), rgba(9, 16, 29, 0.98));
  color: var(--text);
  box-shadow: var(--shadow);
}

.project-dialog::backdrop {
  background: rgba(2, 8, 16, 0.66);
  backdrop-filter: blur(6px);
}

.project-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.project-dialog__head {
  margin-bottom: 2px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.tree {
  display: grid;
  gap: 8px;
}

.tree-folder {
  display: grid;
  gap: 6px;
}

.tree-folder > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  font-weight: 700;
}

.tree-folder > summary::-webkit-details-marker {
  display: none;
}

.tree-children {
  display: grid;
  gap: 6px;
  padding-left: 14px;
  border-left: 1px solid rgba(165, 201, 255, 0.12);
  margin-left: 9px;
}

.tree-file-row {
  position: relative;
}

.tree-file {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  padding-right: 42px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.tree-file:hover,
.tree-file:focus-visible,
.tree-file.is-active {
  transform: translateX(1px);
  border-color: rgba(123, 231, 255, 0.26);
  background: rgba(123, 231, 255, 0.06);
}

.tree-file__delete {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  font-size: 0.85rem;
  line-height: 1;
}

.tree-file-row:hover .tree-file__delete,
.tree-file-row:focus-within .tree-file__delete {
  opacity: 1;
  pointer-events: auto;
}

.tree-file__name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tree-file__path {
  font-size: 0.85rem;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar__metrics,
  .topbar__actions {
    justify-content: flex-start;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .editor-panel__head {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 12px, 1600px);
    margin-top: 6px;
  }

  .topbar__actions {
    justify-content: stretch;
  }

  .topbar__actions .btn {
    flex: 1 1 120px;
  }

  .topbar__metrics {
    grid-template-columns: 1fr;
  }

  .editor {
    min-height: 52vh;
  }

  .editor-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-footer__actions {
    justify-content: stretch;
  }

  .editor-footer__actions .btn {
    flex: 1 1 150px;
  }
}
