:root {
  --bg: #0b0a17;
  --bg-panel: #14122a;
  --ink: #f1eefa;
  --ink-dim: #a9a3c4;
  --pink: #ff3ea0;
  --violet: #8b5cf6;
  --green: #39ff9e;
  --line: #2a2650;
  --radius: 14px;
  --font-display: 'Baloo 2', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  color-scheme: dark;
  overflow-wrap: break-word;
}

main { max-width: 780px; margin: 0 auto; padding: 0 20px 80px; }

h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 0 0 6px; }

a { color: inherit; }

/* --- header --- */
.site-header {
  max-width: 780px;
  margin: 0 auto;
  padding: 22px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; gap: 4px; text-decoration: none; }

/* --- search bar --- */
.search-bar {
  max-width: 780px;
  margin: 0 auto;
  padding: 4px 20px 18px;
  display: flex;
  gap: 8px;
}
.search-bar input[type="text"] {
  flex: 1;
  min-width: 0;
}

/* --- bead motif --- */
.bead {
  --bead-color: var(--pink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bead-color);
  color: #0b0a17;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18), 0 0 14px color-mix(in srgb, var(--bead-color) 55%, transparent);
}
.bead-lg { width: 46px; height: 46px; font-size: 1.3rem; }

.bead-string {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  justify-content: center;
}

/* --- hero --- */
.hero {
  padding: 56px 0 36px;
  text-align: center;
}
.hero-sub {
  max-width: 46ch;
  margin: 22px auto 0;
  color: var(--ink-dim);
  font-size: 1.02rem;
}

/* --- panels / forms --- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  margin-bottom: 22px;
}
.panel-sub { color: var(--ink-dim); font-size: 0.94rem; margin: 0 0 18px; }

/* --- collapsible sections (native <details>, custom chevron) --- */
.collapsible {
  transition: background 0.2s, border-color 0.2s;
}
.collapsible summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary h2 { margin: 0; transition: color 0.15s; }
.collapsible[open] summary:hover h2 { color: var(--violet); }
.collapsible summary:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 4px;
  border-radius: 4px;
}
.collapsible-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-dim);
  border-bottom: 2px solid var(--ink-dim);
  transform: rotate(45deg);
  transition: transform 0.15s ease, border-color 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
}
.collapsible[open] .collapsible-chevron { transform: rotate(-135deg); }
.collapsible-body { padding-top: 18px; }

/* Collapsed: same gradient as the primary action buttons (e.g. "add to the
   string"), so these read as inviting calls-to-action rather than dead
   space. Expanded: reverts to the normal dark panel look. */
.collapsible:not([open]) {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  border-color: transparent;
}
.collapsible:not([open]):hover { filter: brightness(1.08); }
.collapsible:not([open]) summary h2 { color: #0b0a17; }
.collapsible:not([open]) .collapsible-chevron {
  border-color: #0b0a17;
}

/* Danger variant (e.g. "Delete this kandi") — deliberately does NOT get the
   inviting gradient treatment other collapsed boxes get, since this one
   shouldn't read as a friendly call-to-action. */
.collapsible.danger:not([open]) {
  background: var(--bg-panel);
  border-color: #ef4444;
}
.collapsible.danger:not([open]) summary h2 { color: #ef4444; }
.collapsible.danger:not([open]) .collapsible-chevron { border-color: #ef4444; }
.collapsible.danger:not([open]):hover { filter: none; border-color: #f87171; }

.about-body h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 20px 0 8px;
}
.about-body h3:first-of-type { margin-top: 0; color: var(--pink); }
.about-body h3:last-of-type { color: var(--violet); }
.about-body p {
  color: var(--ink-dim);
  margin: 0 0 4px;
}

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--ink-dim);
}
.stack-form .opt { font-weight: 400; opacity: 0.7; }

.stack-form fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 16px 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stack-form legend {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  padding: 0 8px;
}
.stack-form fieldset:first-of-type { border-color: var(--pink); }
.stack-form fieldset:first-of-type legend { color: var(--pink); }
.stack-form fieldset:last-of-type { border-color: var(--violet); }
.stack-form fieldset:last-of-type legend { color: var(--violet); }

.req { color: var(--green); margin-left: 2px; }

.field-hint {
  font-size: 0.78rem;
  color: var(--ink-dim);
  opacity: 0.75;
  margin: 0;
  font-weight: 400;
}

.privacy-note {
  font-size: 0.82rem;
  color: var(--ink-dim);
  background: #0f0d20;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 0;
}

select {
  background: #0f0d20;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.96rem;
}

.color-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-picker-row input[type="color"] {
  width: 40px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0d20;
  cursor: pointer;
}
.color-picker-row input[type="text"] { flex: 1; }

.emoji-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.emoji-preview {
  font-size: 1.3rem;
  min-width: 1.6em;
}
.emoji-popover {
  position: relative;
  z-index: 20;
  margin-top: 4px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  width: 100%;
  max-width: 320px;
}
.emoji-picker-el {
  --background: #14122a;
  --border-color: #2a2650;
  --input-border-color: #2a2650;
  --indicator-color: var(--pink);
  --outline-color: var(--violet);
  --category-font-color: var(--ink-dim);
  width: 100%;
  height: 320px;
}

.id-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #0f0d20;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.id-preview-row .field-hint { display: block; margin-bottom: 2px; }
#id-preview { font-size: 1rem; }

.kandi-profile-link, .kandi-set {
  font-size: 0.86rem;
  color: var(--ink-dim);
  margin: 0 0 4px;
}
.kandi-profile-link a { color: var(--green); text-decoration: none; }
.kandi-profile-link a:hover { text-decoration: underline; }
.kandi-subtitle {
  color: var(--ink-dim);
  font-size: 0.92rem;
  margin: 0 0 10px;
}
.kandi-title {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 6px 0 2px;
  font-size: 1rem;
}

input[type="text"], input[type="file"], input[type="date"], textarea {
  background: #0f0d20;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.96rem;
}
input[type="text"]:focus, textarea:focus {
  outline: 2px solid var(--violet);
  outline-offset: 1px;
}
textarea { resize: vertical; }

/* Native <input type="file"> renders very inconsistently on mobile browsers
   (its internal button+filename layout often ignores container width and
   can overflow the screen). Instead: keep the real input, but make it an
   invisible full-size overlay on top of a normal styled button, so it's
   always exactly as wide as its container regardless of native rendering. */
.file-input-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  overflow: hidden;
}
.file-input-name {
  font-size: 0.82rem;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55vw;
}
.file-input-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: #0b0a17;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--violet); }
.btn-small { align-self: flex-start; padding: 7px 14px; font-size: 0.82rem; }
.btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.12); }

