:root {
  --bg: #F4F6F3; --surface: #FFFFFF; --surface2: #EEF2EC; --text: #17231F; --muted: #5E6B66; --line: #DCE3DE;
  --primary: #0E5A4F; --primary-ink: #FFFFFF; --accent: #CBE63A; --accent-ink: #1E2A06;
  --danger: #C2362B; --warn: #B7791F; --ok: #1F8A4C; --going: #1F8A4C; --maybe: #B7791F; --no: #8A8F8D;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --radius: 14px; --tabh: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #18211E; --surface2: #202B27; --text: #E6EEEA; --muted: #9AA8A2; --line: #2C3934;
    --primary: #3FB39F; --primary-ink: #06201B; --accent: #CBE63A; --accent-ink: #1E2A06;
    --danger: #F0766B; --warn: #E3B05A; --ok: #5BCB8A; --going: #5BCB8A; --maybe: #E3B05A; --no: #7D8784;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, sans-serif;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .3em 0 .6em; line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; }
h2 { font-size: 1.08rem; margin: 0 0 .7em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.pad { padding: 40px 16px; } .pad-s { padding: 12px; }
.hint { display: block; color: var(--muted); font-size: .84rem; margin-top: 4px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 1100; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--primary); color: var(--primary-ink);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #0B3B34; color: #fff; } }
.brand { display: flex; align-items: center; gap: 8px; color: inherit; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; background: #fff; }
.lang { width: auto; flex: none; margin-left: auto; background: rgba(255,255,255,.14); color: inherit; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 5px 6px; font: inherit; font-size: .85rem; }
.lang option { color: #000; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; display: flex;
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: .74rem; min-width: 0; }
.tabs a:hover { text-decoration: none; }
.tabs .ti { font-size: 1.25rem; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--primary); font-weight: 700; }
.tabs a.on .ti { filter: none; opacity: 1; }
.tabs .tl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabs { position: static; height: auto; padding: 0; background: none; border: 0; gap: 4px; margin-left: 24px; }
  .tabs a { flex: none; flex-direction: row; gap: 6px; color: rgba(255,255,255,.8); font-size: .92rem; padding: 7px 12px; border-radius: 9px; }
  .tabs a.on { color: #fff; background: rgba(255,255,255,.16); }
  .tabs .ti { font-size: 1rem; filter: none; opacity: 1; }
}

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; min-height: 32px; font-size: .86rem; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: .9rem; min-width: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 label:first-child { grid-column: 1 / -1; } }
fieldset.loc { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
fieldset.loc legend { font-weight: 700; padding: 0 6px; font-size: .9rem; }
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-group .lbl { font-weight: 600; font-size: .9rem; }
.form label.radio { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.radio input { width: auto; }
.form-err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-weight: 600; }

/* layout */
main { outline: none; }
.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page.narrow, .form-page { max-width: 620px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0; }
.back { display: inline-block; margin-bottom: 6px; color: var(--muted); font-weight: 600; }
.empty { text-align: center; padding: 36px 16px; color: var(--text); }
.empty .big { font-size: 2.6rem; }
.empty .btn { margin: 4px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* explore */
.explore { display: flex; flex-direction: column; }
.ex-top { padding: 12px 16px 6px; background: var(--bg); position: relative; z-index: 900; }
.search { display: flex; gap: 8px; max-width: 1100px; margin: 0 auto; }
.search input { flex: 1; }
.sresults {
  position: absolute; left: 16px; right: 16px; top: 62px; max-width: 700px; max-height: 60vh; overflow: auto; z-index: 950;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.lp-results.sresults { position: static; max-height: 240px; }
.sr-h { font-size: .76rem; font-weight: 700; color: var(--muted); padding: 8px 12px 2px; text-transform: uppercase; letter-spacing: .03em; }
.sr { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; border-bottom: 1px solid var(--line); }
.sr:hover { background: var(--surface2); text-decoration: none; }
.sr span { display: flex; flex-direction: column; min-width: 0; }
.sr small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr .pb { width: 22px; height: 22px; flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; max-width: 1100px; margin: 0 auto; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; white-space: nowrap;
}
.chip .pb { width: 16px; height: 16px; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.ex-body { display: flex; flex-direction: column; }
.ex-map { position: relative; height: 46vh; min-height: 260px; }
#map { position: absolute; inset: 0; }
.map-btn {
  position: absolute; right: 12px; bottom: 14px; z-index: 800; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--primary); font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow);
}
.ex-list { padding: 12px 16px 24px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
@media (min-width: 900px) {
  .ex-body { flex-direction: row-reverse; height: calc(100vh - 150px); padding: 0 16px 16px; gap: 16px; max-width: 1400px; margin: 0 auto; width: 100%; }
  .ex-map { flex: 1; height: auto; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
  .ex-list { width: 400px; flex: none; overflow-y: auto; padding: 0 4px 0 0; }
  .ex-top { padding: 14px 16px 8px; }
  .search, .chips { max-width: 1400px; }
}

/* club card */
.club-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); min-width: 0;
}
.club-card:hover { text-decoration: none; border-color: var(--primary); }
.cc-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--surface2); display: grid; place-items: center; font-size: 1.5rem; }
.cc-icon .pb { width: 30px; height: 30px; }
.cc-body { flex: 1; min-width: 0; }
.cc-title { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cc-title b { overflow-wrap: anywhere; }
.cc-meta, .cc-where, .cc-sched { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.next { display: inline-block; margin-top: 4px; font-size: .82rem; background: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); padding: 1px 8px; border-radius: 999px; }
.cc-dist { flex: none; font-weight: 700; color: var(--primary); font-size: .9rem; white-space: nowrap; }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.role-owner { background: var(--accent); color: var(--accent-ink); }
.role-admin { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.role-member { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.role-pending { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* map pins */
.pin-wrap { background: none; border: 0; }
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #fff; border: 2px solid #0E5A4F;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .12s;
}
.pin > * { transform: rotate(45deg); }
.pin .emo { font-size: 18px; line-height: 1; }
.pin .pb { width: 22px; height: 22px; }
.pin.active { background: #CBE63A; border-color: #0B3B34; transform: rotate(-45deg) scale(1.18); z-index: 1000; }
.pop b { display: block; margin-bottom: 2px; }
.leaflet-container { font: inherit; background: var(--surface2); }

/* club detail */
.hero { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.hero-icon { flex: none; width: 64px; height: 64px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; font-size: 2.2rem; }
.hero-icon .pb { width: 44px; height: 44px; }
.hero-txt { min-width: 0; }
.hero h1 { margin: 0 0 2px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1.15fr; align-items: start; } }
.desc { white-space: pre-wrap; margin: 0 0 12px; overflow-wrap: anywhere; }
.info-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; min-width: 0; }
.info-row > div { min-width: 0; }
.info-row .lbl { font-size: .78rem; color: var(--muted); font-weight: 600; }
.mini-map { height: 220px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-head h2 { margin: 0; }
.count { display: inline-block; min-width: 22px; text-align: center; font-size: .78rem; background: var(--surface2); border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.mem-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.mem-row:first-child { border-top: 0; }
.mem-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.3rem; }
.mini-sel { width: auto; padding: 3px 6px; font-size: .9rem; border-radius: 8px; }
.manage { display: flex; flex-wrap: wrap; gap: 8px; }
.past summary, .att summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin-top: 6px; }
.past-row { font-size: .88rem; padding: 3px 0; color: var(--muted); }
.past-row span { display: inline-block; min-width: 90px; }

/* meetup */
.meetup { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
#meetupList .meetup:first-child { border-top: 0; }
#mtList .meetup, #myMt .meetup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.mt-date { flex: none; width: 52px; text-align: center; border-radius: 12px; background: var(--surface2); padding: 6px 0; display: flex; flex-direction: column; line-height: 1.15; align-self: flex-start; }
.mt-date .mon { font-size: .72rem; color: var(--muted); font-weight: 700; }
.mt-date .day { font-size: 1.35rem; font-weight: 800; }
.mt-date .wd { font-size: .72rem; color: var(--muted); }
.has-going .mt-date { background: color-mix(in srgb, var(--going) 22%, transparent); }
.mt-body { flex: 1; min-width: 0; }
.mt-club { display: inline-flex; align-items: center; gap: 4px; font-size: .84rem; font-weight: 600; }
.mt-club .pb { width: 16px; height: 16px; }
.mt-title { overflow-wrap: anywhere; }
.edit-link { font-size: .85rem; }
.mt-meta { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.mt-note { font-size: .88rem; white-space: pre-wrap; background: var(--surface2); border-radius: 8px; padding: 6px 10px; margin-top: 6px; overflow-wrap: anywhere; }
.full { color: var(--danger); }
.rsvp { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.rs { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .84rem; cursor: pointer; }
.rs:disabled { opacity: .45; cursor: default; }
.rs.on.going { background: var(--going); border-color: var(--going); color: #fff; font-weight: 700; }
.rs.on.maybe { background: var(--maybe); border-color: var(--maybe); color: #fff; font-weight: 700; }
.rs.on.no { background: var(--no); border-color: var(--no); color: #fff; font-weight: 700; }
.att-chip { display: inline-block; font-size: .8rem; padding: 2px 9px; margin: 4px 4px 0 0; border-radius: 999px; background: color-mix(in srgb, var(--going) 16%, transparent); }
.att-chip.maybe { background: color-mix(in srgb, var(--maybe) 18%, transparent); }
.day-h { font-size: .95rem; margin: 18px 0 8px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.filters select { width: auto; flex: 1 1 140px; }

/* location picker */
.lp-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.lp-tools input { flex: 1 1 180px; }
.lp-map { height: 280px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }

/* profile / auth */
.profile { display: flex; gap: 14px; align-items: center; }
.profile > div { min-width: 0; overflow-wrap: anywhere; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.auth-hero { text-align: center; margin: 10px 0 16px; }
.auth-hero .pb { width: 56px; height: 56px; }
.auth-hero h1 { margin: 8px 0 2px; }
.club-list { margin-bottom: 18px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); background: #1C2723; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 2000; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
.toast.warn { background: #8A5A12; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.leaflet-top, .leaflet-bottom { z-index: 800; }
.ex-top { z-index: 1000; }
