:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --ink: #14141f;
  --muted: #8a8a99;
  --line: #ecedf1;
  --brand: #ff6a5f;
  --brand2: #ff8e53;
  --brand-grad: linear-gradient(135deg, #ff6a5f, #ff8e53);
  --star: #ffb400;
  --shadow: 0 6px 24px rgba(20, 20, 45, 0.07);
  --shadow-sm: 0 2px 10px rgba(20, 20, 45, 0.05);
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over display:flex labels etc. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

a { color: var(--brand); text-decoration: none; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px 110px;
}

h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.03em; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 26px 0 12px; letter-spacing: -0.02em; }

.sub { color: var(--muted); font-size: 0.95rem; margin: 0 0 18px; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  font-size: 1.5rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.04em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark .dot { color: var(--star); -webkit-text-fill-color: var(--star); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.greeting { font-size: 0.9rem; color: var(--muted); }
.greeting b { color: var(--ink); font-weight: 700; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card-list { display: flex; flex-direction: column; gap: 12px; }

/* ---------- event card ---------- */
.ev {
  background: var(--card);
  border-radius: 20px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  position: relative;
}
.ev-head {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease;
}
.ev-head:active { transform: scale(0.98); }
.ev-icon {
  width: 58px; height: 58px;
  border-radius: 16px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
  color: #fff;
  overflow: hidden;
}
.ev-icon img { width: 100%; height: 100%; object-fit: cover; }
.ev-main { flex: 1; min-width: 0; }
.ev-title {
  font-weight: 700; font-size: 1.02rem;
  overflow-wrap: anywhere;
}
.ev-sub {
  color: var(--muted); font-size: 0.85rem; margin-top: 2px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.ev-person { color: var(--ink); font-weight: 600; }
.ev-score { text-align: center; flex-shrink: 0; min-width: 46px; }
.ev-score .num { font-size: 1.35rem; font-weight: 800; line-height: 1; }
.ev-score .num.empty { color: var(--muted); font-weight: 600; font-size: 1rem; }
.ev-score .mini { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }
.ev-dot {
  position: absolute; top: 12px; right: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
}

/* ---------- stars ---------- */
.stars {
  position: relative; display: inline-block;
  font-size: 0.95rem; line-height: 1; color: #e3e3ea; vertical-align: middle;
}
.stars-under { letter-spacing: 1px; }
.stars-over {
  position: absolute; top: 0; left: 0;
  overflow: hidden; white-space: nowrap;
  color: var(--star); letter-spacing: 1px;
}
.stars-meta { color: var(--muted); font-size: 0.82rem; margin-left: 6px; }

/* ---------- star input ---------- */
.star-input {
  font-size: 2.3rem; line-height: 1; cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent; display: flex; align-items: center;
}
.star-input .si-star { padding: 2px 2px; color: #e3e3ea; }
.star-input .si-star.full { color: var(--star); }
.star-input .si-star.half {
  background: linear-gradient(90deg, var(--star) 50%, #e3e3ea 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.star-value { font-size: 0.85rem; color: var(--muted); margin-left: 10px; }

/* ---------- forms ---------- */
.form-card { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.hint { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
input, select, textarea {
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fbfbfd;
  width: 100%;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); background: #fff;
}
input[type="file"] { padding: 9px 12px; }
textarea { resize: vertical; }
fieldset.rate-now {
  border: 1.5px dashed var(--line); border-radius: 15px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; margin: 0;
}
fieldset.rate-now legend { font-weight: 700; font-size: 0.9rem; padding: 0 6px; }

.btn {
  display: inline-block; font: inherit; font-weight: 700; font-size: 1rem;
  border: none; border-radius: 14px; padding: 14px 20px; cursor: pointer;
  text-align: center; color: #fff; background: var(--brand-grad);
  box-shadow: 0 6px 16px rgba(255, 106, 95, 0.32);
}
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: #f0f0f4; color: var(--ink); box-shadow: none;
}
.linkish {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 0.88rem; padding: 0; text-decoration: underline;
}
.linkish.danger { color: var(--brand); }

.error {
  background: #fff0ef; border: 1px solid #ffd4cf; color: #c0392b;
  border-radius: 13px; padding: 12px 14px; margin-bottom: 14px; font-size: 0.92rem;
}
.notice {
  background: #eafaf0; border: 1px solid #c3ecd2; color: #1e8449;
  border-radius: 13px; padding: 12px 14px; margin-bottom: 14px; font-size: 0.92rem;
}

/* ---------- title autosuggest ---------- */
.suggest {
  margin-top: -8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.suggest-head {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--muted); padding: 9px 13px; background: #fafafb;
  text-transform: uppercase;
}
.suggest-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.suggest-item:active { background: #f6f6f9; }
.suggest-emoji { font-size: 1.3rem; flex-shrink: 0; }
.suggest-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.suggest-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.suggest-sub { font-size: 0.78rem; color: var(--muted); }
.suggest-score { font-weight: 700; color: var(--star); flex-shrink: 0; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f0f0f4; color: var(--ink);
  border-radius: 999px; padding: 5px 12px;
  font-size: 0.82rem; font-weight: 600;
}

/* ---------- tags ---------- */
.tag-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 12px 0 4px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef0ff; color: #4a4fbf;
  border-radius: 999px; padding: 5px 12px;
  font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.tag-chip a { color: inherit; text-decoration: none; }
.tag-chip .tag-x {
  background: none; border: none; color: #9a9ec8; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0 0 0 2px;
}
.tag-chip .tag-x:hover { color: var(--brand); }
.tag-add { display: inline-flex; gap: 6px; align-items: center; }
.tag-add input {
  width: auto; min-width: 120px; padding: 6px 12px;
  border-radius: 999px; font-size: 0.85rem;
}
.tag-add-btn {
  background: #f0f0f4; border: none; border-radius: 999px;
  padding: 6px 14px; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--ink);
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .tag-chip { font-size: 0.9rem; padding: 7px 14px; }
.tag-count {
  background: #dfe2ff; border-radius: 999px; padding: 0 7px;
  font-size: 0.75rem; margin-left: 2px;
}

/* ---------- merge tool ---------- */
.merge-card { margin-top: 24px; }
.merge-card summary {
  font-weight: 700; cursor: pointer; list-style: none;
}
.merge-card summary::-webkit-details-marker { display: none; }
.merge-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.merge-card .btn-ghost { align-self: flex-start; }
.merge-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.merge-tag-check {
  flex-direction: row; align-items: center; gap: 5px;
  font-weight: 600; font-size: 0.85rem;
}
.merge-tag-check input { width: auto; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #fff3f0 0%, #f4f5f8 55%);
}
.login-card {
  background: var(--card); border-radius: 26px; padding: 34px 28px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow); text-align: center;
}
.login-logo { font-size: 2.8rem; font-weight: 900; font-style: italic; letter-spacing: -0.04em;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-logo .dot { color: var(--star); -webkit-text-fill-color: var(--star); }
.login-tag { color: var(--muted); margin: 4px 0 24px; font-size: 0.95rem; }
.login-card form { display: flex; flex-direction: column; gap: 13px; text-align: left; }

/* ---------- event detail ---------- */
.detail-hero {
  border-radius: 22px; padding: 22px; color: #fff; margin-bottom: 16px;
  position: relative; overflow: hidden;
}
.detail-hero.has-photo { padding: 0; }
.detail-hero .hero-photo { width: 100%; display: block; }
.detail-hero .hero-cat { font-size: 2.4rem; }
.detail-hero h1 { color: #fff; margin-top: 8px; }
.detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.detail-meta .chip { background: rgba(255,255,255,0.9); }
.detail-details { color: var(--ink); background: var(--card); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); margin-bottom: 16px; }

.avg-box {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 8px;
}
.avg-number { font-size: 2.8rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.avg-number.empty { color: var(--muted); }
.avg-side .stars { font-size: 1.3rem; }

/* collapsible "add/edit your review" — keeps reading (consumption) primary */
.rate-toggle { margin-bottom: 8px; }
.rate-toggle summary {
  font-weight: 700; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.rate-toggle summary::-webkit-details-marker { display: none; }
.rate-toggle[open] summary { margin-bottom: 12px; }
.rate-toggle form { display: flex; flex-direction: column; gap: 10px; }

.review-card { padding: 14px 16px; margin-bottom: 10px; }
.review-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.review-date { color: var(--muted); font-size: 0.75rem; }

/* uploaded photo shows as a thumbnail below the info, not a giant hero */
.event-photo-thumb {
  display: inline-block; margin: 0 0 16px;
  border-radius: 14px; overflow: hidden; max-width: 260px;
  box-shadow: var(--shadow-sm);
}
.event-photo-thumb img { display: block; width: 100%; }

/* category page: who rated + per-person scores */
.cat-event { padding: 12px 14px; }
.cat-event-head { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.cat-event-main { min-width: 0; }
.rater-list { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.rater-row { display: flex; align-items: center; gap: 8px; }
.rater-name { font-weight: 600; font-size: 0.9rem; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.rater-name:hover { text-decoration: underline; }
.review-author { color: inherit; text-decoration: none; }
.review-author:hover { text-decoration: underline; }
.rater-stars { flex-shrink: 0; }
.rater-score { font-weight: 800; font-size: 0.9rem; width: 26px; text-align: right; }

.footer-actions { display: flex; align-items: center; gap: 14px; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.review-head strong { font-weight: 700; }
.review-text { margin: 8px 0 0; white-space: pre-wrap; color: #33333f; }

.detail-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line);
}

/* ---------- report card / lists ---------- */
.tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 20px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); color: inherit;
}
.tile-badge {
  width: 50px; height: 50px; border-radius: 15px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff; font-weight: 800;
}
.tile-main { flex: 1; min-width: 0; }
.tile-title { font-weight: 700; font-size: 1.02rem; }
.tile-sub { color: var(--muted); font-size: 0.84rem; margin-top: 3px; }
.tile-score { font-size: 1.25rem; font-weight: 800; }
.tile-score.empty { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

.report-card { padding: 6px 4px; }
.skill-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-bottom: 1px solid var(--line);
}
.skill-row:last-child { border-bottom: none; }
.skill-emoji { font-size: 1.4rem; }
.skill-name { flex: 1; font-weight: 600; }
.skill-score { font-weight: 800; }

/* ---------- admin ---------- */
details.admin-user { border-bottom: 1px solid var(--line); }
details.admin-user:last-child { border-bottom: none; }
details.admin-user > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
}
details.admin-user > summary::-webkit-details-marker { display: none; }
.admin-av { width: 40px; height: 40px; border-radius: 12px; color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.admin-info { flex: 1; min-width: 0; }
.admin-info .name { font-weight: 700; }
.admin-info .uname { color: var(--muted); font-size: 0.82rem; }
.admin-edit-hint { color: var(--muted); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
details.admin-user[open] .admin-edit-hint { color: var(--brand); }
.admin-edit-body {
  padding: 4px 4px 16px; margin-left: 52px;
  display: flex; flex-direction: column; gap: 14px;
}
.admin-edit-form { display: flex; flex-direction: column; gap: 6px; }
.admin-edit-form .row-input { display: flex; gap: 8px; }
.admin-edit-form .row-input input { flex: 1; min-width: 0; }
.admin-edit-form .btn-ghost { padding: 10px 16px; flex-shrink: 0; }
.badge-admin { background: var(--brand-grad); color: #fff; border-radius: 999px;
  font-size: 0.68rem; font-weight: 800; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.check-row { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }
.check-row input { width: auto; }

/* ---------- leaderboard / stats ---------- */
.trophy { font-size: 1.25rem; text-decoration: none; line-height: 1; }
.stat-strip {
  display: flex; justify-content: space-around; text-align: center;
  padding: 16px; margin-bottom: 14px; gap: 8px;
}
.stat-strip b { display: block; font-size: 1.6rem; font-weight: 800; color: var(--brand); }
.stat-strip span { font-size: 0.78rem; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card {
  background: var(--card); border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow-sm); color: inherit; text-decoration: none;
  display: flex; flex-direction: column; gap: 3px;
}
.stat-emoji { font-size: 1.7rem; }
.stat-label { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.stat-name { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.stat-detail { font-size: 0.8rem; color: var(--muted); }
@media (max-width: 380px) { .stat-grid { grid-template-columns: 1fr; } }

/* ---------- "everyone else" collapse on People ---------- */
.other-people { margin-top: 14px; }
.other-people summary {
  font-weight: 700; cursor: pointer; list-style: none;
  color: var(--muted); padding: 10px 4px;
}
.other-people summary::-webkit-details-marker { display: none; }
.other-people summary::before { content: '▸ '; }
.other-people[open] summary::before { content: '▾ '; }

/* ---------- empty ---------- */
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.empty-emoji { font-size: 2.6rem; display: block; margin-bottom: 10px; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: 68px; background: rgba(255,255,255,0.94);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 8px calc(env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #b3b3bf; font-size: 0.62rem; font-weight: 600; text-decoration: none;
  flex: 1; min-width: 0; padding: 8px 2px; white-space: nowrap; letter-spacing: -0.01em;
}
.tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--brand); }
.tab-add { flex: 0 0 auto; margin: 0 4px; }
.tab-add .add-btn {
  width: 54px; height: 54px; border-radius: 50%; background: var(--brand-grad);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(255, 106, 95, 0.4); margin-top: -22px;
}
.tab-add .add-btn svg { width: 26px; height: 26px; stroke: #fff; stroke-width: 2.4; }
