:root {
  --bg: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #14161a);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #2357d9);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(127, 127, 127, .18);
  --danger: #c2362b;
  --ok: #1f8a4c;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { padding: 16px 14px 88px; max-width: 560px; margin: 0 auto; }
h1 { font-size: 24px; margin: 4px 2px 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px 14px; }
.head h1 { margin-bottom: 2px; }
.head { margin-bottom: 12px; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: transparent; border-radius: 10px;
  padding: 9px 12px; cursor: pointer; min-height: 40px;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: 0; padding: 8px 0; color: var(--accent); text-align: left; }
button:disabled { opacity: .5; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
  background: var(--card); min-height: 40px;
}
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row > button { flex: 1 1 auto; }
.row > input { flex: 1 1 160px; width: auto; }

.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 10px; }
.bar span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.chips li { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); }

.steps { list-style: none; padding: 0; margin: 0; }
.step { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.step.done .dot { background: var(--ok); border-color: var(--ok); }
.step.done span:last-child { color: var(--muted); text-decoration: line-through; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.list li:first-child { border-top: 0; }
.list li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .sub { display: block; color: var(--muted); font-size: 13px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.glance { color: var(--muted); font-style: italic; }
.glance:empty { display: none; }

details { border-top: 1px solid var(--line); }
details:first-child { border-top: 0; }
summary { padding: 10px 0; cursor: pointer; font-weight: 600; }
.field { margin: 0 0 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field .note { font-size: 12px; color: var(--muted); margin-top: 3px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: flex; gap: 6px; align-items: center; margin: 0; color: var(--text); font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.checks input { width: auto; min-height: 0; }
.saved { color: var(--ok); }

nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav button { flex: 1; border: 0; border-radius: 0; padding: 12px 4px; color: var(--muted); font-size: 13px; }
nav button.on { color: var(--accent); font-weight: 600; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 10; }
.modal[hidden] { display: none; }
.modal .sheet { background: var(--card); width: 100%; border-radius: 16px 16px 0 0; padding: 18px 16px 24px; }
.modal ul { padding-left: 18px; margin: 6px 0 12px; }
.toast { position: fixed; left: 14px; right: 14px; bottom: 72px; background: #222; color: #fff;
  padding: 10px 14px; border-radius: 10px; z-index: 11; }
.toast[hidden] { display: none; }
