/* ---------------------------------------------------------------
   Muse Console — design tokens
   Plain, solid-surface dashboard look: white/near-black canvas, thin
   hairline borders instead of blur, a persistent left sidebar, pill
   buttons kept for their tactile roundness.
------------------------------------------------------------------ */

:root {
  --accent: #007AFF;
  --accent-rgb: 0, 122, 255;
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;

  --bg-canvas: #ffffff;
  --bg-sidebar: #fafafa;
  --surface: #ffffff;
  --surface-hover: rgba(0, 0, 0, 0.04);
  --text-primary: #1c1c1e;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.32);

  --border: rgba(0, 0, 0, 0.1);
  --hairline: rgba(60, 60, 67, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);

  --radius-card: 10px;
  --radius-alert: 16px;
  --radius-pill: 999px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0A84FF;
    --bg-canvas: #000000;
    --bg-sidebar: #111113;
    --surface: #1a1a1c;
    --surface-hover: rgba(255, 255, 255, 0.06);
    --text-primary: #f2f2f7;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --text-tertiary: rgba(235, 235, 245, 0.32);
    --border: rgba(255, 255, 255, 0.1);
    --hairline: rgba(255, 255, 255, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --accent: #007AFF;
  --bg-canvas: #ffffff;
  --bg-sidebar: #fafafa;
  --surface: #ffffff;
  --surface-hover: rgba(0, 0, 0, 0.04);
  --text-primary: #1c1c1e;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.32);
  --border: rgba(0, 0, 0, 0.1);
  --hairline: rgba(60, 60, 67, 0.13);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --accent: #0A84FF;
  --bg-canvas: #000000;
  --bg-sidebar: #111113;
  --surface: #1a1a1c;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --text-primary: #f2f2f7;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-tertiary: rgba(235, 235, 245, 0.32);
  --border: rgba(255, 255, 255, 0.1);
  --hairline: rgba(255, 255, 255, 0.1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-canvas);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }

button { font: inherit; color: inherit; }

/* ---------------- Surfaces (cards, panels, dropdowns) ---------------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.glass-strong {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:active { opacity: 0.85; }

.btn-prominent {
  background: var(--accent);
  color: #fff;
}
.btn-prominent:hover { opacity: 0.9; }

.btn-glass {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-glass:hover { background: var(--surface-hover); }

.btn-plain {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
}

.btn-destructive { color: var(--red); background: transparent; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: none;
}
.btn-icon:hover { background: rgba(120, 120, 128, 0.22); }
.btn-icon.danger:hover { color: var(--red); }

.btn-icon-sm {
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-hover); color: var(--text-secondary);
  border: none; cursor: pointer; flex: none;
}
.btn-icon-sm .icon { width: 12px; height: 12px; }
.btn-icon-sm:hover { background: rgba(120, 120, 128, 0.24); }
.btn-icon-sm.save:hover { background: var(--green); color: #fff; }
.btn-icon-sm.cancel:hover { background: var(--red); color: #fff; }

.name-edit-input {
  font: inherit; font-size: 15.5px; font-weight: 700; color: var(--text-primary);
  background: rgba(120, 120, 128, 0.1);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 3px 8px; max-width: 220px;
}

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease;
  resize: none;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
}
input.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; letter-spacing: 0.02em; }
::placeholder { color: var(--text-tertiary); }

.label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}
.label-optional { text-transform: none; font-weight: 500; color: var(--text-tertiary); letter-spacing: 0; }

/* ---------------- App shell (sidebar + main area) ---------------- */

#app { min-height: 100%; display: flex; flex-direction: column; }

.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; }

#app-shell {
  display: none; /* toggled to 'flex' by JS once signed in */
  flex: 1;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  transition: width 0.15s ease;
}

/* Collapsed sidebar is a desktop-only concept — on the mobile layout below,
   the sidebar becomes a horizontal top bar and always shows full labels,
   so this is scoped out of that breakpoint entirely rather than competing
   with it on specificity. */
