/* Stitchbay: its colours over the web iOS kit (src/ioskit/ios.css), the tab bar, and its own pieces: project cards,
   the counter, the row card and the pattern reader, pattern pages, the dictionary and the tools. Oatmeal linen and
   sea-green in light, deep wool and soft teal in dark. The pictures (js/art.js) read --sb-plate. */
:root {
  --canvas: #F4EFE8; --grouped: #F4EFE8; --row: #FFFDF9; --card: #FFFDF9;
  --sea: #2F6F69; --tint: var(--sea); --forest: var(--sea); --coral: var(--sea);
  --text2: rgba(40, 46, 44, 0.62); --text3: rgba(40, 46, 44, 0.32); --sep: rgba(40, 46, 44, 0.15);
  --fill: rgba(60, 90, 85, 0.12); --fill2: rgba(60, 90, 85, 0.08);
  --glass: rgba(255, 253, 249, 0.86); --glass-edge: rgba(30, 50, 45, 0.08);
  --sb-plate: #ECE3D7; --sb-gold: #C48A1E; --sb-rose: #B5523B; --sb-hi: rgba(47, 111, 105, 0.13);
  --tabbar-space: calc(var(--sab) + 108px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #111514; --grouped: #111514; --row: #1D2321; --card: #1D2321;
    --sea: #7CC5BA; --text: #EEF2EF; --text2: rgba(238, 242, 239, 0.62); --text3: rgba(238, 242, 239, 0.3); --sep: rgba(238, 242, 239, 0.12);
    --fill: rgba(170, 220, 210, 0.13); --fill2: rgba(170, 220, 210, 0.08);
    --glass: rgba(34, 41, 39, 0.84); --glass-edge: rgba(220, 255, 245, 0.08);
    --sb-plate: #2B3330; --sb-gold: #E6B455; --sb-rose: #E48B73; --sb-hi: rgba(124, 197, 186, 0.16);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #111514; --grouped: #111514; --row: #1D2321; --card: #1D2321;
  --sea: #7CC5BA; --text: #EEF2EF; --text2: rgba(238, 242, 239, 0.62); --text3: rgba(238, 242, 239, 0.3); --sep: rgba(238, 242, 239, 0.12);
  --fill: rgba(170, 220, 210, 0.13); --fill2: rgba(170, 220, 210, 0.08);
  --glass: rgba(34, 41, 39, 0.84); --glass-edge: rgba(220, 255, 245, 0.08);
  --sb-plate: #2B3330; --sb-gold: #E6B455; --sb-rose: #E48B73; --sb-hi: rgba(124, 197, 186, 0.16);
  color-scheme: dark;
}
body { background: var(--canvas); }
.btn-primary { --btn: var(--sea); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0D1F1C; } }
:root[data-theme="dark"] .btn-primary { color: #0D1F1C; }

/* ---------- tabs ---------- */
#stack .tab-pane { position: absolute; inset: 0; }
#stack .screen-body { padding-bottom: var(--tabbar-space); }
.tabbar { position: absolute; z-index: 10; left: 50%; bottom: calc(var(--sab) + 18px); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 70px); padding: 4px; border-radius: 34px;
  background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); box-shadow: 0 0 0 0.5px var(--glass-edge), 0 8px 30px rgba(10, 30, 25, 0.14); --i: 0; }
.tab-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: 70px; border-radius: 30px; background: var(--fill); transform: translateX(calc(var(--i) * 100%)); transition: transform 0.38s var(--ease); }
.tab-item { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; border-radius: 30px; color: var(--text); }
.tab-item.on { color: var(--sea); }
.tab-icon { width: 26px; height: 26px; display: grid; place-items: center; }
.tab-icon svg { width: 26px; height: 26px; }
.tab-label { font-size: 10px; line-height: 12px; font-weight: 600; letter-spacing: 0.01em; }
.tab-item:active .tab-icon { transform: scale(0.92); }
body.has-sheet .tabbar, body.counting .tabbar { visibility: hidden; }
@media (min-width: 700px) {
  .tabbar { bottom: auto; top: calc(var(--sat) + 8px); grid-template-columns: repeat(5, 108px); padding: 3px; border-radius: 26px; }
  .tab-pill { top: 3px; bottom: 3px; left: 3px; width: 108px; border-radius: 22px; }
  .tab-item { flex-direction: row; gap: 6px; height: 44px; border-radius: 22px; }
  .tab-icon, .tab-icon svg { width: 20px; height: 20px; }
  .tab-label { font-size: 15px; line-height: 20px; }
  #stack .screen.tab-root .nav-title { visibility: hidden; }
  #stack .screen-body { padding-bottom: calc(var(--sab) + 32px); }
}

