/* Simple, readable styling. RTL-first (Hebrew); math is always LTR. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #2459c4;
  --accent-soft: #e8eefb;
  --good: #1f8a4c;
  --good-soft: #e6f4ec;
  --bad: #c0362c;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --card: #1c2027;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #2c323b;
    --accent: #7aa5ff;
    --accent-soft: #233150;
    --good: #5cc98a;
    --good-soft: #1d3527;
    --bad: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 1rem 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.good { color: var(--good); font-weight: 600; }

/* top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); font-size: 1.1rem; }
form.inline { display: inline; margin: 0; }

/* buttons & forms */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: .45rem 1rem; border-radius: var(--radius); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { padding: .2rem .7rem; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
button.link.danger { color: var(--bad); }
.form { display: flex; flex-direction: column; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
input, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .45rem .6rem;
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search { min-width: 0; width: 280px; max-width: 100%; }
.search-form { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
fieldset.radio-row { border: 0; padding: 0; margin: 0; display: flex; gap: 1.2rem; flex-wrap: wrap; }
fieldset.radio-row label { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; }
.error { background: #fdecea; color: #8a1c13; border-radius: var(--radius); padding: .6rem .8rem; }
.flash { background: var(--accent-soft); border-radius: var(--radius); padding: .6rem .8rem; margin: 1rem 0; }

/* layout */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 1rem 0;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 1rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.hero { padding: 1rem 0; }
.crumbs { margin: 1rem 0 0; color: var(--muted); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
.weekly .check { display: inline-block; width: 1.2em; color: var(--muted); }
.weekly li.done .check { color: var(--good); font-weight: 700; }
.weekly li.done .dlink { color: var(--muted); }
.tag.diff-0 { background: var(--good-soft); color: var(--good); }
.tag.diff-2 { background: #fdecea; color: #a8271d; }
@media (prefers-color-scheme: dark) { .tag.diff-2 { background: #3a2220; color: var(--bad); } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .9rem; }
.bar { background: var(--border); border-radius: 99px; height: 10px; overflow: hidden; margin-top: .4rem; min-width: 60px; }
.bar-fill { background: var(--good); height: 100%; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); text-align: start; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .9rem; white-space: nowrap; }
.table time { white-space: nowrap; }
.table td.wide, .table th.wide { width: 100%; }
.table tr:last-child td { border-bottom: 0; }
.row-good td:first-child { box-shadow: inset -3px 0 0 var(--good); }
.row-done td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.row-me { background: var(--accent-soft); }
.tag {
  display: inline-block; font-size: .75rem; padding: 0 .4rem; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); margin-inline-start: .3rem; cursor: default;
}
.card { overflow-x: auto; }

/* derivation list */
.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 99px; padding: .2rem .8rem; }
.dlink { color: var(--text); }
.dlink:hover { color: var(--accent); }

/* derivation page */
.dtitle { font-size: 1.5rem; }
.meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
details.solution summary { cursor: pointer; list-style: none; }
details.solution summary::-webkit-details-marker { display: none; }
details.solution summary h2 { display: inline; margin: 0; }
details.solution summary::before { content: "◂ "; color: var(--muted); }
details.solution[open] summary::before { content: "▾ "; }
details.solution[open] summary { margin-bottom: .75rem; }
.content { line-height: 1.8; }
.content .p { margin: 0 0 .8rem; }
.content .align-center { text-align: center; }
.content .align-right { text-align: right; }
.figure { margin: 1rem 0; text-align: center; }
.figure img { max-width: 100%; height: auto; background: #fff; border-radius: 4px; padding: 4px; }
.c-blue { color: rgb(12, 97, 197); }
.c-green { color: rgb(0, 128, 40); }
.c-red { color: rgb(235, 16, 16); }
.c-brown { color: rgb(154, 58, 0); }
.c-orange { color: rgb(231, 135, 26); }
.c-purple { color: rgb(94, 53, 177); }

/* math: always left-to-right inside Hebrew text */
.math { direction: ltr; unicode-bidi: isolate; }
.math.display { display: block; margin: .6rem 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.math-error { color: var(--bad); font-family: monospace; }

/* tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: .4rem .8rem;
  font: inherit; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* attempt page */
.attempt-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 1rem; }
.stopwatch { text-align: center; }
.sw-display { font-size: 4rem; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; line-height: 1.2; margin-top: .5rem; }
.stopwatch.running .sw-display { color: var(--accent); }
.stopwatch.over .sw-display { color: var(--bad); }
.sw-buttons { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.duration-inputs { display: flex; align-items: flex-end; gap: .5rem; justify-content: flex-end; }
.duration-inputs input { width: 6rem; text-align: center; }
.duration-inputs .colon { font-size: 1.4rem; padding-bottom: .3rem; }

@media (max-width: 600px) {
  .sw-display { font-size: 3rem; }
  .table th, .table td { padding: .35rem .3rem; }
}
