/* Quiltday. Paper and thread colors, one stylesheet for the site and the app. */
:root {
  --paper: #fbf7f0;
  --card: #ffffff;
  --ink: #2b2623;
  --muted: #6f655d;
  --line: #e7ddd0;
  --empty: #efe7db;
  --accent: #b5512f;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d9;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1916;
    --card: #26221e;
    --ink: #f1ebe3;
    --muted: #b3a89c;
    --line: #3a342e;
    --empty: #332d28;
    --accent: #e0774f;
    --accent-ink: #1c1916;
    --accent-soft: #3d2a20;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(30px, 5.4vw, 48px); letter-spacing: -.01em; }
h2 { font-size: clamp(22px, 3.4vw, 30px); margin-top: 1.4em; }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 620px; margin: 0 auto; padding: 0 14px 90px; }

.site-head, .app-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; font: 700 21px var(--serif); color: var(--ink); text-decoration: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 15px var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: #b3261e; }
.btn:disabled { opacity: .5; cursor: default; }
button.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

/* landing */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; padding: 34px 0 30px; }
.hero .lead { font-size: 19px; color: var(--muted); max-width: 34em; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.demo { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.demo-row { margin-bottom: 14px; }
.demo-row:last-child { margin-bottom: 0; }
.demo-row b { font-size: 14px; display: block; margin-bottom: 6px; }
.section { padding: 26px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.tile h3 { margin-bottom: 6px; }
.tile p:last-child { margin-bottom: 0; }
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.price { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.price.pro { border: 2px solid var(--accent); }
.price .amt { font: 700 34px var(--serif); }
.price ul { padding-left: 20px; margin: 10px 0 16px; }
.faq { border-top: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; color: var(--muted); }
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 26px 0 40px; color: var(--muted); font-size: 14px; }
.site-foot .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }
.site-foot h3 { font: 600 14px var(--sans); color: var(--ink); }
.site-foot ul { list-style: none; padding: 0; margin: 0; }
.site-foot li { margin: 4px 0; }
.prose { padding-bottom: 20px; }
.crumbs { font-size: 14px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
thead th { font-weight: 700; }
tbody th { width: 24%; color: var(--muted); font-weight: 600; }

/* quilt grid: weeks are columns, days are rows */
.quilt { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell, 11px)); grid-auto-columns: var(--cell, 11px); gap: var(--gap, 3px); }
.quilt i { display: block; border-radius: 3px; background: var(--empty); }
.quilt i.on { background: var(--c, var(--accent)); }
.quilt i.part { background: color-mix(in srgb, var(--c, var(--accent)) 45%, var(--empty)); }
.quilt i.slip { background: repeating-linear-gradient(45deg, var(--empty) 0 2px, #c9573a 2px 4px); }
.quilt i.off { background: transparent; }
.quilt i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.quilt-scroll { overflow-x: auto; padding: 4px 3px 6px; }
.quilt.big { --cell: 15px; }
.quilt.big i { cursor: pointer; }
.months { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell, 15px); gap: 3px; font-size: 11px; color: var(--muted); height: 16px; white-space: nowrap; }

/* app */
.app-main { min-height: 60vh; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.habit-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.habit-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.habit-name { flex: 1; min-width: 0; }
.habit-name a { color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit-name .sub { font-size: 13px; color: var(--muted); }
.check { width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--c); background: transparent; color: var(--c); font: 700 20px var(--sans); cursor: pointer; flex: none; display: grid; place-items: center; }
.check.done { background: var(--c); color: #fff; }
.check.count { font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--paper); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font: 700 22px var(--serif); }
.stat span { font-size: 12px; color: var(--muted); }
label.field { display: block; margin-bottom: 14px; font-weight: 600; font-size: 15px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=number], select, textarea { width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 16px var(--sans); }
textarea { min-height: 80px; resize: vertical; }
.swatches, .icons, .seg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; }
.swatches button[aria-pressed=true] { border-color: var(--ink); }
.icons button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-size: 20px; cursor: pointer; }
.icons button[aria-pressed=true] { border: 2px solid var(--accent); background: var(--accent-soft); }
.seg button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.empty-state { text-align: center; padding: 30px 10px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 8px; }
.bars div { flex: 1; background: var(--c, var(--accent)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars-labels { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 15px; z-index: 50; max-width: 90vw; }
.locked { position: relative; }
.locked .blur { filter: blur(4px); pointer-events: none; user-select: none; }
.locked .over { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10px; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
.tabbar a { flex: 1; max-width: 140px; text-align: center; padding: 8px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.tabbar a[aria-current=page] { color: var(--ink); background: var(--paper); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: end center; z-index: 40; }
.sheet .card { width: min(560px, 100%); margin: 0; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; background: var(--empty); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