/* ---------- shared ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; width: 100%; }
.big-title { font: 700 32px/38px var(--serif); letter-spacing: -0.01em; padding: 4px 4px 2px; }
.lede { color: var(--text2); font-size: 16px; line-height: 22px; padding: 0 4px 6px; }
.sec-h { font: 600 20px/26px var(--serif); padding: 24px 4px 10px; display: flex; align-items: baseline; gap: 8px; }
.sec-h .grow { flex: 1; }
.sec-h .text-btn { font: 600 15px var(--sys); color: var(--sea); }
.pro-tag { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 9px; font: 700 10px/18px var(--sys); letter-spacing: 0.06em; color: #fff; background: var(--sb-gold); vertical-align: middle; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--fill); font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px; }
.art { display: block; }
.art .sb-art { width: 100%; height: 100%; display: block; }
.empty { text-align: center; color: var(--text2); padding: 40px 20px; font-size: 15px; line-height: 21px; }
.empty .art { width: 120px; height: 120px; margin: 0 auto 12px; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .r-title { font-weight: 600; }
.row .r-sub { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 1px; }
.row .r-end { color: var(--text2); font-size: 15px; white-space: nowrap; }
.row .thumb { width: 44px; height: 44px; flex: none; }
.seg-wrap { padding: 4px 0 8px; }
.note { color: var(--text2); font-size: 13px; line-height: 18px; padding: 6px 4px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.fact { background: var(--card); border-radius: 14px; padding: 10px 8px; text-align: center; box-shadow: 0 0 0 0.5px var(--sep); }
.fact b { display: block; font-size: 15px; line-height: 20px; }
.fact span { display: block; color: var(--text2); font-size: 12px; line-height: 16px; margin-top: 2px; }

/* ---------- project cards ---------- */
.pcard { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; background: var(--card); border-radius: 18px; padding: 12px 14px; margin: 0 0 10px; box-shadow: 0 0 0 0.5px var(--sep), 0 2px 10px rgba(20, 40, 35, 0.05); color: var(--text); }
.pcard .art { width: 64px; height: 64px; flex: none; }
.pcard .grow { flex: 1; min-width: 0; }
.pcard-name { font-weight: 700; font-size: 17px; line-height: 22px; }
.pcard-sub { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--fill); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--sea); }
.pcard-count { font: 700 26px/30px var(--sys); font-variant-numeric: tabular-nums; color: var(--sea); text-align: right; min-width: 44px; }
.pcard-count small { display: block; font-size: 11px; line-height: 13px; font-weight: 600; color: var(--text2); }
.new-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: 16px; background: var(--fill); color: var(--sea); font-weight: 700; font-size: 16px; margin: 4px 0 8px; }