@media (min-width: 861px) {
  .sidebar.collapsed { width: 64px; }
  .sidebar.collapsed .sidebar-brand { justify-content: center; padding: 8px; }
  .sidebar.collapsed .nav-item { justify-content: center; }
  .sidebar.collapsed .sidebar-account .account-btn { justify-content: center; }
  .sidebar.collapsed .sidebar-brand span:not(.mark),
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .account-meta,
  .sidebar.collapsed .account-chevron {
    display: none;
  }
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 16px;
  font-weight: 700; font-size: 15px;
}
.sidebar-brand .mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer;
}
.nav-item .icon { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); }

.sidebar-spacer { flex: 1; }

.sidebar-account {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
  position: relative;
}
.sidebar-account .account-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 6px 8px;
  border-radius: 8px;
}
.sidebar-account .account-btn:hover { background: var(--surface-hover); }
.sidebar-account .account-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
}
.sidebar-account .account-name {
  font-size: 13.5px; font-weight: 600;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-account .account-role { font-size: 11.5px; color: var(--text-secondary); }
.sidebar-account .account-dropdown {
  left: 0; right: 0; top: auto; bottom: 54px; min-width: 0;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.page-header {
  display: none; /* toggled by JS when there are breadcrumbs to show */
  align-items: center;
  gap: 6px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.page-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); flex-wrap: wrap; }
.crumbs .crumb-link { color: var(--accent); cursor: pointer; font-weight: 600; }
.crumbs .crumb-current { color: var(--text-primary); font-weight: 700; }
.crumbs .sep { opacity: 0.5; }

.account-menu-wrap { position: relative; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--surface-hover);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.account-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: none; cursor: pointer; padding: 4px; }
.account-dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 220px;
  padding: 8px;
  z-index: 30;
  display: none;
  border-radius: var(--radius-card);
}
.account-dropdown.open { display: block; }
.account-dropdown .who { padding: 10px 12px; }
.account-dropdown .who .n { font-weight: 700; font-size: 14px; }
.account-dropdown .who .e { font-size: 12px; color: var(--text-secondary); }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer; font-size: 14px;
}
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item.danger { color: var(--red); }
.dropdown-divider { height: 1px; background: var(--hairline); margin: 6px 4px; }

.content { flex: 1; padding: 28px 28px 48px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------------- Sign in ---------------- */

.signin-view { align-items: center; justify-content: center; min-height: 100vh; }
.signin-card {
  width: min(380px, 92vw);
  padding: 40px 32px 32px;
  text-align: center;
  border-radius: var(--radius-alert);
}
.signin-mark {
  width: 60px; height: 60px; border-radius: 16px;
  margin: 0 auto 18px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; font-weight: 700;
}
.signin-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.signin-sub { font-size: 14px; color: var(--text-secondary); margin: 0 0 28px; line-height: 1.4; }
.apple-btn {
  width: 100%; background: #000; color: #fff; border-radius: 10px;
  padding: 13px; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer;
}
@media (prefers-color-scheme: dark) {
  .apple-btn { background: #fff; color: #000; }
}
.signin-foot { margin-top: 18px; font-size: 12px; color: var(--text-tertiary); }

.ck-auth-button {
  display: none;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  /* CloudKit renders its own "Sign in with Apple ID" button in here (likely
     an iframe) — we can't restyle its internals (font, exact padding,
     corner radius) from this page, but clipping + rounding the container
     at least keeps its corners visually consistent with the rest of the
     card. Give it a touch more height than the button itself needs so its
     text doesn't render cramped against the container edge. */
  overflow: hidden;
  border-radius: 10px;
}
.ck-auth-button.visible { display: flex; }
.ck-auth-button iframe { display: block; }

.demo-banner {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--orange);
  background: rgba(255, 149, 0, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.4;
}

/* ---------------- Loading / error states ---------------- */

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 20px; color: var(--text-secondary);
  grid-column: 1 / -1; width: 100%;
}
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(120, 120, 128, 0.22);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state.is-error .icon { color: var(--orange); }
.empty-state .es-retry { margin-top: 6px; }


/* ---------------- Section heading / search ---------------- */

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 0 0 20px; flex-wrap: wrap;
}
.section-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.section-actions { display: flex; align-items: center; gap: 10px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-pill);
  width: 240px; max-width: 60vw;
}
.search-box input { background: transparent; border: none; padding: 0; font-size: 14px; }
.search-box .icon { color: var(--text-tertiary); }

