:root {
  color-scheme: light;
  --bg: #f3f5f2; --card: #ffffff; --ink: #1b2623; --muted: #56635e; --line: #d5dcd7;
  --accent: #1f5f57; --on-accent: #ffffff; --soft: #e2ece8; --warn: #7a4a12; --warn-bg: #f7ecd9; --danger: #a12f2f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111715; --card: #1a2220; --ink: #e8eeeb; --muted: #9dada7; --line: #33403c;
    --accent: #8fd0c2; --on-accent: #0c2420; --soft: #22302c; --warn: #f0cf9c; --warn-bg: #362a17; --danger: #f2a3a3;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111715; --card: #1a2220; --ink: #e8eeeb; --muted: #9dada7; --line: #33403c;
  --accent: #8fd0c2; --on-accent: #0c2420; --soft: #22302c; --warn: #f0cf9c; --warn-bg: #362a17; --danger: #f2a3a3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.25; font-weight: 650; text-wrap: balance; }
h1:focus { outline: none; }
h2 { font-size: 1.05rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

#shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 24px; display: flex; flex-direction: column; gap: 16px; }
#nav { order: 2; position: sticky; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav:empty { display: none; }
#nav button { flex: 1; border: 0; border-radius: 0; background: none; color: var(--muted); min-height: 56px; font-size: .95rem; }
#nav button[aria-current] { color: var(--accent); font-weight: 650; box-shadow: inset 0 2px 0 var(--accent); }

/* Los botones principales quedan al alcance del pulgar. */
.bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > * { flex: 1 1 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--soft); border-radius: 12px; padding: 12px 14px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

button, .btn { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 10px 16px; cursor: pointer; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:hover, .btn:hover { border-color: var(--accent); }
button:focus-visible, .btn:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 650; min-height: 60px; font-size: 1.1rem; }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; padding: 6px 8px; }
.danger { color: var(--danger); border-color: var(--danger); }
.left { justify-content: flex-start; text-align: left; }
[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); font-weight: 650; }
kbd { font: 600 .75rem/1 ui-monospace, Consolas, monospace; border: 1px solid currentColor; border-radius: 5px; padding: 3px 5px; opacity: .7; display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) { kbd { display: inline-block; } }

label, .label { font-weight: 600; display: block; }
textarea, input[type="time"] { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; }
textarea { resize: vertical; min-height: 84px; }
.error { color: var(--danger); font-size: .95rem; }

.clock { font-size: clamp(4rem, 22vw, 7rem); font-weight: 300; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; margin: 24px 0; }
.center { text-align: center; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { padding: 0; font-variant-numeric: tabular-nums; }
.ends { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.file { position: absolute; width: 1px; height: 1px; opacity: 0; }
dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; }
dd { margin: 0; font-variant-numeric: tabular-nums; }

#toast { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); z-index: 5; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); background: var(--ink); color: var(--bg); border-radius: 10px; padding: 10px 16px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

@media (min-width: 700px) {
  #nav { order: 0; position: static; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); }
  #nav button { flex: 0 0 140px; }
  #nav button[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); }
  #main { padding-top: 56px; flex: none; min-height: 600px; }
}
