:root {
  color-scheme: light;
  --bg: #f4ebdb;
  --panel: rgba(15, 18, 21, 0.82);
  --panel-soft: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.11);
  --text-main: #f6efde;
  --text-soft: rgba(246, 239, 222, 0.7);
  --text-dark: #241a12;
  --accent: #f0893f;
  --accent-strong: #ff6c3d;
  --accent-muted: rgba(240, 137, 63, 0.18);
  --highlight: #7fd1c5;
  --danger: #ef5b5b;
  --shadow: 0 24px 64px rgba(18, 19, 22, 0.24);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 186, 122, 0.35), transparent 28rem),
    radial-gradient(circle at right 20%, rgba(127, 209, 197, 0.28), transparent 26rem),
    linear-gradient(180deg, #f7eddd 0%, #ecd7bf 100%);
  color: var(--text-dark);
  font-family: "Aptos", "Segoe UI Variable Text", "Trebuchet MS", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(36, 26, 18, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 26, 18, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
}

.ambient {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  filter: blur(68px);
  opacity: 0.42;
  pointer-events: none;
}

.ambient-left {
  left: -8rem;
  top: 20%;
  background: rgba(240, 137, 63, 0.55);
}

.ambient-right {
  right: -8rem;
  bottom: -5rem;
  background: rgba(127, 209, 197, 0.45);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1rem;
  min-height: 100vh;
  padding: 1.25rem;
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    var(--panel);
  box-shadow: var(--shadow);
  color: var(--text-main);
  backdrop-filter: blur(24px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(18rem, 28rem) 1fr;
  gap: 1.2rem;
  padding: 1.35rem;
}

.brand-block {
  display: grid;
  gap: 0.5rem;
}

.eyebrow,
.panel-kicker,
.dialog-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--highlight);
}

.brand-block h1,
.panel-header h2,
.name-dialog h3,
.hero-card h3 {
  margin: 0;
  font-family: "Sitka Display", "Book Antiqua", "Georgia", serif;
  letter-spacing: -0.02em;
}

.brand-block h1 {
  font-size: clamp(2rem, 3vw, 3.2rem);
}

.subtitle,
.panel-meta,
.footer-note,
.empty-state p,
.dialog-text,
.note,
.meta-list dt {
  color: var(--text-soft);
}

.subtitle {
  margin: 0;
  line-height: 1.55;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, auto)) minmax(15rem, 1fr);
  gap: 0.75rem;
  align-items: end;
}

.auth-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(127, 209, 197, 0.12);
  color: var(--text-main);
  white-space: nowrap;
}

.action-button,
.ghost-button,
.search-control input,
.dialog-field input {
  min-height: 2.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font: inherit;
}

.action-button,
.ghost-button {
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.action-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
}

.action-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-button.accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fffaf3;
}

.action-button.danger {
  background: rgba(239, 91, 91, 0.14);
  border-color: rgba(239, 91, 91, 0.4);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.02);
}

.search-control,
.dialog-field {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.search-control span,
.dialog-field span {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.search-control input,
.dialog-field input {
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

.action-button:focus-visible,
.ghost-button:focus-visible,
.search-control input:focus-visible,
.dialog-field input:focus-visible,
.tree-node-button:focus-visible,
.list-row:focus-visible,
.crumb-button:focus-visible {
  outline: 2px solid rgba(127, 209, 197, 0.82);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(22rem, 1fr) minmax(20rem, 27rem);
  gap: 1rem;
  min-height: 0;
}

.panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 1.1rem 1.2rem 0;
}

.panel-header-wide {
  align-items: center;
}

.panel-header h2 {
  font-size: 1.5rem;
}

.path-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.7rem;
  padding: 0.65rem 1.2rem 0.9rem;
}

.crumb-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
}

.crumb-button.current {
  color: var(--highlight);
}

.crumb-separator {
  color: var(--text-soft);
}

