:root {
  color-scheme: light dark;
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #1c2320;
  --muted: #6b7671;
  --line: #dde3df;
  --green: #2f6b46;
  --red: #a33227;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --card: #1d2321;
    --ink: #e8ede9;
    --muted: #96a29c;
    --line: #2e3633;
    --green: #6cc08b;
    --red: #e07a6d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; text-decoration: none; color: var(--ink); }
nav a { margin-left: 1rem; }
a { color: var(--green); }

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card.narrow { max-width: 22rem; margin: 3rem auto; }

h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.35rem; }

/* Genuinely tabular data scrolls inside its own box, so a wide table can
   never push the page sideways on a phone. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }
tr.inactive { opacity: 0.55; }

/* --- watch list -------------------------------------------------------- */
/* Cards rather than table rows: a watch is a configured thing with actions,
   not a row of data, and cards stack on a narrow screen instead of
   overflowing. */

.watch-list { list-style: none; margin: 0; padding: 0; }

.watch {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.watch:last-child { border-bottom: 0; padding-bottom: 0; }
.watch.inactive { opacity: 0.6; }

.watch-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.watch-head h1 { margin: 0; }
.watch-name {
  font-weight: 600;
  font-size: 1.02rem;
  text-decoration: none;
  color: var(--ink);
}
.watch-name:hover { color: var(--green); text-decoration: underline; }

.watch-meta { font-size: 0.83rem; color: var(--muted); margin: 0.5rem 0 0; }

/* --- criteria chips ---------------------------------------------------- */

.criteria-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;      /* the whole point: wraps instead of overflowing */
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.78rem;
  color: var(--ink);
  white-space: nowrap;
}
.chip-icon { font-size: 0.85em; line-height: 1; opacity: 0.75; }

/* The course is the thing you scan for first, so give it the accent. */
.chip-course {
  border-color: color-mix(in srgb, var(--green) 45%, transparent);
  background: color-mix(in srgb, var(--green) 10%, transparent);
  color: var(--green);
  font-weight: 600;
}

.criteria { color: var(--muted); font-size: 0.87rem; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 500; }
.hint { color: var(--muted); font-size: 0.83rem; margin: 0.2rem 0 0.5rem; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill.on { background: rgba(47, 107, 70, 0.15); color: var(--green); }
.pill.off { background: rgba(107, 118, 113, 0.18); color: var(--muted); }

.actions { display: flex; gap: 0.65rem; align-items: center; white-space: nowrap; }
.actions form { display: inline; margin: 0; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 500; font-size: 0.88rem; }
label.check { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 1rem; font-weight: 400; }
label.check input { margin: 0; }

input[type=text], input[type=password], input[type=date],
input[type=time], input[type=number], select {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem 1rem;
  margin: 1.1rem 0;
}
legend { font-weight: 600; font-size: 0.88rem; padding: 0 0.35rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }

button {
  margin-top: 1rem;
  padding: 0.5rem 1.1rem;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--green); border: 1px solid var(--green); }
button.link {
  background: none;
  border: 0;
  color: var(--green);
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}
button.link.danger { color: var(--red); }
.cancel { margin-left: 0.85rem; font-size: 0.9rem; }

dl.status { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; font-size: 0.9rem; }
dl.status dt { color: var(--muted); }
dl.status dd { margin: 0; }

code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }
