/* Backgrounds and text follow the Telegram theme (light or dark); the accent is the app's own:
   pink for women, blue for men (set by data-gender on <html>). */
:root {
  --brand: #c2527a;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f3f2f7);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --accent: var(--brand);
  --accent-text: #ffffff;
  --link: var(--brand);
  --danger: var(--tg-theme-destructive-text-color, #d93a3a);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --radius: 14px;
  --gap: 12px;
  color-scheme: light dark;
}
:root[data-gender="male"] { --brand: #2f6fdb; }
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #1c1c1e; --bg2: #000000; --text: #f2f2f7; --hint: #8e8e93; --card: #2c2c2e;
  }
}
* { box-sizing: border-box; }
button, .chip, .praise, #tabs button { transition: background-color .25s, color .25s, border-color .25s; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.hint { color: var(--hint); font-size: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.card.accent { border: 2px solid var(--accent); }
.stack > * + * { margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
button, .btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-text); cursor: pointer; width: 100%; text-align: center; display: block;
}
button.secondary { background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--accent); }
button.link { background: none; color: var(--link); padding: 8px 0; width: auto; font-weight: 500; }
button.danger { background: none; color: var(--danger); }
button:disabled { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px; width: auto; font-weight: 500;
}
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 0; border-radius: 12px; padding: 12px;
}
textarea { min-height: 120px; resize: vertical; }
label.check { display: flex; gap: 10px; align-items: flex-start; }
label.check input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.dots { padding-left: 20px; margin: 0; }
ul.dots li + li { margin-top: 4px; }
.map img { width: 100%; border-radius: var(--radius); display: block; background: var(--bg2); min-height: 200px; }
.item { padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); }
.item:last-child { border-bottom: 0; }
.level { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.level i { width: 14px; height: 8px; border-radius: 3px; background: color-mix(in srgb, var(--hint) 25%, transparent); }
.level i.on { background: var(--accent); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); }
.verdict { font-weight: 700; font-size: 18px; }
.verdict-suitable { color: #2e9e5b; } .verdict-caution { color: #c98a00; } .verdict-not_suitable { color: var(--danger); }
.pre { white-space: pre-wrap; }
.progress li { padding: 6px 0; color: var(--hint); }
.progress li.done { color: var(--text); }
.progress li.active { color: var(--text); font-weight: 600; }
.progress li::before { content: "○ "; }
.progress li.done::before { content: "✓ "; color: #2e9e5b; }
.progress li.active::before { content: "◌ "; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bg2); border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-wrap { overflow-x: auto; }
table.levels { border-collapse: collapse; font-size: 14px; width: 100%; }
table.levels th, table.levels td { padding: 6px 6px; text-align: center; white-space: nowrap; }
table.levels th:first-child, table.levels td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
td.l0 { color: var(--hint); }
td.l1 { background: color-mix(in srgb, var(--accent) 15%, transparent); }
td.l2 { background: color-mix(in srgb, var(--accent) 30%, transparent); }
td.l3 { background: color-mix(in srgb, var(--accent) 50%, transparent); }
td.l4 { background: color-mix(in srgb, var(--accent) 70%, transparent); color: var(--accent-text); }
.msgs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.msg { padding: 10px 12px; border-radius: 16px; max-width: 85%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border-bottom-left-radius: 4px; }
.composer { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--bg2); padding: 8px 0; }
.composer button { width: auto; }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
#tabs button { background: none; color: var(--hint); border-radius: 0; padding: 10px 2px 12px; font-size: 11px; font-weight: 500; }
#tabs button .ico { display: block; font-size: 20px; line-height: 1.2; }
#tabs button.on { color: var(--accent); }
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 10; font-size: 14px;
}
.hidden-input { display: none; }
.tips .tip { padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--hint) 20%, transparent); }
.tips .tip:last-child { border-bottom: 0; }
.tips .tip.link { color: var(--link); cursor: pointer; }
.badge.streak { background: color-mix(in srgb, var(--accent) 15%, var(--card)); color: var(--accent); font-size: 14px; font-weight: 600; }
.praise { background: color-mix(in srgb, var(--accent) 10%, var(--card)); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 var(--gap); }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.card > summary::after { content: " ▾"; color: var(--hint); }
details[open].card > summary::after { content: " ▴"; }
.suggestions { margin-bottom: 12px; }
.suggestions .chip { text-align: left; }

/* weather & skin */
.weather .metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.metric { padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--hint) 10%, transparent); }
.metric b { display: block; font-size: 18px; margin: 2px 0; }
.metric.warn { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.metric .hint { font-size: 12px; }
ul.advice { margin: 0; padding-left: 18px; list-style: disc; }
ul.advice li { margin: 4px 0; }
/* tip of the day */
details.daily > summary > span.hint { display: block; font-weight: 500; }
details.daily > summary h2 { display: block; margin: 4px 0; }
details.daily > summary p { font-weight: 400; margin: 4px 0; }
details.daily > summary::after, details[open].daily > summary::after { content: none; }
details[open].daily > summary > p { display: none; }
details.daily .more { color: var(--accent); font-weight: 500; font-size: 14px; }
details[open].daily .more { display: none; }
details.card > summary h2 { display: inline; }
details.card > summary > p { font-weight: 400; }
table.levels.bars .level { margin-right: 0; }
table.levels.bars .level i { width: 8px; }
/* levels infographic */
.meter-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 8px; }
.meter { height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--hint) 18%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.meter i.l0 { background: color-mix(in srgb, var(--hint) 45%, transparent); }
.meter i.l1 { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.meter i.l2 { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.meter-word { font-size: 12px; min-width: 72px; text-align: right; }
.plan .item { gap: 4px; }
.date-picker { display: grid; grid-template-columns: 1fr 2fr 1.3fr; gap: 8px; }
.date-picker select { width: 100%; }
.map img.loading { min-height: 320px; border-radius: 12px; background: color-mix(in srgb, var(--hint) 12%, transparent); }
/* in-app camera */
.cam-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.cam-wrap video.cam { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-wrap .oval { position: absolute; left: 50%; top: 46%; width: 64%; height: 72%; transform: translate(-50%, -50%);
  border: 3px dashed rgba(255, 255, 255, .85); border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); pointer-events: none; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px #000; }
.cam-actions { justify-content: space-between; align-items: center; margin-top: 14px; }
.cam-actions .link { width: auto; flex: 1; }
.shutter { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 50%; padding: 0; background: var(--accent);
  border: 5px solid color-mix(in srgb, var(--accent) 30%, var(--card)); }