/* ---------- a project: the counter ---------- */
.counter-main { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 10px; margin: 8px 0 6px; }
.count-btn { height: 64px; border-radius: 22px; background: var(--fill); color: var(--text); display: grid; place-items: center; }
.count-btn .sf { width: 26px; height: 26px; }
.count-big { height: 160px; border-radius: 28px; background: var(--card); box-shadow: 0 0 0 0.5px var(--sep), 0 6px 22px rgba(20, 40, 35, 0.07); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text); touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.count-big:active { transform: scale(0.985); }
.count-big .num { font: 700 72px/1 var(--sys); font-variant-numeric: tabular-nums; color: var(--sea); letter-spacing: -0.02em; }
.count-big .lbl { font-size: 14px; color: var(--text2); margin-top: 6px; font-weight: 600; }
.count-big .of { font-size: 13px; color: var(--text3); margin-top: 2px; }
.bump { animation: bump 0.22s var(--ease); }
@keyframes bump { 40% { transform: scale(1.06); } }
.reminder { display: flex; gap: 10px; align-items: center; background: color-mix(in srgb, var(--sb-gold) 18%, transparent); color: var(--text); border-radius: 14px; padding: 10px 12px; margin: 6px 0; font-size: 15px; line-height: 20px; }
.reminder .sf { color: var(--sb-gold); flex: none; }
.rowcard { background: var(--card); border-radius: 18px; padding: 14px 16px; margin: 10px 0; box-shadow: 0 0 0 0.5px var(--sep); }
.rowcard .eyebrow { margin-bottom: 4px; }
.rowcard .row-label { font-weight: 700; font-size: 15px; color: var(--sea); }
.rowcard .row-text { font-size: 18px; line-height: 26px; margin-top: 4px; }
.rowcard .row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rowcard .until { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 8px; }
.rowcard .next { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--sep); }
.mini-counters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.mini { background: var(--card); border-radius: 16px; padding: 10px 12px; box-shadow: 0 0 0 0.5px var(--sep); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.mini .mini-name { font-size: 13px; color: var(--text2); font-weight: 600; grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.mini .mini-name button { margin-left: auto; color: var(--text3); }
.mini .mini-num { font: 700 28px/32px var(--sys); font-variant-numeric: tabular-nums; }
.mini .mini-max { font-size: 13px; color: var(--text3); font-weight: 600; }
.mini .mini-btns { display: flex; gap: 6px; }
.mini .mini-btns button { width: 38px; height: 38px; border-radius: 12px; background: var(--fill); display: grid; place-items: center; }
.timer-row { display: flex; align-items: center; gap: 10px; }
.timer-row b { font-variant-numeric: tabular-nums; }

/* ---------- the pattern text and reader ---------- */
.pat-head { display: flex; gap: 16px; align-items: center; padding: 8px 0 4px; }
.pat-head .art { width: 104px; height: 104px; flex: none; }
.pat-name { font: 700 28px/33px var(--serif); letter-spacing: -0.01em; }
.pat-blurb { color: var(--text2); font-size: 16px; line-height: 23px; margin: 8px 4px 4px; }
.ptext { background: var(--card); border-radius: 18px; padding: 6px 16px 10px; margin: 8px 0; box-shadow: 0 0 0 0.5px var(--sep); }
.ptext h3 { font: 600 18px/24px var(--serif); padding: 12px 0 4px; }
.ptext p { font-size: 16px; line-height: 24px; padding: 4px 0; }
.pline { display: block; width: 100%; text-align: left; font-size: 16px; line-height: 24px; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; color: var(--text); }
.pline b { color: var(--sea); font-weight: 700; }
.pline.rep { color: var(--text2); font-style: italic; }
.pline.here { background: var(--sb-hi); box-shadow: inset 3px 0 0 var(--sea); }
.pline.done { color: var(--text3); }
.pline.done b { color: var(--text3); }
.locked { position: relative; max-height: 220px; overflow: hidden; }
.locked::after { content: ""; position: absolute; inset: auto 0 0; height: 120px; background: linear-gradient(transparent, var(--card)); }
.keytab { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 20px; }
.keytab td { padding: 7px 4px; border-bottom: 0.5px solid var(--sep); vertical-align: top; }
.keytab td:first-child { font-weight: 700; white-space: nowrap; width: 1%; padding-right: 12px; }
.sizes { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.size-btn { height: 34px; padding: 0 14px; border-radius: 17px; background: var(--fill); font-weight: 600; font-size: 14px; color: var(--text); }
.size-btn.on { background: var(--sea); color: var(--row); }

/* PDFs and photos of your own patterns */
.reader { position: relative; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--sep); margin: 8px 0; touch-action: pan-y pinch-zoom; }
.reader canvas, .reader img { display: block; width: 100%; height: auto; }
.reader .hl { position: absolute; left: 0; right: 0; background: rgba(255, 214, 90, 0.38); border-top: 2px solid rgba(214, 150, 20, 0.9); border-bottom: 2px solid rgba(214, 150, 20, 0.9); pointer-events: none; transition: top 0.25s var(--ease); mix-blend-mode: multiply; }
.reader .shade { position: absolute; left: 0; right: 0; background: rgba(0, 0, 0, 0.08); pointer-events: none; }
.reader-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; }
.reader-bar .pages { color: var(--text2); font-size: 14px; font-weight: 600; }

/* ---------- patterns list ---------- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.ptile { display: flex; flex-direction: column; text-align: left; background: var(--card); border-radius: 18px; padding: 10px 12px 12px; box-shadow: 0 0 0 0.5px var(--sep); color: var(--text); }
.ptile .art { width: 100%; aspect-ratio: 1; }
.ptile-name { font-weight: 700; font-size: 15px; line-height: 20px; margin-top: 6px; }
.ptile-sub { color: var(--text2); font-size: 13px; line-height: 17px; margin-top: 2px; }
.level { display: inline-flex; gap: 2px; vertical-align: middle; }
.level i { width: 6px; height: 6px; border-radius: 3px; background: var(--text3); }
.level i.on { background: var(--sea); }

/* ---------- learn ---------- */
.sym-cell { width: 44px; height: 44px; flex: none; display: grid; place-items: center; color: var(--text); }
.sym-big { width: 96px; height: 96px; margin: 8px auto; color: var(--text); display: block; }
.sym-big svg { width: 96px; height: 96px; }
.st-name { font: 700 24px/30px var(--serif); text-align: center; }
.st-abbr { text-align: center; color: var(--text2); font-weight: 600; margin-top: 2px; }
.st-desc { font-size: 17px; line-height: 25px; padding: 12px 4px; }

/* lessons */
:root { --sb-ink: #3a3a36; --sb-yarn: #c8553d; --sb-new: #2f6f69; --sb-wood: #c9a26b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sb-ink: #e6ebe8; --sb-yarn: #e48b73; --sb-new: #7cc5ba; --sb-wood: #b48b56; } }
:root[data-theme="dark"] { --sb-ink: #e6ebe8; --sb-yarn: #e48b73; --sb-new: #7cc5ba; --sb-wood: #b48b56; }
.diagram { margin: 8px 0 4px; } .diagram svg { width: 100%; height: auto; display: block; max-height: 46vh; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0; }
.dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--text3); } .dots i.past { background: var(--text2); } .dots i.on { background: var(--sea); width: 18px; }
.lesson-step { padding: 4px 4px 0; } .lesson-t { font: 700 22px/28px var(--serif); margin: 2px 0 0; }
.lesson-nav { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 8px; }
.lesson-nav button { height: 50px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.lesson-n { width: 30px; height: 30px; border-radius: 15px; background: var(--fill); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--sea); flex: none; }
.lesson-n.done { background: var(--sea); color: var(--row); }

/* ---------- tools ---------- */
.result { background: var(--card); border-radius: 18px; padding: 16px; margin: 10px 0; box-shadow: 0 0 0 0.5px var(--sep); }
.result .big { font: 700 34px/40px var(--sys); color: var(--sea); font-variant-numeric: tabular-nums; }
.result .say { font-size: 17px; line-height: 25px; margin-top: 6px; }
.result .r-sub { color: var(--text2); font-size: 14px; line-height: 19px; margin-top: 6px; }
.result .err { color: var(--sb-rose); font-size: 15px; }
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.ttable { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 20px; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--sep); }
.ttable th, .ttable td { padding: 9px 10px; text-align: left; border-bottom: 0.5px solid var(--sep); }
.ttable th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text2); font-weight: 700; }
.ttable tr:last-child td { border-bottom: 0; }
.convert-out { white-space: pre-wrap; font-size: 16px; line-height: 24px; background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: 0 0 0 0.5px var(--sep); min-height: 60px; }
.swatch { width: 28px; height: 28px; border-radius: 14px; flex: none; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.2); }

