/* Тема «Лаин»: всегда тёмная, своя палитра (не зависит от темы Telegram).
   Почти чёрный с сине-фиолетовым отливом, акцент — холодный циан, второй — мягкий фиолетовый. */
:root {
  color-scheme: dark;
  --bg: #07070d;
  --card: #10101b;
  --card-2: #161626;
  --text: #e9e7f5;
  --hint: #8b88a8;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --accent-text: #05101a;
  --head: #9d95d6;
  --link: #7dd3fc;
  --line: rgba(157, 149, 214, .14);
  --soft: rgba(125, 211, 252, .08);
  --glow: 0 0 14px rgba(125, 211, 252, .35);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 560px; margin: 0 auto; padding: 8px 12px calc(96px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:active { opacity: .7; }
a { color: inherit; }

.hero { padding: 22px 6px 16px; }
.kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.hero h1 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -.01em; }
.hero .hint { margin: 0; }

.tiles { display: grid; gap: 10px; }
.tile { display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
  text-align: left; text-decoration: none; padding: 16px; border-radius: var(--radius); background: var(--card); }
.tile .ico { grid-row: span 2; width: 48px; height: 48px; display: grid; place-items: center; font-size: 26px;
  border-radius: 14px; background: var(--soft); }
.tile .t { font-size: 17px; font-weight: 600; }
.tile .s { font-size: 14px; color: var(--hint); }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-h h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--head); }
.hint { color: var(--hint); font-size: 13px; }

.dayhead { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 4px; }
.dayhead .nav { width: 42px; height: 42px; border-radius: 50%; background: var(--card); font-size: 24px; line-height: 1; }
.dayhead .nav:disabled { opacity: .3; }
.dayhead .date { text-align: center; }
.dayhead .date b { display: block; font-size: 21px; }
.dayhead .date small { color: var(--hint); font-size: 13px; }
.tabs { margin: 10px 0 2px; }

.scale { display: grid; grid-template-columns: repeat(auto-fit, minmax(27px, 1fr)); gap: 5px; }
.scale button { height: 42px; border-radius: 11px; background: var(--soft); font-weight: 600;
  font-variant-numeric: tabular-nums; transition: transform .08s ease, background .15s ease; }
.scale button.on { background: var(--accent); color: var(--accent-text); transform: scale(1.07); }

.seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--soft); }
.seg button { flex: 1; padding: 9px 6px; border-radius: 9px; font-weight: 500; font-size: 15px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
.tabs .seg button.on { background: var(--accent); color: var(--accent-text); }

.stepper, .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; }
.stepper + .stepper, .stepper + .row { border-top: 1px solid var(--line); }
.row .seg { min-width: 140px; }
.lbl { flex: 1; }
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl button { width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: var(--accent); font-size: 22px; line-height: 1; }
.val { min-width: 56px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.calc { display: block; margin-top: 6px; color: var(--accent); font-size: 13px; font-weight: 600; min-height: 1em; }

.stackrow { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.stackrow + .stackrow { border-top: 1px solid var(--line); }
.check { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line); color: transparent;
  display: grid; place-items: center; font-size: 16px; font-weight: 700; transition: background .15s ease; }
.stackrow.on .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.stackrow .name { flex: 1; }
.stackrow:not(.on) .name { color: var(--hint); text-decoration: line-through; text-decoration-color: var(--line); }
.tag { color: var(--hint); font-size: 12px; text-decoration: none; }
.dose { display: flex; align-items: center; gap: 6px; }
.dose input { width: 76px; text-align: right; }
.unit { color: var(--hint); font-size: 14px; min-width: 22px; }

.toggle { display: block; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; text-align: left;
  background: var(--soft); font-weight: 500; }
.toggle.on { background: var(--accent); color: var(--accent-text); }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; }
textarea { width: 100%; min-height: 88px; resize: vertical; }
.addsel { width: 100%; margin-top: 10px; color: var(--link); }

.loading, .empty { padding: 56px 16px; text-align: center; color: var(--hint); }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 10; max-width: 90vw;
  padding: 10px 16px; border-radius: 12px; background: rgba(28, 28, 30, .92); color: #fff; font-size: 14px; text-align: center;
  opacity: 0; transform: translate(-50%, 16px); transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#fallback-main { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); height: 52px;
  border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- «Лаин»: атмосфера и акценты ---- */
body { background:
  radial-gradient(900px 520px at 50% -12%, rgba(124, 58, 237, .20), transparent 62%),
  radial-gradient(700px 420px at 110% 30%, rgba(14, 165, 233, .07), transparent 60%),
  var(--bg); background-attachment: fixed; min-height: 100vh; }
.kicker { font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .38em; color: var(--accent-2); }
.hero h1 { font-weight: 600; }
.card, .tile, .dayhead .nav { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); }
.tile .ico, .ctl button, .scale button, .seg { background: var(--soft); }
.tile:active, .card:active { border-color: rgba(125, 211, 252, .25); }
.card-h h2 { color: var(--head); letter-spacing: .14em; font-size: 12px; }
.scale button { color: var(--text); border: 1px solid transparent; }
.scale button.on, .tabs .seg button.on, .toggle.on, .stackrow.on .check {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); box-shadow: var(--glow); border-color: transparent; }
.seg button.on { background: var(--card-2); box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .35); color: var(--accent); }
.ctl button { color: var(--accent); border: 1px solid var(--line); }
.toggle { border: 1px solid var(--line); }
.calc { color: var(--accent); text-shadow: 0 0 10px rgba(125, 211, 252, .35); }
input, select, textarea { background: rgba(255, 255, 255, .03); border-color: var(--line); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(125, 211, 252, .5); box-shadow: 0 0 0 3px rgba(125, 211, 252, .12); }
textarea::placeholder { color: rgba(139, 136, 168, .7); }
#fallback-main { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-text); box-shadow: var(--glow); }
#toast { background: rgba(16, 16, 27, .95); border: 1px solid var(--line); color: var(--text); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
