:root {
  --cream-50: #fbf8f1;
  --cream-100: #f6efe3;
  --cream-200: #efe4d2;
  --sage-100: #dfe7d9;
  --sage-300: #b7c2b1;
  --sage-500: #7f8f82;
  --sage-700: #5f6d63;
  --ink-900: #1d1f1a;
  --ink-700: #3d433a;
  --ink-500: #5c6559;
  --accent: #c39162;
  --accent-strong: #a87346;
  --border: rgba(55, 60, 50, 0.18);
  --shadow: 0 28px 60px rgba(30, 33, 27, 0.14);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  color: var(--ink-900);
  background: var(--cream-50);
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(209, 184, 150, 0.35), transparent 42%),
    radial-gradient(circle at 80% 20%, rgba(178, 196, 175, 0.32), transparent 40%),
    radial-gradient(circle at 75% 85%, rgba(210, 170, 125, 0.25), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--cream-200), var(--cream-100));
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--sage-500);
  color: var(--cream-50);
  display: grid;
  place-items: center;
  font-family: 'Fraunces', serif;
  font-size: 18px;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: left;
  color: var(--ink-700);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.6);
}

.nav-item.active {
  background: var(--sage-100);
  border-color: rgba(95, 109, 99, 0.3);
  color: var(--ink-900);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.token-status {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-500);
}

.token-value {
  font-weight: 600;
  color: var(--ink-700);
}

.main {
  padding: 32px 40px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.topbar-title h1 {
  margin: 6px 0 4px;
  font-family: 'Fraunces', serif;
  font-size: 36px;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
  color: var(--sage-700);
}

.subtitle {
  margin: 0;
  color: var(--ink-500);
}

.btn,
.btn-primary {
  border: none;
  background: var(--accent);
  color: var(--cream-50);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(163, 119, 80, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover,
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(163, 119, 80, 0.35);
}

.btn:disabled,
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-outline,
.btn-secondary {
  background: transparent;
  color: var(--ink-700);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-outline:hover,
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.6);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.6);
}

.panel {
  margin-bottom: 24px;
  display: grid;
  gap: 18px;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

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

.split {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.card {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  animation: rise 0.5s ease both;
}

.card-header h2,
.card-header h3 {
  margin: 0 0 6px;
  font-family: 'Fraunces', serif;
}

.card-header p {
  margin: 0;
  color: var(--ink-500);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.row:hover {
  border-color: var(--sage-300);
  transform: translateY(-1px);
}

.row-title {
  font-weight: 600;
}

.row-meta {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 4px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action {
  border: 1px solid var(--border);
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-700);
}

.action:hover {
  border-color: var(--sage-300);
  background: rgba(223, 231, 217, 0.4);
}

.form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.form-group {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-700);
}

input,
textarea,
select {
  font: inherit;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
}

textarea {
  resize: vertical;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button input {
  flex: 1;
}

.preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.7);
  max-height: 400px;
  overflow: auto;
}

.preview-frame img {
  max-width: 100%;
  border-radius: 4px;
}

.preview-frame.preview-surface {
  padding: 0;
  overflow: hidden;
  max-height: none;
}

.demo-preview-shell {
  position: relative;
  min-height: 320px;
  background: rgba(246, 239, 227, 0.7);
}

.demo-preview-media {
  height: 320px;
  background: rgba(246, 239, 227, 0.7);
}

.demo-preview-media iframe,
.demo-preview-media img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

.demo-preview-banner {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  background: rgba(29, 31, 26, 0.9);
  color: var(--cream-50);
  border-radius: 999px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.demo-preview-cta {
  background: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.demo-preview-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(195, 145, 98, 0.18);
  text-transform: uppercase;
  pointer-events: none;
}

.demo-preview-footer {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink-700);
  display: grid;
  gap: 4px;
}

.demo-preview-widget {
  position: absolute;
  right: 16px;
  bottom: 80px;
  width: 120px;
  height: 160px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ink-500);
}

.scrape-summary {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 10px;
  font-size: 14px;
}

.scrape-summary ul {
  margin: 6px 0 0 16px;
  padding: 0;
}

.demo-editor {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
}

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

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-header h4 {
  margin: 0;
  font-size: 14px;
}

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

.editor-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  gap: 10px;
}

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

.row-remove {
  justify-self: start;
  border: 1px solid var(--border);
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-700);
}

.preview-divider {
  border-top: 1px solid var(--border);
  margin: 20px 0 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.text-muted {
  color: var(--ink-500);
  font-size: 14px;
}

#demo-link {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-500);
}

.data-table tbody tr:hover {
  background: rgba(223, 231, 217, 0.25);
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.select {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-700);
}

.details {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.details.empty {
  color: var(--ink-500);
  font-size: 14px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.detail {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
}

.detail label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-500);
  margin-bottom: 6px;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(127, 143, 130, 0.2);
  color: var(--sage-700);
}

.badge.accent {
  background: rgba(195, 145, 98, 0.2);
  color: var(--accent-strong);
}

.note {
  font-size: 12px;
  color: var(--ink-500);
}

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

.transcript-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
}

.transcript-item .speaker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-500);
}

.transcript-item .content {
  margin-top: 6px;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ink-900);
  color: var(--cream-50);
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.loading {
  background: var(--ink-700);
}

.toast.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(30, 33, 27, 0.4);
  z-index: 30;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(420px, 90vw);
  background: var(--cream-50);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.modal-card h2 {
  font-family: 'Fraunces', serif;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hint {
  font-size: 12px;
  color: var(--ink-500);
  min-height: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.empty {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  text-align: center;
  color: var(--ink-500);
  background: rgba(255, 255, 255, 0.5);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 220px 1fr;
  }

  .main {
    padding: 28px 28px 48px;
  }

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

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
  }

  .sidebar-footer {
    margin-top: 0;
    align-items: center;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .sidebar {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    width: 100%;
  }

  .row {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-with-button {
    flex-direction: column;
    align-items: stretch;
  }

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