:root {
  --bg: #f8f7f4;
  --card: #ffffff;
  --ink: #171717;
  --muted: #4b4b4b;
  --accent: #1f7ae0;
  --accent-soft: rgba(31, 122, 224, 0.08);
  --ring: rgba(31, 122, 224, 0.12);
  --border: #e6e4df;
  --shadow: 0 18px 40px rgba(23, 23, 23, 0.08);
  color-scheme: light;
}

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px 100px 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand {
  font-family: 'Playfair Display', 'Inter', serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  font-size: 14px;
  color: var(--muted);
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
  align-items: center;
  padding: 16px 0 12px;
}

.hero-copy h1 {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: clamp(32px, 4vw, 48px);
  margin: 8px 0 12px;
  letter-spacing: -0.015em;
}

.hero-copy .lede {
  color: var(--muted);
  max-width: 52ch;
  margin-bottom: 18px;
  line-height: 1.55;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 999px;
  margin: 0 0 8px;
}

.google-btn,
.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.google-btn {
  background: #fff;
  color: #202124;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.07);
  border: 1.4px solid #dadce0;
  padding: 12px 22px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.google-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #4285f4, #ea4335 47%, #fbbc05 47%, #34a853);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  font-size: 12px;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.hero-visual {
  display: flex;
  justify-content: flex-end;
}

.image-stack {
  position: relative;
  width: min(520px, 90vw);
  min-height: 360px;
}

.image-frame {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.99);
  animation: fadeCycle 20s ease-in-out infinite;
  border: 1px solid var(--border);
}

.image-frame.show-at-1 { animation-delay: 0s; }
.image-frame.show-at-2 { animation-delay: 4s; }
.image-frame.show-at-3 { animation-delay: 8s; }
.image-frame.show-at-4 { animation-delay: 12s; }
.image-frame.show-at-5 { animation-delay: 16s; }

@keyframes fadeCycle {
  0% { opacity: 0; transform: translate3d(0, 18px, 0) scale(0.99); }
  5% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  20% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  25% { opacity: 0; transform: translate3d(0, -10px, 0) scale(0.99); }
  100% { opacity: 0; transform: translate3d(0, -10px, 0) scale(0.99); }
}

.table-section {
  margin-top: 48px;
}

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

.section-header h2 {
  margin: 4px 0 0;
  letter-spacing: -0.01em;
}

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

[hidden] {
  display: none !important;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.icon-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.actions-cell {
  text-align: right;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ghost-btn:hover {
  background: #fff;
  box-shadow: var(--shadow);
}

.table-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #fff, #fafafa);
  z-index: 1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

td .chip {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}

td .link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

td .link:hover {
  text-decoration: underline;
}

/* Drag and drop styles */
.drag-handle {
  cursor: grab;
  color: var(--muted);
  margin-right: 8px;
  user-select: none;
}

.drag-handle:hover {
  color: var(--ink);
}

tr[draggable="true"] {
  cursor: grab;
}

tr.dragging {
  opacity: 0.5;
  background: var(--accent-soft);
}

tr.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.table-lock {
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(248, 247, 244, 0.1) 0%, rgba(248, 247, 244, 0.92) 55%, rgba(248, 247, 244, 0.98) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 22px 26px;
  border-top: 1px solid var(--border);
  backdrop-filter: blur(6px);
  transition: opacity 200ms ease, visibility 200ms ease;
  pointer-events: none;
  z-index: 10;
}

.table-lock .google-btn {
  pointer-events: auto;
}

.table-lock.locked {
  opacity: 1;
  visibility: visible;
}

.table-lock.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-title {
  font-weight: 700;
  margin: 0 0 6px;
}

.lock-copy {
  margin: 0;
  color: var(--muted);
}

.table-card.locked tbody {
}

.table-card.locked .table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.admin-panel {
  margin-top: 52px;
  background: var(--card);
  border-radius: 18px;
  padding: 18px 18px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.prompt-form .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 8px 0 16px;
}

.prompt-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

.prompt-form input,
.prompt-form textarea {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  font-size: 14px;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fbfbfb;
  transition: border 150ms ease, box-shadow 150ms ease;
}

.prompt-form input:focus,
.prompt-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
  background: #fff;
}

.prompt-form textarea {
  resize: vertical;
  max-width: 100%;
  box-sizing: border-box;
}

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

.primary-btn {
  background: linear-gradient(135deg, #1f7ae0, #0f62ba);
  color: #fff;
  box-shadow: 0 12px 30px rgba(31, 122, 224, 0.35);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(31, 122, 224, 0.38);
}

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

.admin-note {
  color: var(--accent);
  font-weight: 700;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 48px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

@media (max-width: 720px) {
  .page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .table-card.locked .table-wrap {
    max-height: 360px;
  }

  .table-wrap {
    max-height: 360px;
    overflow: auto;
  }

  .table-lock {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 16px 20px;
    height: auto;
  }

  .table-lock .google-btn {
    width: 100%;
    justify-content: center;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

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

  .image-stack {
    width: 100%;
    min-height: 220px;
  }

  .image-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Skeleton loading */
.skeleton-row td {
  position: relative;
  overflow: hidden;
}

.skeleton-cell {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  height: 16px;
  display: inline-block;
}

.skeleton-cell.short {
  width: 40px;
}

.skeleton-cell.medium {
  width: 100px;
}

.skeleton-cell.long {
  width: 200px;
}

.skeleton-cell.chip {
  width: 80px;
  height: 28px;
  border-radius: 999px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Checkbox label for admin form */
.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* Prompt text truncation */
.prompt-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.prompt-text.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.see-more-btn {
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  display: none;
}

.see-more-btn:hover {
  text-decoration: underline;
}