.list-header {
  display: grid;
  grid-template-columns: minmax(12rem, 1.8fr) minmax(8rem, 1fr) minmax(6rem, 0.7fr) minmax(8rem, 0.9fr);
  gap: 1rem;
  padding: 0 1.2rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.tree-host,
.list-host,
.preview-host {
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.2rem 1.2rem;
}

.tree-host {
  padding-top: 0.7rem;
}

.tree-list,
.tree-children {
  display: grid;
  gap: 0.3rem;
}

.tree-children {
  margin-left: 1rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.tree-node,
.list-row {
  display: grid;
  width: 100%;
}

.tree-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.tree-node-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.tree-node.current > .tree-line .tree-node-button,
.tree-node.selected > .tree-line .tree-node-button,
.tree-node-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tree-tag,
.row-icon,
.preview-tag,
.hero-badge,
.search-banner strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.15rem;
  min-height: 2.15rem;
  border-radius: 0.85rem;
  background: rgba(240, 137, 63, 0.16);
  color: #ffd4b4;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree-tag.file,
.row-icon.file {
  background: rgba(127, 209, 197, 0.14);
  color: #bef8ee;
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  align-self: center;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.list-host {
  display: grid;
  align-content: start;
  gap: 0.55rem;
}

.list-row {
  grid-template-columns: minmax(12rem, 1.8fr) minmax(8rem, 1fr) minmax(6rem, 0.7fr) minmax(8rem, 0.9fr);
  gap: 1rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.8rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.list-row:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.list-row.selected {
  border-color: rgba(127, 209, 197, 0.48);
  background: rgba(127, 209, 197, 0.12);
}

.row-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.row-text {
  min-width: 0;
}

.row-name,
.row-secondary,
.meta-list dd,
.preview-editor,
.preview-code,
.preview-fallback {
  margin: 0;
}

.row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.row-secondary {
  font-size: 0.82rem;
  color: var(--text-soft);
}

.card,
.empty-state,
.search-banner {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(255, 255, 255, 0.03);
  padding: 1.2rem;
}

.empty-state,
.loading-card {
  display: grid;
  gap: 0.7rem;
}

.loading-card {
  place-items: center;
  min-height: 17rem;
  color: var(--text-soft);
}

.loading-card::before {
  content: "";
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.preview-host {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.preview-card {
  display: grid;
  gap: 1rem;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.preview-heading h3 {
  margin: 0;
  font-size: 1.2rem;
}

.preview-tag {
  width: fit-content;
}

.preview-editor,
.preview-code {
  width: 100%;
  min-height: 21rem;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: rgba(7, 10, 12, 0.5);
  color: var(--text-main);
  font: 0.95rem/1.6 "Consolas", "Cascadia Code", monospace;
}

.preview-code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.preview-image,
.preview-embed,
.preview-video {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 10, 12, 0.5);
}

.preview-image {
  max-height: 27rem;
  object-fit: contain;
}

.preview-embed {
  min-height: 30rem;
}

.preview-video {
  max-height: 27rem;
}

.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1rem;
  margin: 0;
}

.meta-list dd {
  color: var(--text-main);
}

.search-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.name-dialog {
  max-width: 28rem;
  width: calc(100% - 2rem);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    var(--panel);
  color: var(--text-main);
  box-shadow: var(--shadow);
}

.name-dialog::backdrop {
  background: rgba(9, 12, 15, 0.56);
  backdrop-filter: blur(5px);
}

.name-dialog form {
  display: grid;
  gap: 1rem;
  padding: 1.35rem;
}

.auth-dialog form {
  min-width: min(30rem, 90vw);
}

.auth-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.auth-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-main);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
}

.toast-region {
  position: fixed;
  right: 1.3rem;
  bottom: 1.3rem;
  z-index: 10;
  display: grid;
  gap: 0.7rem;
  width: min(22rem, calc(100vw - 2rem));
}

.toast {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(18, 21, 24, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  animation:
    toast-in 220ms ease forwards,
    toast-out 220ms ease 3.8s forwards;
}

.toast.error {
  border-color: rgba(239, 91, 91, 0.46);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

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

  .toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: minmax(15rem, 20rem) minmax(18rem, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

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

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-header,
  .list-row {
    grid-template-columns: minmax(10rem, 1.7fr) minmax(6rem, 0.9fr) minmax(5rem, 0.7fr);
  }

  .list-header span:last-child,
  .list-row > :last-child {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.8rem;
  }

  .topbar,
  .panel {
    border-radius: 1.2rem;
  }

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

  .panel-header,
  .path-tools,
  .search-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .list-header,
  .list-row {
    grid-template-columns: 1fr;
  }

  .list-header span:not(:first-child),
  .list-row > :not(:first-child) {
    display: none;
  }
}
