:root {
  --bg: var(--tg-theme-bg-color, #f4f6fb);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a2e);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --accent: var(--tg-theme-button-color, #4f7cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --green: #2fbf71;
  --amber: #f2a33c;
  --red: #e2564b;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: -apple-system, "SF Pro Text", Roboto, "Segoe UI", sans-serif; }
body { padding-bottom: 84px; }

#app { padding: 14px 14px 0; max-width: 560px; margin: 0 auto; }

.boot { text-align: center; padding-top: 30vh; color: var(--hint); }
.boot-pill { font-size: 56px; animation: float 1.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }

.hero {
  border-radius: 22px; padding: 18px;
  background: linear-gradient(135deg, #4f7cff 0%, #38b6a5 100%);
  color: #fff; margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(79, 124, 255, .25);
  display: flex; align-items: center; gap: 14px;
}
.hero .ring { flex-shrink: 0; position: relative; width: 74px; height: 74px; }
.hero .ring svg { transform: rotate(-90deg); }
.hero .ring .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.hero h1 { font-size: 19px; margin-bottom: 3px; }
.hero p { font-size: 13px; opacity: .92; }
.hero .badge { display: inline-block; margin-top: 7px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.22); padding: 3px 10px; border-radius: 999px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(20,30,60,.05); }
.card h2 { font-size: 16px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.card h2 .sub { font-size: 12px; color: var(--hint); font-weight: 400; }

.dose { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid rgba(128,140,170,.14); }
.dose:last-child { border-bottom: none; }
.dose .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; width: 52px; }
.dose .info { flex: 1; min-width: 0; }
.dose .info b { font-size: 15px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose .info small { color: var(--hint); font-size: 12px; }
.dose .act { display: flex; gap: 8px; }
.dose .act button {
  width: 40px; height: 40px; border-radius: 13px; border: none; font-size: 17px;
  background: rgba(128,140,170,.12); color: var(--text); transition: transform .1s;
}
.dose .act button:active { transform: scale(.9); }
.dose .act .ok { background: rgba(47,191,113,.16); }
.dose .status { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.s-taken   { background: rgba(47,191,113,.15); color: var(--green); }
.s-skipped { background: rgba(128,140,170,.18); color: var(--hint); }
.s-missed  { background: rgba(226,86,75,.14); color: var(--red); }
.s-pending { background: rgba(242,163,60,.16); color: var(--amber); }
.s-future  { background: rgba(79,124,255,.12); color: var(--accent); }

.empty { text-align: center; color: var(--hint); padding: 26px 10px; font-size: 14px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

.btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 15px;
  background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600;
  margin-top: 10px; transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: rgba(79,124,255,.1); color: var(--accent); }
.btn.soft { background: rgba(128,140,170,.12); color: var(--text); }
.btn.star { background: linear-gradient(135deg, #f7b733, #f2994a); color: #fff; }

.chiprow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid rgba(128,140,170,.3);
  background: transparent; color: var(--text); font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.medrow { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid rgba(128,140,170,.14); }
.medrow:last-child { border-bottom: none; }
.medrow .pillico { width: 42px; height: 42px; border-radius: 13px; background: rgba(79,124,255,.12); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.medrow .m { flex: 1; min-width: 0; }
.medrow .m b { display: block; font-size: 15px; }
.medrow .m small { color: var(--hint); font-size: 12px; }
.medrow .m small.rep { display: block; margin-top: 2px; }
.medrow .del { border: none; background: none; font-size: 17px; color: var(--hint); padding: 8px; }

.icon-btn { border: none; background: rgba(128,140,170,.12); color: var(--text); width: 28px; height: 28px; border-radius: 9px; font-size: 13px; flex-shrink: 0; }
.icon-btn:active { transform: scale(.92); }

.viewer { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.viewer .ava { width: 36px; height: 36px; border-radius: 50%; background: rgba(56,182,165,.18); display: flex; align-items: center; justify-content: center; }
.viewer .n { flex: 1; font-size: 14px; }
.viewer small { color: var(--hint); display: block; font-size: 11px; }
.viewer button { border: none; background: none; color: var(--red); font-size: 13px; font-weight: 600; }

input[type=text], input[type=time], input[type=number], select {
  width: 100%; padding: 13px 14px; border-radius: 13px; font-size: 15px;
  border: 1.5px solid rgba(128,140,170,.3); background: var(--bg); color: var(--text);
  margin: 6px 0; outline: none;
}
input:focus { border-color: var(--accent); }
label { font-size: 13px; color: var(--hint); font-weight: 600; }

#nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 20;
  background: var(--card); box-shadow: 0 -4px 20px rgba(20,30,60,.08);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
#nav button {
  flex: 1; border: none; background: none; color: var(--hint); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px;
}
#nav button span { font-size: 21px; }
#nav button.active { color: var(--accent); background: rgba(79,124,255,.08); }

#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 82vh; overflow-y: auto; transform: translateY(0); transition: transform .25s;
}
#sheet.hidden { transform: translateY(110%); }
#sheet h3 { font-size: 17px; margin-bottom: 10px; }
#sheet-backdrop { position: fixed; inset: 0; background: rgba(10,15,30,.45); z-index: 30; opacity: 1; transition: opacity .25s; }
#sheet-backdrop.hidden { opacity: 0; pointer-events: none; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 60;
  background: rgba(20,25,40,.92); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; white-space: nowrap; transition: opacity .3s;
}
#toast.hidden { opacity: 0; pointer-events: none; }

.prem-hero {
  border-radius: 22px; padding: 20px; color: #fff; margin-bottom: 12px;
  background: linear-gradient(135deg, #f7b733 0%, #ec6f66 100%);
  box-shadow: 0 8px 24px rgba(236,111,102,.3);
}
.prem-hero h2 { font-size: 19px; margin-bottom: 6px; }
.prem-hero ul { list-style: none; margin-top: 8px; }
.prem-hero li { font-size: 14px; padding: 3px 0; }
.hidden { display: none !important; }
.week { font-size: 12px; color: var(--hint); margin-top: 8px; }
.illus { width: 130px; border-radius: 20px; display: block; margin: 0 auto 10px; }
.prem-img { width: 100%; border-radius: 14px; display: block; margin-bottom: 12px; }
