/* tinycalc — barvy dle validované referenční palety (viz README) */
:root {
  color-scheme: light;
  --plane:      #f9f9f7;
  --surface:    #fcfcfb;
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --muted:      #898781;
  --grid:       #e1e0d9;
  --line:       #c3c2b7;
  --border:     rgba(11, 11, 11, .10);
  --good:       #0ca30c;
  --warning:    #fab219;
  --serious:    #ec835a;
  --critical:   #d03b3b;
  --accent:     #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:    #0d0d0d;
    --surface:  #1a1a19;
    --ink:      #ffffff;
    --ink-2:    #c3c2b7;
    --muted:    #898781;
    --grid:     #2c2c2a;
    --line:     #383835;
    --border:   rgba(255, 255, 255, .10);
    --accent:   #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--plane);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 3rem;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 .75rem; }

header { padding: 1rem .75rem .5rem; max-width: 720px; margin: 0 auto; }
header h1 { font-size: 1.15rem; margin: 0; letter-spacing: -.01em; }
header p { margin: .15rem 0 0; color: var(--muted); font-size: .8rem; }

/* ---- záložky ---- */
nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--plane);
  border-bottom: 1px solid var(--border);
  padding-top: .5rem;
}
nav .wrap {
  display: flex; gap: .25rem;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
nav .wrap::-webkit-scrollbar { display: none; }
nav button {
  flex: 0 0 auto; appearance: none; border: 0; background: none;
  font: inherit; font-size: .9rem; color: var(--ink-2);
  padding: .6rem .65rem; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

section[hidden] { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .85rem;
  margin: .75rem 0;
}
.card > h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
             color: var(--muted); margin: 0 0 .6rem; font-weight: 600; }

/* ---- formulářová mřížka ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .6rem; }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.field > span { font-size: .72rem; color: var(--ink-2); }
input, select {
  font: inherit; font-size: 16px; /* 16px = iOS nezoomuje */
  width: 100%; min-width: 0;
  padding: .45rem .5rem;
  background: var(--plane);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
label.check { display: flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--ink-2); }
label.check input { width: auto; }

/* ---- seznamy řádků ---- */
.row { display: flex; gap: .4rem; align-items: flex-end; margin-bottom: .45rem; }
.row .field { flex: 1 1 0; }
.row .field.narrow { flex: 0 0 4.2rem; }
.row .del {
  flex: 0 0 auto; appearance: none; border: 1px solid var(--line);
  background: var(--plane); color: var(--muted);
  border-radius: 8px; width: 2.1rem; height: 2.15rem;
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.row .del:hover { color: var(--critical); border-color: var(--critical); }
.add {
  appearance: none; border: 1px dashed var(--line); background: none;
  color: var(--ink-2); font: inherit; font-size: .85rem;
  border-radius: 8px; padding: .45rem .7rem; cursor: pointer; width: 100%;
}
.add:hover { border-color: var(--accent); color: var(--accent); }

/* ---- dlaždice s výsledky ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .5rem; }
.tile {
  background: var(--plane); border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .65rem;
}
.tile .lab { font-size: .72rem; color: var(--ink-2); }
.tile .val { font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; margin-top: .1rem; }
.tile .val .u { font-size: .8rem; font-weight: 400; color: var(--muted); margin-left: .15rem; }
.tile .sub { font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.tile.hero .val { font-size: 2.1rem; }

/* ---- upozornění ---- */
.note { display: flex; gap: .5rem; align-items: flex-start;
        border-radius: 10px; padding: .5rem .6rem; margin-top: .5rem;
        font-size: .84rem; border: 1px solid var(--border); background: var(--plane); }
.note .ico { flex: 0 0 auto; font-weight: 700; }
.note.good     { border-left: 3px solid var(--good); }
.note.good .ico    { color: var(--good); }
.note.warning  { border-left: 3px solid var(--warning); }
.note.warning .ico { color: var(--warning); }
.note.critical { border-left: 3px solid var(--critical); }
.note.critical .ico{ color: var(--critical); }

/* ---- schéma podvozku ---- */
.trailer { margin-top: .75rem; }
.trailer .track {
  position: relative; height: 62px; margin: 1.4rem .5rem 1.9rem;
  border-bottom: 2px solid var(--line);
}
.trailer .deck {
  position: absolute; left: 0; right: 0; top: 26px; height: 8px;
  background: var(--grid); border-radius: 4px;
}
.trailer .mark { position: absolute; top: 0; width: 0; }
.trailer .mark i {
  position: absolute; top: 16px; left: -1px; width: 2px; height: 30px;
  background: currentColor; display: block;
}
.trailer .mark b {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%);
  font-size: .66rem; font-weight: 600; white-space: nowrap; color: var(--ink-2);
}
.trailer .mark s {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  font-size: .66rem; text-decoration: none; white-space: nowrap; color: var(--muted);
}
.trailer .mark.cg { color: var(--accent); }
.trailer .mark.cg b { color: var(--accent); }
.trailer .mark.tgt { color: var(--muted); }
.trailer .mark.tgt i { background: repeating-linear-gradient(var(--muted) 0 3px, transparent 3px 6px); }
.trailer .mark.ax { color: var(--ink-2); }
.trailer .mark.hitch { color: var(--ink-2); }
.trailer .wheel {
  position: absolute; top: 34px; width: 16px; height: 16px; margin-left: -8px;
  border-radius: 50%; background: var(--line);
}

/* ---- nářezové schéma ---- */
.bar { display: flex; height: 30px; margin: .3rem 0 .1rem;
       background: var(--grid); border-radius: 5px; overflow: hidden; }
.seg { display: flex; align-items: center; justify-content: center;
       font-size: .66rem; font-weight: 600; color: #fff;
       overflow: hidden; white-space: nowrap; min-width: 2px;
       border-right: 2px solid var(--surface); }  /* mezera je uvnitř šířky dílu */
.seg:last-child { border-right: 0; }
.seg.waste { background: var(--grid); color: var(--muted); font-weight: 400; }
.barlab { font-size: .7rem; color: var(--muted); display: flex; justify-content: space-between; }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; margin: .1rem 0 .6rem; font-size: .75rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- tabulka ---- */
table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: .4rem; }
th, td { text-align: right; padding: .35rem .3rem; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .72rem; }
td { font-variant-numeric: tabular-nums; }
tr.best td { font-weight: 600; }
tr.best td:first-child::after { content: " ✓"; color: var(--good); }

.hint { font-size: .74rem; color: var(--muted); margin: .5rem 0 0; }
footer { text-align: center; color: var(--muted); font-size: .72rem; padding: 1.5rem .75rem 0; }
@media (max-width: 400px) { .grid.g3 { grid-template-columns: repeat(2, 1fr); } }

/* pásmo přijatelného těžiště + čitelnost popisků v segmentech */
.trailer .band {
  position: absolute; top: 22px; height: 16px;
  background: color-mix(in srgb, var(--good) 22%, transparent);
  border-left: 1px solid var(--good); border-right: 1px solid var(--good);
  border-radius: 2px;
}
.seg { text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }

/* ---- míra využití ---- */
.meter { margin: .6rem 0; }
.meter .mlab { display: flex; justify-content: space-between; align-items: baseline;
               font-size: .8rem; color: var(--ink-2); }
.meter .mlab b { font-variant-numeric: tabular-nums; color: var(--ink); }
.meter .track { position: relative; height: 10px; border-radius: 5px;
                background: var(--grid); overflow: hidden; margin-top: .25rem; }
.meter .fill { height: 100%; border-radius: 5px; }
.meter .sub { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
