:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #777);
  --link: var(--tg-theme-link-color, #2a7fff);
  --btn: var(--tg-theme-button-color, #2a7fff);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --danger: #d33;
  --ok: #2a9d5c;
  --we: #d66;
  --teal: #2bb3a3;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg2); color: var(--text); }
#app { padding: 12px 12px 140px; max-width: 640px; margin: 0 auto; }
button { font: inherit; color: inherit; }
.loading, .empty { text-align: center; color: var(--hint); padding: 40px 0; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 14px 0 6px; font-weight: 600; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.top { margin: 4px 0 14px; min-height: 32px; }
.x { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--bg); color: var(--hint); font-size: 15px; }
.back { background: none; border: 0; color: var(--link); font-size: 16px; padding: 0; }
.seg { display: flex; gap: 6px; margin: 0 0 12px; }
.seg button { flex: 1; padding: 11px 4px; border: 0; border-radius: 10px; background: var(--bg); color: var(--text); font-size: 14px; white-space: nowrap; }
.seg button.on { background: var(--btn); color: var(--btn-text); font-weight: 600; }
.squares { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.squares.n3 { grid-template-columns: repeat(3, calc((100% - 40px) / 6)); justify-content: center; }
.squares.n4 { grid-template-columns: repeat(4, calc((100% - 40px) / 6)); justify-content: center; }
.seg { flex-wrap: wrap; }
.seg button { min-width: calc(33% - 6px); }
.squares button { width: 100%; aspect-ratio: 1; min-height: 48px; grid-column: auto; border: 0; border-radius: 12px; background: var(--bg); color: var(--text); font-size: 18px; font-weight: 600; }
.squares button.on { background: var(--btn); color: var(--btn-text); }
.card { background: var(--bg); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.cover { height: 96px; background: #222 center/cover no-repeat; }
.cover.big { height: 150px; }
.body { padding: 10px 12px; }
.title { font-weight: 600; font-size: 16px; margin: 0; }
.sub, .hint { color: var(--hint); font-size: 13px; margin: 2px 0 0; }
.hint.c { text-align: center; margin-top: 12px; font-size: 16px; color: var(--text); font-weight: 500; }
.tag { font-size: 12px; color: var(--hint); }
.tag.ok { color: var(--ok); }
.tag.wait { color: #c80; }
.list { margin: 4px 0 0; padding: 0; list-style: none; font-size: 14px; }
.list li { padding: 4px 0; border-bottom: 1px solid var(--bg2); }
.list li:last-child { border-bottom: 0; }
.list .b { color: var(--hint); font-size: 12px; }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; padding: 12px; border-radius: 10px; border: 0; font-size: 15px; font-weight: 500; background: var(--bg2); color: var(--text); text-align: center; text-decoration: none; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.fab { position: fixed; left: 12px; right: 12px; bottom: 76px; max-width: 616px; margin: 0 auto; padding: 14px; border-radius: 12px; border: 0; background: var(--btn); color: var(--btn-text); font-size: 16px; font-weight: 600; z-index: 5; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); border-top: 1px solid var(--bg2); padding: 6px 0 max(8px, env(safe-area-inset-bottom)); z-index: 6; }
.tabs button { flex: 1; border: 0; background: none; color: var(--hint); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--btn); font-weight: 600; }
label { display: block; font-size: 13px; color: var(--hint); margin: 14px 0 6px; }
input, select, textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 0; background: var(--bg); color: var(--text); font-size: 15px; }
textarea { min-height: 70px; resize: vertical; }
.field { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 0; border-radius: 10px; background: var(--bg); font-size: 15px; text-align: left; }
.field .ph { color: var(--hint); }
.field .chev { color: var(--hint); font-size: 20px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { position: relative; height: 84px; border: 0; border-radius: 10px; background: #333 center/cover no-repeat; padding: 0; overflow: hidden; outline: 3px solid transparent; }
.tile span { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; text-align: left; line-height: 1.2; }
.tile.on { outline-color: var(--btn); }
.tile.on span { background: var(--btn); color: var(--btn-text); }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 140px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: .95; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet { width: 100%; max-width: 640px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .row b { font-size: 16px; }
.nav { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--bg2); font-size: 20px; }
.nav:disabled { opacity: .3; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; margin-top: 10px; text-align: center; }
.cal .h { color: var(--hint); font-size: 12px; padding-bottom: 4px; }
.cal button { height: 40px; width: 40px; margin: 0 auto; border: 0; border-radius: 50%; background: none; font-size: 15px; }
.cal button.we { color: var(--we); }
.cal button.past { opacity: .3; }
.cal button.today { box-shadow: inset 0 0 0 1.5px var(--btn); }
.cal button.sel { background: var(--btn); color: var(--btn-text); font-weight: 600; }
.lbl { color: var(--hint); font-size: 13px; text-align: center; margin: 12px 0 6px; }
.time { display: flex; justify-content: center; align-items: center; gap: 10px; }
.time > b { font-size: 28px; }
.time > input { width: 76px; height: 104px; text-align: center; font-size: 32px; font-weight: 600; padding: 0; background: var(--bg2); -moz-appearance: textfield; }
.spin { display: flex; flex-direction: column; gap: 8px; }
.spin button { width: 48px; height: 48px; border: 0; border-radius: 12px; background: var(--bg2); font-size: 24px; font-weight: 600; }
.time input::-webkit-outer-spin-button, .time input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.card.featured { box-shadow: 0 0 0 3px var(--teal); }
.tile.featured { outline-color: var(--teal); }
.tile.on.featured { outline-color: var(--btn); }
.badge { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--teal); color: #fff; font-size: 11px; font-weight: 600; font-style: normal; line-height: 1.5; }
.tile .badge { position: absolute; top: 6px; left: 6px; margin: 0; }