/* ---------- charts ---------- */
.chart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart-actions .new-btn { margin: 4px 0 8px; font-size: 15px; }
.chart-thumb { width: 100%; aspect-ratio: 1; display: grid; place-items: center; background: var(--sb-plate); border-radius: 12px; padding: 10px; }
.chart-thumb .sb-art { width: 100%; height: 100%; }
.chart-preview { max-width: 280px; margin: 8px auto; background: var(--sb-plate); border-radius: 14px; padding: 12px; }
.palette { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: none; }
.pal { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 58px; color: var(--text); }
.pal-dot { width: 38px; height: 38px; border-radius: 19px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18); }
.pal.on .pal-dot { box-shadow: 0 0 0 3px var(--canvas), 0 0 0 5px var(--sea); }
.pal-name { font-size: 11px; line-height: 13px; font-weight: 600; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.pal.add { justify-content: flex-start; } .pal.add .sf { width: 38px; height: 38px; border-radius: 19px; background: var(--fill); padding: 9px; color: var(--sea); }
.chart-bar { display: flex; align-items: center; gap: 6px; padding: 4px 0 8px; }
.chart-size { color: var(--text2); font-size: 13px; font-weight: 600; text-align: center; }
.grid-wrap { overflow: auto; max-height: 62vh; border-radius: 12px; background: var(--card); box-shadow: 0 0 0 0.5px var(--sep); padding: 8px; display: flex; justify-content: center; align-items: flex-start; }
.grid { display: block; touch-action: none; cursor: crosshair; flex: none; }
.runs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.run { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px 0 6px; border-radius: 16px; background: var(--fill); font-size: 15px; }
.run::before { content: ""; width: 20px; height: 20px; border-radius: 10px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2); }
.run b { font-variant-numeric: tabular-nums; }

@media print {
  .tabbar, .navbar, #sheets, .no-print { display: none !important; }
  .screen-body { overflow: visible !important; padding: 0 !important; }
  .ptext { box-shadow: none; }
  .pline.here { background: none; box-shadow: none; }
}
/* the Patterns tab's kind filter */
.kchips { margin: 0 -16px 4px; padding: 2px 16px 8px; }
.kchip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 17px; border: 0; background: var(--fill2); color: var(--text); font: 500 15px var(--sys); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.kchip-n { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }
.kchip.on { background: var(--sea); color: #fff; }
.kchip.on .kchip-n { color: rgba(255, 255, 255, 0.8); }
.kchip:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }
