/* Controller view: phone-first. Colours and base styles: base.css. */
body {
  min-height: 100vh;
  font-size: 1.05rem;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
}

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.eyebrow { margin: 1.5rem 0 0.25rem; color: var(--muted); font-size: 0.95rem; }
.login-name { font-size: 1.6rem; margin-bottom: 1.25rem; }
.fatal-text { font-size: 1.2rem; color: var(--alert); }

.card {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
}

.hint { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.9rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ------------------------------------------------------------ form controls */
label { display: block; font-weight: 600; }

input, select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 0.3rem;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1.1rem; /* >= 16px stops iOS zooming in */
}
input:focus, select:focus { border-color: var(--fg); }
#login-form input[type="password"] { font-size: 1.6rem; letter-spacing: 0.3em; }

.check { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0; font-weight: 400; }
.check-top { margin: 0 0 1rem; }
.check input { width: 1.4rem; height: 1.4rem; min-height: 0; margin: 0; }

.form-error { margin: 0.75rem 0 0; color: var(--alert); font-weight: 600; }

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.inline-form label { flex: 1 1 7rem; }
.inline-form .grow { flex: 1 1 100%; }
.inline-form .btn { flex: 1 1 6rem; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border: 2px solid var(--fg);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-small { min-height: 40px; padding: 0.3rem 0.8rem; font-size: 0.95rem; }
.btn-primary { width: 100%; background: var(--fg); color: var(--bg); }

/* Start / Resume (blue) or Pause (orange): the most important control. */
.btn-run {
  width: 100%;
  min-height: 72px;
  margin-top: 1rem;
  border: 0;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  color: var(--on-colour);
  background: var(--muted);
}
.is-paused .btn-run,
.is-countdown .btn-run { background: var(--running); }
.btn-cancel { width: 100%; margin-top: 0.5rem; }
.is-running .btn-run { background: var(--paused); }

/* ------------------------------------------------------------ header + clock */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.name { font-size: 1.35rem; overflow-wrap: anywhere; }

.clock-card { text-align: center; }
.clock-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.15em 0.6em;
  border: 2px solid currentColor;
  border-radius: 0.4em;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.is-running .status,
.is-countdown .status { color: var(--running); }
.is-paused .status { color: var(--paused); }
.is-running .status-icon::before { content: "▶"; }
.is-paused .status-icon::before { content: "❚❚"; }
.is-countdown .status-icon::before { content: "◷"; }

.reconnecting { color: var(--alert); font-weight: 600; font-size: 0.95rem; }

.time {
  margin-top: 0.75rem;
  font-size: min(17vw, 4.8rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.date { margin-top: 0.3rem; font-size: 1.3rem; }
.countdown-line {
  margin: 0.75rem 0 0;
  padding: 0.5rem;
  background: var(--running);
  color: var(--on-colour);
  border-radius: 0.4rem;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.spaced { margin-top: 1rem; }
.local-time { margin-top: 0.4rem; color: var(--muted); font-size: 0.95rem; }
.local-time span { color: var(--fg); font-variant-numeric: tabular-nums; }

.jump-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.jump-grid .btn { padding: 0.5rem 0.25rem; white-space: nowrap; font-size: 1rem; }
@media (max-width: 360px) { .jump-grid { grid-template-columns: repeat(2, 1fr); } }

/* ------------------------------------------------------------ share */
.share { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.share-links { flex: 1 1 14rem; display: grid; gap: 0.6rem; }
.share-links input { margin: 0; font-size: 0.95rem; }
.qr { flex: 0 0 auto; width: 9rem; padding: 0.5rem; background: #fff; border-radius: 0.3rem; line-height: 0; }
.qr svg { width: 100%; height: auto; }

/* ------------------------------------------------------------ log */
.log-head { display: flex; justify-content: space-between; align-items: baseline; }
.log { margin: 0; padding: 0; list-style: none; max-height: 18rem; overflow-y: auto; }
.log li { padding: 0.45rem 0; border-top: 1px solid #333; font-size: 0.95rem; }
.log li:first-child { border-top: 0; }
.log .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .what { font-weight: 700; }

/* ------------------------------------------------------------ dialogs + toast */
.dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 2px solid var(--fg);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--fg);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.75); }
.dialog p { font-size: 1.15rem; }
.dialog .row .btn { flex: 1; }

.qr-dialog { width: min(40rem, calc(100vw - 2rem)); text-align: center; }
.qr-large { width: min(80vmin, 34rem); margin: 0 auto; padding: 1rem; }
.qr-large-url { overflow-wrap: anywhere; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.75rem 1.1rem;
  border-radius: 0.5rem;
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.6);
}
.toast.is-error { background: var(--alert); color: var(--on-colour); }

.conn-lost {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--alert);
  color: var(--on-colour);
  font-weight: 800;
  text-align: center;
}
