:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --border: #e2ded7;
  --text: #1c1a17;
  --muted: #6f6a62;
  --accent: #1f6f5c;
  --accent-soft: #e4f0ec;
  --danger: #a33a2a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1e2124;
    --border: #2e3236;
    --text: #e8e6e3;
    --muted: #9aa0a6;
    --accent: #57b498;
    --accent-soft: #1c332d;
    --danger: #e08573;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin: 2rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .2rem; line-height: 1.3; }
a { color: inherit; }
p { margin: .4rem 0; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); }
.spacer { flex: 1; }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 1rem 4rem; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 780px; margin: 0 auto; padding: .9rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.scan-form { margin: 0; display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
/* Testing affordance, not a headline: keep it visibly subordinate to Scan. */
.scan-opt {
  display: flex; align-items: center; gap: .3rem;
  font-size: .76rem; color: var(--muted); cursor: pointer; user-select: none;
}
.scan-opt input { margin: 0; cursor: pointer; }

/* --- buttons --- */
button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; transition: background .12s, border-color .12s;
}
button:hover { border-color: var(--accent); }
.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.scan { padding: .6rem 1.6rem; }
.ghost { background: transparent; font-size: .85rem; padding: .38rem .7rem; }
.ghost.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ghost.subtle { color: var(--muted); }

/* --- flash / status --- */
.flash {
  margin: 1rem 0 0; padding: .7rem .9rem;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); font-size: .9rem;
}
.statusline { padding: .9rem 0 .2rem; }

/* --- filters --- */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .6rem 0 .2rem; }
.chip {
  text-decoration: none; font-size: .85rem;
  padding: .35rem .75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* --- cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.event { margin-bottom: .85rem; }
.event.decided { opacity: .62; }
.event.going { opacity: 1; border-color: var(--accent); }

.event-head { display: flex; gap: .85rem; align-items: flex-start; }
.event-title { min-width: 0; }
.score {
  flex: 0 0 auto; min-width: 2.4rem; text-align: center;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 8px; padding: .35rem .4rem;
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.meta { font-size: .85rem; color: var(--muted); margin: 0; }
.zone { white-space: nowrap; }
.desc { font-size: .92rem; margin: .6rem 0 .2rem; }

.reasons {
  list-style: none; margin: .6rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .3rem;
}
.reasons li {
  font-size: .76rem; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .15rem .45rem;
}

.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }

/* --- going list --- */
.going-list { list-style: none; padding: 0; margin: 0; }
.going-list li {
  padding: .5rem .8rem; background: var(--surface);
  border: 1px solid var(--accent); border-radius: 8px; margin-bottom: .4rem;
  display: flex; gap: .6rem; justify-content: space-between; flex-wrap: wrap;
  font-size: .92rem;
}

.empty { color: var(--muted); padding: 1.5rem 0; }

/* --- fravalg --- */
.mute-actions { margin-top: .35rem; }
.rule-form { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; max-width: 46rem; }
.rule-form label { display: flex; flex-direction: column; gap: .3rem; width: 100%; font-size: .85rem; color: var(--muted); }
.rule-form input[type=text] {
  font: inherit; padding: .55rem .7rem; border-radius: 8px; width: 100%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.rule-list { list-style: none; padding: 0; margin: 0; }
.rule-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.rule-list form { margin: 0; }
.log { width: 100%; border-collapse: collapse; font-size: .85rem; }
.log td { padding: .4rem .6rem .4rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.foot { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .85rem; }

/* --- login --- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: .8rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login input {
  font: inherit; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.repeats {
  color: var(--accent); font-weight: 600; white-space: nowrap;
}
