:root {
  --bg: #f7f5f1; --card: #ffffff; --ink: #1f1d1a; --muted: #6b665e; --line: #e2ddd4;
  --accent: #2f5d50; --accent-ink: #ffffff; --soft: #eef3f0; --warn: #8a4b0f; --warn-bg: #fdf3e6;
  --piece: #c9d9d1; --piece-line: #2f5d50; --slab: #ece8e1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --card: #201f1d; --ink: #ece9e4; --muted: #a29d94; --line: #36332f;
    --accent: #7fb8a5; --accent-ink: #0f1a16; --soft: #1f2a26; --warn: #f0b878; --warn-bg: #2d2217;
    --piece: #35554a; --piece-line: #7fb8a5; --slab: #2a2825; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --card: #201f1d; --ink: #ece9e4; --muted: #a29d94; --line: #36332f;
  --accent: #7fb8a5; --accent-ink: #0f1a16; --soft: #1f2a26; --warn: #f0b878; --warn-bg: #2d2217;
  --piece: #35554a; --piece-line: #7fb8a5; --slab: #2a2825; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); }
header.top { border-bottom: 1px solid var(--line); background: var(--card); }
header.top .in, main, footer .in { max-width: 860px; margin: 0 auto; padding: 0 16px; }
header.top .in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { font-weight: 700; letter-spacing: .02em; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
.brand span { color: var(--accent); }
nav a { margin-left: 14px; text-decoration: none; color: var(--muted); font-size: .92rem; }
nav a:hover { color: var(--ink); }
main { padding-top: 24px; padding-bottom: 40px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 32px 0 8px; }
h3 { font-size: 1.02rem; margin: 18px 0 4px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tool { margin-bottom: 8px; }
.row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end;
  padding: 10px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 3px; }
input, select { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.x { padding: 8px 10px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.result { margin-top: 16px; padding: 14px 16px; background: var(--soft); border-radius: 10px; }
.big { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-top: 10px; font-size: .92rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; margin-top: 10px; }
.check input { width: auto; }
.slabs { display: grid; gap: 12px; margin-top: 12px; }
.slabs svg { width: 100%; height: auto; display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
details { border-bottom: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { display: block; text-decoration: none; color: var(--ink); }
.tile b { display: block; margin-bottom: 4px; }
.tile.soon { opacity: .6; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 18px 0 30px; }
@media (max-width: 640px) {
  .row { grid-template-columns: 1fr 1fr; position: relative; }
  .row .type { grid-column: 1 / -1; padding-right: 48px; }
  .row .x { position: absolute; top: 28px; right: 0; }
  .row > div:empty { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  nav a { margin-left: 10px; }
  nav a.hide-sm { display: none; }
  h1 { font-size: 1.45rem; }
}