.user-filter-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-primary);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  background-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 9px 34px 9px 16px;
  cursor: pointer;
}
.user-filter-select:focus { outline: none; border-color: var(--accent); }

/* ---------------- Cards / grids ---------------- */

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

.card {
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 148px;
}
.card:hover { border-color: rgba(var(--accent-rgb), 0.4); box-shadow: var(--shadow-raised); }
.card .card-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: rgba(var(--accent-rgb), 0.12); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.card .card-title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.card .card-sub { font-size: 12.5px; color: var(--text-secondary); line-height: 1.35; }
.card .card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.badge {
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  padding: 4px 9px; border-radius: var(--radius-pill);
}

.hunt-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; cursor: pointer; margin-bottom: 8px;
  transition: border-color 0.15s ease;
}
.hunt-row:hover { border-color: rgba(var(--accent-rgb), 0.4); }
.hr-icon {
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  background: rgba(var(--accent-rgb), 0.12); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.hr-body { flex: 1; min-width: 0; }
.hr-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.hr-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hunt-row .hr-meta { flex: none; display: flex; align-items: center; gap: 12px; }
.hunt-row .hr-count { font-size: 12.5px; color: var(--text-tertiary); }

/* ---- Folders (All Hunts screen) ---- */

.folder-group { margin-bottom: 18px; }
.folder-group:last-child { margin-bottom: 0; }

.folder-header {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 6px; margin-bottom: 8px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-primary);
}
.folder-header:hover { color: var(--accent); }
.folder-header .icon { width: 16px; height: 16px; color: var(--text-tertiary); flex: none; }
.folder-header:hover .icon { color: var(--accent); }
.folder-name { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.folder-count {
  font-size: 11.5px; font-weight: 700; color: var(--text-tertiary);
  background: var(--surface-hover); padding: 2px 8px; border-radius: var(--radius-pill);
}
.folder-chevron { margin-left: auto; color: var(--text-tertiary); transition: transform 0.15s ease; flex: none; }
.folder-group.collapsed .folder-chevron { transform: rotate(-90deg); }
.folder-group.collapsed .folder-hunts { display: none; }

.folder-empty-hint {
  font-size: 13px; color: var(--text-tertiary); font-style: italic;
  padding: 10px 6px;
}

/* Groups an "All Venues" view of the hunts list into one section per
   venue, each with its own folder groups and its own Add Folder button —
   folders belong to exactly one venue, so there's no single button that
   could add one without knowing which venue it's for. */
.venue-section { margin-bottom: 28px; }
.venue-section:last-child { margin-bottom: 0; }
.venue-section-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.venue-section-name { font-size: 16px; font-weight: 700; }
.venue-add-folder { font-size: 12.5px; padding: 6px 12px; }

/* Venue switcher at the top of the All Hunts screen — sized to its
   content rather than the full-width default .folder-select gets in the
   hunt editor. */
.venue-filter-select { width: auto; min-width: 150px; }

/* Inline "new folder name" row shown by the Add Folder button — same
   shape as .folder-header so it slots in above the other groups. */
.folder-header-creating {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; margin-bottom: 8px;
}
.folder-header-creating .icon { width: 16px; height: 16px; color: var(--text-tertiary); flex: none; }
.folder-header-creating .name-edit-input { flex: 1; max-width: 280px; }

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

/* Reuses .venue-picker's look (custom chevron, appearance:none) for the
   Folder field in the hunt editor and the per-row "move to folder" picker. */
.folder-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  font: inherit; font-size: 14.5px; color: var(--text-primary);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 30px 10px 12px;
  cursor: pointer;
}
.folder-select:focus { border-color: var(--accent); outline: none; }
.folder-select-sm {
  width: auto; max-width: 150px;
  font-size: 12.5px; padding: 6px 26px 6px 10px; border-radius: 8px;
}