/* --- recent grid --- */
.kandi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.kandi-card {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #0f0d20;
  display: block;
  transition: border-color 0.15s;
}
.kandi-card:hover { border-color: var(--violet); }
.kandi-thumb { aspect-ratio: 1; background: #191634; }
.kandi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kandi-thumb-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim); font-size: 0.78rem;
}
.kandi-card-body { padding: 10px 12px 14px; }
.kandi-hash {
  font-family: var(--font-display);
  color: var(--green);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.kandi-hash-lg { font-size: 1.1rem; }
.kandi-maker { margin: 6px 0 2px; font-size: 0.86rem; color: var(--ink-dim); }
.kandi-stops { margin: 0; font-size: 0.78rem; color: var(--ink-dim); opacity: 0.75; }
.empty-state { color: var(--ink-dim); }

/* --- kandi detail header --- */
.kandi-header { padding: 40px 0 8px; }
.kandi-desc { color: var(--ink-dim); }
.kandi-meta { font-size: 0.84rem; color: var(--ink-dim); opacity: 0.8; }

.share-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.qr-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.qr-preview {
  display: block;
  width: 120px;
  height: 120px;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

/* --- map --- */
.map { height: 340px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }

/* --- timeline (bead string, vertical) --- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 6px;
  border-left: 2px solid var(--line);
}
.timeline-item {
  position: relative;
  padding: 0 0 34px 46px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-bead {
  --bead-color: var(--violet);
  position: absolute;
  left: -21px;
  top: -12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bead-color);
  box-shadow: 0 0 0 5px var(--bg-panel), 0 0 14px color-mix(in srgb, var(--bead-color) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}
.timeline-photo {
  width: 100%;
  max-width: 280px;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}
.timeline-headline { margin: 0 0 2px; }
.timeline-note { margin: 0 0 4px; color: var(--ink-dim); }
.timeline-meta { margin: 0; font-size: 0.78rem; color: var(--ink-dim); opacity: 0.75; }
.timeline-delete-btn {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 0.72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  opacity: 0.55;
}
.timeline-delete-btn:hover { opacity: 1; color: #ef4444; }

/* --- footer --- */
.site-footer {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.8rem;
  padding: 20px;
  opacity: 0.7;
}
.contact-line { margin-top: 4px; }
.contact-line a { color: var(--green); }

.not-found { text-align: center; padding: 60px 24px; }
.not-found code { color: var(--green); }
.not-found-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* --- people directory --- */
.people-list {
  display: grid;
  gap: 14px;
}
.person-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  background: #0f0d20;
}
.person-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 8px;
}
.person-activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
}
.person-activity a { color: var(--green); text-decoration: none; }
.person-activity a:hover { text-decoration: underline; }
.person-activity-meta { color: var(--ink-dim); }

/* --- reserved codes (admin) --- */
.reserved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.reserved-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #0f0d20;
}
.reserved-note {
  color: var(--ink-dim);
  font-size: 0.85rem;
}
.reserved-status {
  margin-left: auto;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reserved-status.waiting { color: var(--ink-dim); }
.reserved-status.claimed { color: var(--green); }
.reserved-status.claimed a { color: var(--green); }

@media (max-width: 480px) {
  .bead-lg { width: 38px; height: 38px; font-size: 1.05rem; }
  .panel { padding: 20px 16px; }
}
