:root {
  color-scheme: dark;
  --bg: #0e1112;
  --panel: #151a1d;
  --panel-2: #1d2428;
  --panel-3: #101416;
  --ink: #f5f1e8;
  --muted: #a8b1b2;
  --soft: #6f7b7b;
  --line: #2d393c;
  --line-strong: #425257;
  --teal: #41c7b7;
  --teal-soft: rgba(65, 199, 183, 0.16);
  --gold: #d2a858;
  --gold-soft: rgba(210, 168, 88, 0.16);
  --rose: #e26d6a;
  --rose-soft: rgba(226, 109, 106, 0.15);
  --violet: #a887e8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(65, 199, 183, 0.08), transparent 38%),
    radial-gradient(circle at 90% 12%, rgba(168, 135, 232, 0.11), transparent 30rem),
    radial-gradient(circle at 70% 80%, rgba(210, 168, 88, 0.1), transparent 26rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
.upload-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 15px;
  color: #071210;
  background: var(--teal);
  cursor: pointer;
}

button:hover,
.upload-button:hover {
  background: #63ddcf;
}

button:disabled,
.upload-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #0e1315;
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  padding: 24px;
  background: rgba(15, 19, 20, 0.94);
}

.brand {
  display: grid;
  gap: 10px;
}

.eyebrow,
.section-label {
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  font-size: 34px;
  line-height: 1.06;
}

.brand p,
.profile-card p,
.rules-card p,
.active-meta,
.preview-info p,
.drop-zone span,
.file-card span,
.file-card small {
  color: var(--muted);
  line-height: 1.45;
}

.auth-card,
.profile-card,
.rules-card,
.vault-panel,
.preview-panel,
.stats-row article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 29, 0.88);
  box-shadow: var(--shadow);
}

.auth-card,
.profile-card,
.rules-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1416;
}

.mode-button {
  color: var(--muted);
  background: transparent;
}

.mode-button.is-active {
  color: #071210;
  background: var(--teal);
}

.auth-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.api-details {
  color: var(--muted);
  font-size: 13px;
}

.api-details summary {
  cursor: pointer;
  margin-bottom: 10px;
}

.profile-card h2 {
  overflow-wrap: anywhere;
}

.status-dot {
  width: max-content;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 850;
}

.ghost {
  color: var(--teal);
  border-color: rgba(65, 199, 183, 0.25);
  background: var(--teal-soft);
}

.ghost:hover {
  color: #071210;
  border-color: transparent;
  background: var(--teal);
}

.danger {
  color: var(--rose);
  border-color: rgba(226, 109, 106, 0.25);
  background: var(--rose-soft);
}

.danger:hover {
  color: #170807;
  background: var(--rose);
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.topbar,
.topbar-actions,
.panel-head,
.preview-info,
.preview-actions {
  display: flex;
  align-items: center;
}

.topbar,
.preview-info {
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 32px;
}

.topbar-actions,
.preview-actions {
  flex-wrap: wrap;
  gap: 9px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.upload-button input {
  display: none;
}

.stats-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  gap: 12px;
}

.stats-row article {
  display: grid;
  gap: 5px;
  padding: 13px;
  box-shadow: none;
}

.stats-row span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stats-row strong {
  overflow-wrap: anywhere;
  font-size: 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.vault-panel,
.preview-panel {
  display: grid;
  min-height: 0;
  overflow: hidden;
}

.vault-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.search-field {
  width: 100%;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 92px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #101618;
  text-align: center;
}

.drop-zone.is-over {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.file-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.file-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  color: var(--ink);
  background: var(--panel-2);
  text-align: left;
}

.file-card:hover,
.file-card.is-active {
  border-color: var(--teal);
  background: #203135;
}

.file-card strong {
  overflow-wrap: anywhere;
  font-size: 15px;
}

.file-card span,
.file-card small {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.empty-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #111719;
}

.preview-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.preview-info {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.preview-info h3 {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 25px;
}

.frame-shell {
  position: relative;
  min-height: 0;
  background: var(--panel-3);
}

iframe {
  width: 100%;
  height: 100%;
  min-height: 560px;
  border: 0;
  background: #0d0f10;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-3);
}

.empty-preview h3 {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(380px, calc(100vw - 44px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: #101618;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 1120px) {
  .app-shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .file-list {
    max-height: 420px;
  }
}

@media (max-width: 680px) {
  .side-panel,
  .workspace {
    padding: 16px;
  }

  .topbar,
  .preview-info {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .preview-actions {
    align-items: stretch;
  }

  .topbar-actions button,
  .topbar-actions label,
  .preview-actions button {
    flex: 1 1 150px;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .brand h1,
  .topbar h2 {
    font-size: 28px;
  }
}
