:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efeae2;
  --text: #1d1b18;
  --muted: #6d675e;
  --line: #e2dcd2;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fde7da;
  --gold: #d4a017;
  --gold-soft: #fbf1d3;
  --gold-ink: #8a6100;
  --star-off: #d8d2c8;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 20, 10, .06), 0 4px 16px rgba(30, 20, 10, .06);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --surface: #1d1c18;
    --surface-2: #272520;
    --text: #f1ede6;
    --muted: #a39c90;
    --line: #34312a;
    --accent: #fb923c;
    --accent-ink: #1a0f05;
    --accent-soft: #3a2415;
    --gold: #f5c542;
    --gold-soft: #3a3015;
    --gold-ink: #f5c542;
    --star-off: #4a463d;
    --ok: #4ade80;
    --ok-soft: #12301c;
    --err: #f87171;
    --err-soft: #3b1515;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding-bottom: 64px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 .8em; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 640px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a.active, .nav a:hover { color: var(--text); text-decoration: none; }
.nav .btn { color: var(--accent-ink); }
.nav-user { display: inline-flex; align-items: center; gap: 8px; }
.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: .85rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 10px 20px; font: 600 .95rem var(--sans); cursor: pointer; transition: transform .1s, filter .15s; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-gold { background: var(--gold); color: #2a1d00; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.nav .link-btn { color: var(--muted); font-weight: 500; }
.danger { color: var(--err) !important; }

/* Flash */
.flash { margin: 20px 0 0; padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash-error { background: var(--err-soft); color: var(--err); }
.auth-card .flash, .form-panel .flash { margin: 0 0 16px; }

/* Hero */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-wrap: wrap; gap: 10px 24px; color: var(--muted); font-size: .92rem; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps span { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: .8rem; }

.section-title { margin-top: 40px; margin-bottom: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head .section-title { margin-bottom: 16px; }
.page-title { margin-top: 36px; }

/* Phase badges */
.phase { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.phase-open { background: var(--ok-soft); color: var(--ok); }
.phase-voting { background: var(--accent-soft); color: var(--accent); }
.phase-complete { background: var(--gold-soft); color: var(--gold-ink); }
.tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* Competition cards */
.comp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.comp-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.comp-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 8px 30px rgba(30, 20, 10, .12); }
.comp-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.comp-card h3 { font-size: 1.5rem; }
.comp-card-foot { margin-top: auto; padding-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.topic { margin-bottom: .5em; }
.topic.big { font-size: 1.15rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.countdown { font-size: .9rem; color: var(--muted); }
.countdown time { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); margin: 24px 0; }
.empty h1 { color: var(--text); }
.cta { margin-top: 56px; padding: 40px; text-align: center; background: var(--accent-soft); border-radius: var(--radius); }

/* Winner strip on home */
.winner-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.winner-tile { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-2); color: #fff; }
.winner-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.winner-tile:hover img { transform: scale(1.04); }
.winner-tile:hover { text-decoration: none; }
.winner-tile-info { position: absolute; inset: auto 0 0 0; padding: 40px 16px 14px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); display: flex; flex-direction: column; font-size: .85rem; }
.winner-tile-info strong { font-family: var(--serif); font-size: 1.15rem; }
.trophy { font-size: 1.2rem; }
.no-winner { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); font-family: var(--serif); padding: 20px; }

/* Competition header */
.comp-header { display: grid; grid-template-columns: 1fr auto; gap: 32px; padding: 36px 0 20px; align-items: end; }
.comp-header .phase { margin-bottom: 12px; }
.desc { white-space: pre-line; max-width: 680px; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, auto); gap: 12px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

.admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 10px 16px; border-radius: 10px; background: var(--surface-2); margin-bottom: 16px; font-size: .9rem; }
.notice { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 14px 18px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 10px 10px 0; margin: 8px 0 24px; box-shadow: var(--shadow); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel.tight { padding: 18px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .92rem; }
.form small { color: var(--muted); font-weight: 400; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .narrow { max-width: 200px; }
.form-actions { display: flex; align-items: center; gap: 20px; }
.auth-card { max-width: 420px; margin: 56px auto; background: var(--surface); padding: 32px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.form-panel { max-width: 760px; margin: 36px auto; }

.upload-form { display: grid; grid-template-columns: minmax(240px, 1fr) 1.2fr; gap: 24px; align-items: stretch; }
.upload-fields { display: flex; flex-direction: column; gap: 16px; }
.upload-fields .btn { align-self: flex-start; }
.dropzone { position: relative; border: 2px dashed var(--line); border-radius: var(--radius); min-height: 220px; display: grid !important; place-items: center; text-align: center; cursor: pointer; background: var(--bg); overflow: hidden; font-weight: 400 !important; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.dz-preview:not([hidden]) + .dz-text { position: relative; background: rgba(0, 0, 0, .6); color: #fff; padding: 6px 12px; border-radius: 8px; align-self: end; margin-bottom: 12px; }
.dz-preview:not([hidden]) + .dz-text small { color: #ddd; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.photo-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: border-color .2s; }
.photo-card.rated { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.photo-card.is-winner { border: 2px solid var(--gold); box-shadow: 0 0 0 4px var(--gold-soft), var(--shadow); }
.photo-frame { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.photo-frame:hover img { transform: scale(1.03); }
.photo-card figcaption { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.photo-card figcaption > div:first-child { display: flex; flex-direction: column; }
.card-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.comment-count { font-size: .85rem; color: var(--muted); }
.rank { position: absolute; top: 10px; left: 10px; font-size: 1.6rem; line-height: 1; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .4)); }
.rank-n { font-size: .85rem; font-weight: 700; background: rgba(0, 0, 0, .65); color: #fff; padding: 4px 9px; border-radius: 999px; }

/* Stars */
.stars-static { font-size: 1.05rem; letter-spacing: 2px; background: linear-gradient(90deg, var(--gold) var(--pct), var(--star-off) var(--pct)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.score .stars-static { font-size: 1.4rem; }
.score-sm { font-size: .9rem; display: inline-flex; align-items: center; gap: 4px; }
.star-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.star-input button { background: none; border: 0; padding: 0 2px; font-size: 1.5rem; line-height: 1; color: var(--star-off); cursor: pointer; transition: color .1s, transform .1s; }
.star-input button.on { color: var(--gold); }
.star-input:hover button { color: var(--star-off); }
.star-input button:hover, .star-input button:hover ~ button { color: var(--gold) !important; }
.star-input button:hover { transform: scale(1.15); }
.star-input.saving { opacity: .5; pointer-events: none; }
.star-input.saved button.on { animation: pop .4s; }
@keyframes pop { 50% { transform: scale(1.3); } }
.photo-side .star-input button { font-size: 2.2rem; }
.label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }

/* Winner hero */
.winner-hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 0; background: var(--surface); border: 2px solid var(--gold); border-radius: calc(var(--radius) + 4px); overflow: hidden; box-shadow: 0 0 0 6px var(--gold-soft), var(--shadow); margin: 12px 0 8px; }
.winner-photo { background: #000; display: grid; place-items: center; }
.winner-photo img { width: 100%; max-height: 560px; object-fit: contain; }
.winner-info { padding: 32px; display: flex; flex-direction: column; justify-content: center; }
.winner-info h2 { font-size: 2rem; }
.ribbon { align-self: flex-start; background: var(--gold); color: #2a1d00; font-weight: 700; padding: 6px 14px; border-radius: 999px; margin-bottom: 16px; letter-spacing: .02em; }
.photographer { display: flex; align-items: center; gap: 12px; }
.winner-info .photographer { font-size: 1.05rem; margin: 8px 0 18px; line-height: 1.3; }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: .75rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1.2rem; background: var(--gold-soft); color: var(--gold-ink); }
.avatar.xl { width: 80px; height: 80px; font-size: 2rem; }

/* Photo page */
.crumbs { display: flex; justify-content: space-between; align-items: center; padding: 24px 0 16px; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 14px; }
.photo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.photo-stage { position: relative; background: #0d0c0a; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 300px; }
.photo-stage img { max-height: 80vh; width: auto; object-fit: contain; }
.photo-stage.is-winner { outline: 3px solid var(--gold); outline-offset: 3px; }
.stage-badge { position: absolute; top: 12px; left: 12px; background: var(--gold); color: #2a1d00; font-weight: 700; font-size: .85rem; padding: 5px 12px; border-radius: 999px; }
.photo-side { display: flex; flex-direction: column; gap: 14px; }
.photo-side h1 { font-size: 1.9rem; margin: 0; }
.photo-side .photographer, .photo-side p { margin: 0; }
.photo-side .panel > * + * { margin-top: 8px; }
.comments h2 { font-size: 1.2rem; }
.comments ul { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment p { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.comment-form { gap: 10px; }
.comment-form .btn { align-self: flex-end; }

/* Archive */
.archive-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; margin-top: 24px; }
.archive-item { display: grid; grid-template-columns: 1.2fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow); }
.archive-photo { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.archive-photo img { width: 100%; height: 100%; object-fit: cover; }
.archive-info { padding: 24px; display: flex; flex-direction: column; gap: 4px; }
.archive-info h2 a { color: var(--text); }
.archive-winner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin: 8px 0 16px; background: var(--gold-soft); border-radius: 10px; }
.archive-winner .avatar { background: var(--gold); color: #2a1d00; }
.archive-info .btn { align-self: flex-start; margin-top: auto; white-space: nowrap; }
.fame { position: sticky; top: 88px; }
.fame h2 { font-size: 1.2rem; }
.fame ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.fame li { display: list-item; }
.fame .tag { margin-left: 6px; background: var(--gold-soft); color: var(--gold-ink); }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 20px; padding: 36px 0 24px; }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 2px 0; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.row-actions { white-space: nowrap; text-align: right !important; }
.row-actions > * + * { margin-left: 12px; }

/* Responsive */
@media (max-width: 900px) {
  .comp-header, .winner-hero, .photo-layout, .archive-layout { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fame { position: static; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .hide-sm { display: none; }
  .nav { gap: 12px; font-size: .92rem; }
  .header-inner { padding: 10px 0; }
  .upload-form, .form-row, .archive-item { grid-template-columns: 1fr; }
  .comp-list, .gallery { grid-template-columns: 1fr; }
  .winner-info { padding: 22px; }
  .auth-card { padding: 24px; margin: 32px auto; }
  .cta { padding: 28px 20px; }
}

/* Imported (Dropbox-era) competitions */
.archive-note { border-left-color: var(--gold); }
.place-tag { background: var(--gold-soft); color: var(--gold-ink); }
.muted-badge { background: rgba(0, 0, 0, .6); color: #fff; font-weight: 600; }
.small-heading { font-size: 1.05rem; margin: 8px 0 0; }
.narrow-wide { max-width: 360px; }

/* Member approval */
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; vertical-align: 1px; }
.tag-pending { background: var(--accent-soft); color: var(--accent); }
.pending-note { border-left-color: var(--accent); }
