/* ─── Reset & Variables ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sidebar-w: 400px;
  --surface: #f6f4f0;
  --surface-warm: #eee9e2;
  --ink: #1a1715;
  --ink-soft: #6b6560;
  --ink-muted: #a09a94;
  --accent: #e8553d;
  --accent-hover: #d44a33;
  --accent-glow: rgba(232, 85, 61, .12);
  --white: #ffffff;
  --card-shadow: 0 2px 20px rgba(26,23,21,.08), 0 0 0 1px rgba(26,23,21,.04);
  --card-shadow-hover: 0 8px 40px rgba(26,23,21,.12), 0 0 0 1px rgba(26,23,21,.06);
  --radius: 14px;
  --radius-sm: 8px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --fb-blue: #1877f2;
  --fb-bg: #f0f2f5;
  --fb-text: #050505;
  --fb-secondary: #65676b;
  --fb-link: #0064d1;
  --fb-separator: #ced0d4;
}

html { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* ─── Logo ─── */
.logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

/* ─── Topbar icon button (shared header) ─── */
.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color .15s;
}

.topbar-icon-btn:hover {
  color: var(--ink);
}

/* ─── Back button ─── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 6px 12px 6px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  margin-bottom: 24px;
  border: none;
  background: none;
  cursor: pointer;
}

.back-btn:hover {
  color: var(--ink);
  background: var(--surface-warm);
}

.back-btn svg {
  flex-shrink: 0;
  transition: transform .15s;
}

.back-btn:hover svg {
  transform: translateX(-2px);
}

/* Dark back button (for sidebar) */
.back-btn-dark {
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.back-btn-dark:hover {
  color: var(--surface);
  background: rgba(255,255,255,.08);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: var(--surface);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  z-index: 200;
  transition: transform .3s ease;
  white-space: nowrap;
}

.toast.visible { transform: translateX(-50%) translateY(0); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,21,.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(10px) scale(.97);
  transition: transform .25s;
}

.modal-overlay.visible .modal {
  transform: none;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

.modal-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface-warm);
}

.modal-toggle:last-of-type { border-bottom: none; }

.modal-toggle-label {
  font-size: 14px;
  font-weight: 500;
}

.modal-toggle-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-warm);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .2s;
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.modal-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-link-text {
  flex: 1;
  font-size: 13px;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.4;
}

.btn-copy-icon {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, background .2s;
}

.btn-copy-icon:hover {
  color: var(--ink);
  background: var(--border);
}

.share-link-item { margin-bottom: 10px; }

.share-link-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.share-link-empty {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  padding: 16px 0;
  line-height: 1.5;
}

.btn-modal {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
}

.btn-modal-secondary {
  background: var(--surface);
  color: var(--ink);
}

.btn-modal-secondary:hover { background: var(--surface-warm); }

.btn-modal-primary {
  background: var(--accent);
  color: white;
}

.btn-modal-primary:hover { background: var(--accent-hover); }
.btn-modal-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Ad Type Selector (modal) ─── */
.ad-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.ad-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: center;
}

.ad-type-option:hover {
  border-color: var(--ink-soft);
}

.ad-type-option.active {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.ad-type-icon {
  color: var(--ink-soft);
  display: flex;
}

.ad-type-option.active .ad-type-icon {
  color: var(--accent);
}

.ad-type-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.ad-type-desc {
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* Modal form fields (light theme) */
.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.modal-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--surface-warm);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color .2s;
}

.modal-field input:focus {
  border-color: var(--accent);
}

.modal-logo-upload {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-logo-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-muted);
}

.modal-logo-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-logo-btn {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.modal-logo-btn:hover { text-decoration: underline; }