/* ---- Users page (admin) ---- */

.user-card {
  padding: 16px 18px;
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.user-card-head { display: flex; align-items: center; gap: 14px; }

.user-venue-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 58px; }
.user-venue-chips-empty { font-size: 12.5px; color: var(--text-tertiary); }
.venue-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-primary);
  background: var(--surface-hover);
  padding: 5px 6px 5px 12px; border-radius: var(--radius-pill);
}
.chip-remove {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(120, 120, 128, 0.18); color: var(--text-secondary);
  border: none; cursor: pointer; padding: 0;
}
.chip-remove:hover { background: var(--red); color: #fff; }
.chip-remove .icon { width: 10px; height: 10px; }

.user-assign-row { display: flex; gap: 8px; padding-left: 58px; }
.venue-picker {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  flex: 1; max-width: 280px;
  font: inherit; font-size: 13.5px; color: var(--text-primary);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 30px 8px 10px;
  cursor: pointer;
}
.venue-picker:focus { border-color: var(--accent); outline: none; }

.user-id-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.user-id-value {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 11px; color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 80px 20px; color: var(--text-secondary);
  gap: 8px;
}
.empty-state .icon { width: 40px; height: 40px; color: var(--text-tertiary); margin-bottom: 6px; }
.empty-state .es-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.empty-state .es-desc { font-size: 14px; max-width: 320px; line-height: 1.4; }

/* ---------------- Hunt editor ---------------- */

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .editor-grid { grid-template-columns: 1fr; }
  .preview-col { order: -1; }
}

.editor-col { display: flex; flex-direction: column; gap: 16px; }

.panel { padding: 20px; }
.panel + .panel { margin-top: 0; }
.panel-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
textarea.hunt-desc { min-height: 64px; }

/* ---- Settings: appearance / layout ---- */

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.segmented-control button {
  font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: none; border-right: 1px solid var(--border);
  padding: 8px 18px; cursor: pointer;
}
.segmented-control button:last-child { border-right: none; }
.segmented-control button:hover:not(.active) { background: var(--surface-hover); }
.segmented-control button.active { background: var(--accent); color: #fff; }

.settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.settings-desc { font-size: 12.5px; color: var(--text-tertiary); }

.toggle-switch {
  width: 42px; height: 25px; border-radius: 999px; flex: none;
  background: var(--surface-hover); border: 1px solid var(--border);
  position: relative; cursor: pointer; padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.toggle-switch::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.toggle-switch.on { background: var(--accent); border-color: var(--accent); }
.toggle-switch.on::after { transform: translateX(17px); }

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

.clue-row {
  border-radius: 10px;
  background: var(--surface-hover);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.clue-row.dragging { opacity: 0.4; }
.clue-row.drag-over { border-color: var(--accent); }

.clue-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px;
  cursor: pointer;
}
.clue-handle { cursor: grab; color: var(--text-tertiary); flex: none; touch-action: none; }
.clue-handle:active { cursor: grabbing; }
.clue-order {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.clue-summary-body { flex: 1; min-width: 0; }
.clue-summary-title { font-size: 14.5px; font-weight: 600; }
.clue-summary-body-text { font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.clue-chevron { flex: none; color: var(--text-tertiary); transition: transform 0.2s ease; }
.clue-row.expanded .clue-chevron { transform: rotate(90deg); }

.clue-detail { display: none; padding: 0 16px 16px 46px; flex-direction: column; gap: 12px; }
.clue-row.expanded .clue-detail { display: flex; }

.clue-detail-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---- Tag fulfillment status ---- */

.status-badge {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 11.5px; font-weight: 700;
  padding: 4px 9px; border-radius: var(--radius-pill);
  white-space: nowrap;
}
.status-badge .icon { width: 12px; height: 12px; }
.status-pending { background: var(--surface-hover); color: var(--text-secondary); }
.status-requested { background: rgba(255, 149, 0, 0.14); color: var(--orange); }
.status-installed { background: rgba(52, 199, 89, 0.14); color: var(--green); }
.status-admin { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); font-size: 13px; vertical-align: middle; margin-left: 8px; }
.status-manager { background: rgba(255, 149, 0, 0.14); color: var(--orange); font-size: 13px; vertical-align: middle; margin-left: 8px; }
.status-appuser { background: var(--surface-hover); color: var(--text-secondary); font-size: 13px; vertical-align: middle; margin-left: 8px; }

.tag-display-row { display: flex; align-items: center; gap: 8px; }
.clue-tag-code {
  flex: 1;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  padding: 10px 12px;
  background: var(--surface-hover);
  border-radius: 8px;
  word-break: break-all;
  color: var(--text-primary);
}
.tag-hint { font-size: 12px; color: var(--text-tertiary); line-height: 1.4; margin: 0; }
.tag-status-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-top: 2px;
}
.tag-status-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.add-clue-btn {
  width: 100%; justify-content: center;
  border: 1.5px dashed rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--accent);
  border-radius: 10px;
  padding: 13px;
}
.add-clue-btn:hover { background: rgba(var(--accent-rgb), 0.1); }

.editor-footer {
  position: sticky; bottom: 16px;
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; margin-top: 6px;
}

/* ---------------- Preview phone ---------------- */

.preview-col { position: sticky; top: 16px; }
.phone-frame {
  border-radius: 34px;
  padding: 14px;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  aspect-ratio: 9 / 18.5;
  display: flex; flex-direction: column;
  background: var(--surface);
}
.phone-notch { width: 90px; height: 20px; border-radius: 12px; background: var(--surface-hover); margin: 0 auto 10px; }
.phone-title { text-align: center; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); margin-bottom: 10px; }

