:root {
  color-scheme: light dark;
  --page: var(--tg-theme-bg-color, #f3f6fb);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #172333);
  --muted: var(--tg-theme-hint-color, #778397);
  --accent: var(--tg-theme-button-color, #1769e0);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 9%, transparent);
  --soft-accent: color-mix(in srgb, var(--accent) 10%, var(--card));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
}

.shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .04em;
}
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
h1 { margin: 0; font-size: 22px; line-height: 1.15; }
.intro { margin: 20px 2px 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.settings-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--text) 5%, transparent);
}
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 16px; }
.setting-copy { display: flex; min-width: 0; align-items: center; gap: 12px; }
.icon-box { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 14px; background: var(--soft-accent); color: var(--accent); font-size: 21px; font-weight: 700; }
h2 { margin: 0 0 5px; font-size: 15px; line-height: 1.25; }
.setting-copy p { max-width: 290px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.divider { height: 1px; margin-left: 70px; background: var(--line); }

.switch { position: relative; display: inline-flex; flex: 0 0 48px; width: 48px; height: 28px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.slider { position: absolute; inset: 0; border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, transparent); transition: background .18s ease; }
.slider::before { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0003; content: ""; transition: transform .18s ease; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 2px; }

.time-panel { padding: 0 16px 18px 70px; }
.time-panel[hidden] { display: none; }
.time-panel > label { display: block; margin: 0 0 9px; color: var(--muted); font-size: 11px; font-weight: 700; }
.time-control { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--page) 65%, var(--card)); }
.time-control input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 19px; font-weight: 700; }
.time-suffix { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }

.notice { min-height: 22px; margin: 13px 2px 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.notice.error { color: var(--tg-theme-destructive-text-color, #ce3c42); }
.notice.success { color: #15966b; }
.save-button { width: 100%; min-height: 50px; border: 0; border-radius: 15px; background: var(--accent); color: var(--accent-text); cursor: pointer; font: inherit; font-size: 15px; font-weight: 750; }
.save-button:disabled { cursor: wait; opacity: .65; }
.footnote { margin: 12px 4px 0; color: var(--muted); text-align: center; font-size: 10px; line-height: 1.45; }

@media (max-width: 360px) {
  .shell { padding-right: 14px; padding-left: 14px; }
  .setting-row { padding-right: 12px; padding-left: 12px; }
  .setting-copy { gap: 9px; }
  .icon-box { width: 38px; height: 38px; flex-basis: 38px; }
  .time-panel { padding-left: 59px; }
}
