:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2a7ae2);
  --button: var(--tg-theme-button-color, #2a7ae2);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f2f2f7);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main { padding: 16px 16px 88px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 18px 0 6px; }
a { color: var(--link); }
.hint { color: var(--hint); font-size: 14px; margin: 4px 0; }
.error { color: #d93025; }

.screen { display: none; }
.screen.active { display: block; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border-radius: 14px; padding: 12px; }
.tile.wide { grid-column: 1 / -1; }
.tile .label { color: var(--hint); font-size: 13px; }
.tile .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .sub { font-size: 14px; margin-top: 2px; }
.bar { height: 6px; border-radius: 3px; background: var(--bg); margin-top: 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--button); }

.today-box, .card-box { margin-top: 14px; }
.block { background: var(--surface); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.block h2 { margin-top: 0; }
.block ul { margin: 0; padding-left: 18px; }
.block li { margin-bottom: 6px; }
.links { font-size: 14px; }

.minutes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
button {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--surface); color: var(--text);
}
button.primary { background: var(--button); color: var(--button-text); width: 100%; margin-top: 12px; }

details { background: var(--surface); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
summary { font-weight: 600; cursor: pointer; }
.piece-card { white-space: pre-line; margin-top: 8px; }

.field { display: block; margin: 12px 0; }
.field span { display: block; margin-bottom: 6px; }
.field.row { display: flex; align-items: center; justify-content: space-between; }
.field.row span { margin: 0; }
input[type=time], input[type=text] {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--hint);
  background: var(--bg); color: var(--text);
}
input[type=text] { width: 100%; }
input[type=checkbox] { width: 22px; height: 22px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--bg); border-top: 1px solid var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; background: none; border-radius: 0; padding: 14px 4px; color: var(--hint); }
.tabs button.active { color: var(--button); font-weight: 600; }