.pv-progress { padding: 0 4px 10px; }
.pv-progress-label { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.pv-bars { display: flex; gap: 4px; }
.pv-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-hover); }
.pv-bar.current { background: var(--accent); }
.pv-bar.done { background: rgba(var(--accent-rgb), 0.35); }

.pv-card {
  flex: 1;
  border-radius: 18px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px;
}
.pv-card-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--text-secondary); margin-bottom: 10px; }
.pv-card-body { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 15px; font-weight: 600; line-height: 1.35; padding: 6px; }
.pv-card-body.placeholder { color: var(--text-tertiary); font-weight: 500; font-size: 13px; }

.pv-footer-btn {
  margin-top: 10px; text-align: center; padding: 10px;
  border-radius: var(--radius-pill);
  background: var(--accent); color: #fff;
  font-size: 12.5px; font-weight: 700;
}

/* ---------------- Alert overlay ---------------- */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.32);
}
.overlay.open { display: flex; }
.overlay-scrim { position: absolute; inset: 0; }
.alert-card {
  position: relative;
  width: min(340px, 100%);
  padding: 30px 30px 24px;
  border-radius: var(--radius-alert);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: pop-in 0.16s ease-out;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.alert-icon { width: 52px; height: 52px; }
.alert-icon.success { color: var(--green); }
.alert-icon.danger { color: var(--red); }
.alert-title { font-size: 18px; font-weight: 700; margin: 4px 0 0; }
.alert-msg { font-size: 14.5px; color: var(--text-secondary); line-height: 1.4; margin: 0; }
.alert-actions { display: flex; gap: 10px; margin-top: 14px; width: 100%; }
.alert-actions .btn { flex: 1; justify-content: center; }
.alert-tap-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 110;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s ease-out, opacity 0.18s ease-out;
  padding: 12px 20px; border-radius: var(--radius-pill);
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { color: var(--green); }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  #app-shell.open, #app-shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 8px 12px;
  }
  .sidebar-brand { padding: 6px 10px; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-spacer { display: none; }
  .sidebar-account { border-top: none; margin-top: 0; padding-top: 0; margin-left: auto; }
  .sidebar-account .account-dropdown { bottom: auto; top: 44px; right: 0; left: auto; width: 220px; }
  .main-area { height: auto; }
  .page-content { overflow-y: visible; }
}

@media (max-width: 620px) {
  .content { padding: 20px 16px 40px; }
  .page-header { padding: 12px 16px; }
  .section-title { font-size: 20px; }
}
