:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #16a34a;
  --red: #dc2626;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

main {
  max-width: 520px;
  margin: 0 auto;
  /* safe-area: odstęp od notcha i paska Home */
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
}

.timer {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
}

.label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.current { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0 16px; }
.total   { font-size: 36px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }

.toggle {
  border: 0;
  border-radius: 20px;
  height: 120px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: .1em;
  color: #fff;
  touch-action: manipulation;
}
.toggle.start { background: var(--green); }
.toggle.stop  { background: var(--red); }
.toggle.pause { background: #b45309; }
.toggle:active { transform: scale(.98); filter: brightness(.9); }

.history { background: var(--card); border-radius: 20px; padding: 16px 20px; flex: 1; }
.history header { display: flex; justify-content: space-between; align-items: center; }
.history h2 { font-size: 18px; margin: 0; }

.link { background: none; border: 0; color: #60a5fa; font-size: 16px; padding: 8px 0; }

ol { list-style: none; margin: 8px 0 0; padding: 0; }
li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #334155;
  font-variant-numeric: tabular-nums;
}
li .dur   { font-weight: 600; font-size: 18px; }
li .del   { background: none; border: 0; color: var(--muted); font-size: 20px; padding: 0 4px; }

.empty { color: var(--muted); text-align: center; margin: 24px 0 8px; }

.version { color: var(--muted); font-size: 12px; text-align: center; margin: 0; opacity: .7; }

/* --- zakładki --- */

[hidden] { display: none !important; }

.view { display: flex; flex-direction: column; gap: 16px; flex: 1; }

.tabs { display: flex; gap: 4px; background: var(--card); border-radius: 14px; padding: 4px; }
.tabs button {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  background: none;
  color: var(--muted);
}
.tabs button[aria-pressed="true"] { background: #334155; color: var(--text); }

/* --- minutnik --- */

.left { font-size: 80px; }
#timerToggle { font-size: 30px; }

.stepper { display: flex; justify-content: center; align-items: center; gap: 20px; color: var(--muted); }
.stepper button, .presets button {
  border: 0;
  border-radius: 14px;
  background: #334155;
  color: var(--text);
  font-weight: 600;
  touch-action: manipulation;
}
.stepper button { width: 64px; height: 56px; font-size: 28px; }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.presets button { height: 52px; font-size: 20px; }
.presets button[aria-pressed="true"] { background: #2563eb; }

.ringing { animation: ringing 1s infinite; }
@keyframes ringing { 50% { background: var(--red); } }

/* --- pytanie o czynność po zakończeniu pomiaru --- */

dialog {
  width: min(480px, calc(100% - 32px));
  margin-top: calc(env(safe-area-inset-top) + 24px); /* u góry, żeby klawiatura nie zasłaniała */
  border: 0;
  border-radius: 20px;
  padding: 20px;
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog form { display: flex; flex-direction: column; gap: 16px; }
dialog .toggle { height: 72px; font-size: 26px; }

dialog input[type="text"] {
  border: 1px solid #475569;
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 18px; /* poniżej 16px iOS przybliża stronę */
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}

.categories { display: flex; flex-wrap: wrap; gap: 8px; }
.categories input { position: absolute; opacity: 0; }
.categories span { display: block; padding: 12px 16px; border-radius: 12px; background: #334155; font-weight: 600; }
.categories input:checked + span { background: #2563eb; }

/* --- historia czynności --- */

.day, .category { display: flex; justify-content: space-between; margin: 0; }
.day { font-size: 18px; margin-top: 20px; }
.category { font-size: 15px; color: #60a5fa; margin-top: 12px; }
li .what { flex: 1; overflow-wrap: anywhere; }
li .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.skip { border: 0; border-radius: 14px; height: 52px; font-size: 17px; font-weight: 600; background: #334155; color: var(--text); }

.alarm-open, .alarm-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: #334155;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}
.alarm-open { margin-top: 16px; }
.alarm-open span:first-child { color: var(--muted); }
.alarm-open span span:first-child { color: var(--text); }
.alarm-list { display: flex; flex-direction: column; gap: 8px; }
.alarm-list button[aria-pressed="true"] { background: #2563eb; }
.alarm-list button[aria-pressed="true"]::after { content: "✓"; }

/* Stoper: START na całą szerokość, potem PAUZA i STOP obok siebie. */
.buttons { display: flex; gap: 12px; }
.buttons .toggle { flex: 1; font-size: 28px; padding: 0; }
