/* José Time Track – oscuro, enfocado, móvil primero.
   Escena: de noche, en el móvil, fichando con una mano. */
:root {
    --bg: oklch(0.19 0.022 265);
    --surface: oklch(0.235 0.026 265);
    --surface-2: oklch(0.28 0.03 265);
    --line: oklch(0.34 0.03 265);
    --text: oklch(0.94 0.012 85);
    --muted: oklch(0.72 0.03 265);
    --accent: oklch(0.8 0.15 75);
    --accent-ink: oklch(0.22 0.04 75);
    --danger: oklch(0.72 0.17 25);
    --danger-ink: oklch(0.2 0.05 25);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --tabs: calc(4.25rem + env(safe-area-inset-bottom));
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-variant-numeric: tabular-nums;
    padding: 1.25rem 1rem calc(var(--tabs) + 1.5rem);
    max-width: 40rem;
    margin: 0 auto;
}

::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-color: var(--line) var(--bg); caret-color: var(--accent); }
a { color: inherit; text-decoration: none; }
svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Barra de pestañas (siempre al alcance del pulgar) */
.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(3, 1fr);
    height: var(--tabs); padding-bottom: env(safe-area-inset-bottom);
    background: oklch(0.21 0.024 265); border-top: 1px solid var(--line);
}
.tabs a { display: grid; place-content: center; justify-items: center; gap: 0.15rem; font-size: 0.75rem; font-weight: 600; color: var(--muted); transition: color 0.2s; }
.tabs a[aria-current] { color: var(--accent); }

/* Pantalla principal: fichar */
.fichar { min-height: calc(100dvh - var(--tabs) - 4rem); display: flex; flex-direction: column; gap: 2rem; }
.clock { display: grid; gap: 0.9rem; text-align: center; padding-top: 1.5vh; }
.clock h1 { margin: 0; font-size: clamp(1.6rem, 7vw, 2.2rem); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.state { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin: 0; font-size: 0.9rem; font-weight: 650; color: var(--muted); }
.on .state { color: var(--accent); }
.state i { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--accent); }
.timer { margin: 0.4rem 0 0; font-size: clamp(3.4rem, 17vw, 5.5rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1; color: var(--accent); }
.since { margin: 0 0 0.6rem; color: var(--muted); }
.hint { margin: 0; color: var(--muted); }
.hint a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.clock form { display: grid; gap: 1rem; }
.hospital { display: grid; gap: 0.4rem; text-align: left; font-size: 0.85rem; color: var(--muted); }
select {
    width: 100%; min-height: 4.5rem; padding: 0 3rem 0 1.1rem; font: inherit; font-size: 1.25rem; font-weight: 650; color: var(--text);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9b98a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 1rem center / 1.5rem;
    border: 1px solid var(--line); border-radius: 16px; appearance: none; -webkit-appearance: none;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.8 0.15 75 / 0.25); }
.big { width: 100%; min-height: 6.5rem; font-size: 1.9rem; font-weight: 750; letter-spacing: -0.01em; border-radius: 20px; }
.big.in { background: var(--accent); color: var(--accent-ink); }
.big.out { background: var(--danger); color: var(--danger-ink); }
.big.in:hover { background: oklch(0.85 0.15 75); }

.today-list { margin-top: auto; }

/* Cabecera de las otras pestañas */
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.1rem; }
.top h1 { margin: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.tots { display: flex; gap: 1.2rem; }
.total { margin: 0; text-align: right; color: var(--muted); font-size: 0.85rem; }
.total strong { display: block; color: var(--accent); font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* Semana */
.weeknav { display: grid; grid-template-columns: 3rem 1fr 3rem; gap: 0.5rem; margin-bottom: 1rem; }
.weeknav a { display: grid; place-items: center; min-height: 3rem; background: var(--surface); border-radius: 12px; transition: background 0.2s; }
.weeknav a:hover { background: var(--surface-2); }
.weeknav .range { font-weight: 600; }

details.new { background: var(--surface); border-radius: 14px; margin-bottom: 1.75rem; }
summary {
    display: flex; align-items: center; gap: 0.6rem; min-height: 3.25rem; padding: 0 1rem;
    font-weight: 650; color: var(--accent); cursor: pointer; list-style: none; border-radius: 14px;
}
summary::-webkit-details-marker { display: none; }
summary svg { width: 1.2rem; height: 1.2rem; transition: transform 0.3s var(--ease); }
details[open] summary svg { transform: rotate(45deg); }

form.add-h, details form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
details form { padding: 0 1rem 1rem; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
input {
    width: 100%; min-height: 3rem; padding: 0 0.8rem; font: inherit; font-size: 1rem; color: var(--text);
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.8 0.15 75 / 0.25); }
input[type="date"], input[type="time"] { color-scheme: dark; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.25rem; }
button, .btn {
    min-height: 3rem; padding: 0 1.25rem; font: inherit; font-weight: 650; color: var(--text);
    background: var(--surface-2); border: 0; border-radius: 10px; cursor: pointer;
    display: inline-grid; place-items: center; transition: transform 0.15s var(--ease), background 0.2s;
}
button:active, .btn:active { transform: scale(0.97); }
button.primary { flex: 1; background: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: oklch(0.85 0.15 75); }
button.danger { color: var(--danger); background: transparent; box-shadow: inset 0 0 0 1px var(--danger); }
details button.danger { margin-left: auto; }
.error { grid-column: 1 / -1; margin: 0; padding: 0.7rem 0.9rem; border-radius: 10px; color: var(--danger); background: oklch(0.3 0.06 25); }

.day, .today-list { margin-bottom: 1.4rem; }
.day h2, .today-list h2 {
    display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 0.4rem; padding: 0 0.25rem 0.4rem;
    font-size: 0.95rem; font-weight: 650; border-bottom: 1px solid var(--line);
}
.day h2 small { margin-left: 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.sum { color: var(--muted); font-weight: 600; }
.day.today h2 { color: var(--accent); border-color: var(--accent); }
.day.today h2 small, .day.today .sum { color: inherit; opacity: 0.85; }
.empty { margin: 0; padding: 0.4rem 0.25rem; color: var(--muted); font-size: 0.95rem; }

.row {
    display: grid; grid-template-columns: 3.4rem 1fr auto; gap: 0.9rem; align-items: center;
    padding: 0.7rem 0.75rem; margin-bottom: 0.4rem; min-height: 3.5rem;
    background: var(--surface); border-radius: 12px; transition: background 0.2s;
}
.row:hover { background: var(--surface-2); }
.time { font-size: 0.8rem; line-height: 1.25; color: var(--muted); }
.what { display: grid; gap: 0.1rem; min-width: 0; }
.proj { display: flex; align-items: center; gap: 0.5rem; font-weight: 650; }
.proj::before { content: ""; width: 0.65rem; height: 0.65rem; flex: none; border-radius: 50%; background: var(--c); }
.note { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dur { font-weight: 700; }

/* Hospitales */
.add-h { grid-template-columns: 1fr auto; margin-bottom: 1.25rem; }
.hosp { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.hosp li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.25rem 0.25rem 0.25rem 0.9rem; min-height: 3.5rem; background: var(--surface); border-radius: 12px; }
.rate { margin-left: auto; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pencil { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 10px; color: var(--muted); transition: background 0.2s, color 0.2s; }
.pencil:hover { background: var(--surface-2); color: var(--accent); }
.pencil svg { width: 1.2rem; height: 1.2rem; }
.edit-h { display: grid; gap: 0.75rem; margin-bottom: 2rem; }
.edit-h .hint { font-size: 0.9rem; }
.quitar button { width: 100%; }
body { padding-top: calc(1.25rem + env(safe-area-inset-top)); }

.clock input[name="note"] { min-height: 3.5rem; font-size: 1.05rem; border-radius: 14px; background: var(--surface); }
.note-on { margin: -0.3rem 0 0; color: var(--muted); font-size: 1.05rem; }

@font-face { font-family: "Chewy"; src: url("chewy.woff2") format("woff2"); font-display: swap; }

/* Arzt: winkt, blinzelt, wippt; das EKG läuft durch */
.doc { cursor: pointer; -webkit-tap-highlight-color: transparent; margin: -0.5rem auto 0; display: flex; align-items: center; justify-content: center; gap: 0.25rem; }
.doc svg { flex: none; }
.say {
    position: relative; margin: 0 0 1.6rem 0.4rem; padding: 0.7rem 1rem; transform: rotate(-3deg);
    font: 1.35rem/1.15 "Chewy", "Comic Sans MS", cursive; text-align: center; color: var(--text);
    background: var(--surface-2); border-radius: 18px;
}
.say b { color: var(--accent); font-weight: 400; font-size: 1.6rem; }
.say::before { content: ""; position: absolute; left: -0.55rem; top: 55%; width: 0.9rem; height: 1rem; background: inherit; clip-path: polygon(100% 0, 0 60%, 100% 100%); }
.doc svg { overflow: visible; display: block; width: min(40vw, 8rem); height: auto; margin: 0 auto; }
.doc .st { display: none; }
.doc.stress .st { display: inline; }
.doc.stress .ok { display: none; }
.doc .lf { display: none; }
.doc.squirt .lf { display: inline; }
.doc.squirt .fc { display: none; }
.doc .wk { display: none; }
.doc.wake .wk { display: inline; }
.doc.wake .sl { display: none; }
.zz { opacity: 0; font: 22px "Chewy", cursive; fill: #9fb0c8; }
@media (prefers-reduced-motion: no-preference) {
    .drop { animation: drop 1.3s ease-in infinite; }
    .drop.d2 { animation-delay: 0.45s; }
    .drop.d3 { animation-delay: 0.85s; }
    @keyframes drop { 0% { transform: translateY(-2px) scale(0.6); opacity: 0; } 25% { opacity: 1; transform: scale(1); } 100% { transform: translateY(26px); opacity: 0; } }
    .stress .bob { animation: jit 0.12s linear infinite; }
    @keyframes jit { 50% { transform: translate(1.5px, -1px); } }
    .doc.squirt .bob { animation: laugh 0.2s ease-in-out infinite; }
    @keyframes laugh { 50% { transform: translateY(-4px); } }
    .stress .wave { animation-duration: 0.3s; }
    .stress .beat { animation-duration: 0.55s; }
    .stress .ecg { animation-duration: 0.8s; }
    .stress .mouth { animation: chatter 0.25s linear infinite; }
    @keyframes chatter { 50% { transform: translateY(1.5px); } }
    .bob { animation: bob 2.4s ease-in-out infinite; transform-origin: 100px 215px; }
    .wave { animation: wave 1.1s ease-in-out infinite; transform-origin: 149px 126px; }
    .say { animation: say 2.4s ease-in-out infinite; }
    @keyframes say { 50% { transform: rotate(2deg) translateY(-3px); } }
    .eyes { animation: blink 4s infinite; transform-origin: 100px 78px; }
    .beat { animation: beat 1.2s ease-in-out infinite; transform-origin: 100px 154px; }
    .ecg { stroke-dasharray: 60 240; animation: ecg 1.8s linear infinite; }
    @keyframes bob { 50% { transform: translateY(-5px) rotate(-1.2deg); } }
    @keyframes wave { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(22deg); } }
    @keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
    @keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.35); } 30% { transform: scale(1); } }
    .doc:not(.stress) .bob { animation: nod 3.2s ease-in-out infinite; }
    .doc:not(.stress) .wave { animation: none; transform: rotate(-8deg); }
    .doc.wake .bob { animation: none; }
    .doc.wake .wave { animation: wave 0.2s ease-in-out infinite; }
    .zz { animation: zz 2.4s ease-out infinite; }
    .zz.b { animation-delay: 0.8s; }
    .zz.c { animation-delay: 1.6s; }
    .bub { animation: bubb 3.2s ease-in-out infinite; transform-origin: 118px 90px; }
    @keyframes nod { 0%, 100% { transform: none; } 45%, 60% { transform: rotate(7deg) translateY(4px); } }
    @keyframes zz { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-22px, -34px); opacity: 0; } }
    @keyframes bubb { 0%, 100% { transform: scale(0.3); } 50% { transform: scale(1.2); } }
    @keyframes ecg { from { stroke-dashoffset: 300; } to { stroke-dashoffset: 0; } }
}

/* Ajustes */
.list { margin-bottom: 2rem; }
.list h2 { margin: 0 0 0.6rem; font-size: 1.05rem; font-weight: 700; }
.nm { font-weight: 600; }
.backup .btn { display: inline-grid; }
.backup .hint { margin: 0 0 0.8rem; font-size: 0.9rem; }

/* Klick auf den Doktor */
.doc svg { transform-origin: 50% 90%; }
@media (prefers-reduced-motion: no-preference) {
    .doc.hop svg { animation: hop 0.7s cubic-bezier(0.3, 0, 0.3, 1); }
    .doc.shake svg { animation: shake 0.55s linear; }
    @keyframes hop { 0% { transform: scale(1.12, 0.86); } 25% { transform: translateY(-28px) scale(0.94, 1.08); } 50% { transform: translateY(0) scale(1.1, 0.9); } 70% { transform: translateY(-10px); } 100% { transform: none; } }
    @keyframes shake { 0%, 100% { transform: none; } 10% { transform: translateX(-9px) rotate(-5deg); } 30% { transform: translateX(9px) rotate(5deg); } 50% { transform: translateX(-7px) rotate(-4deg); } 70% { transform: translateX(7px) rotate(4deg); } 90% { transform: translateX(-3px); } }
}

/* Fotos */
.photo { display: grid; gap: 0.6rem; justify-items: center; margin: 0 0 1rem; }
.photo img { max-width: 100%; max-height: 14rem; border-radius: 14px; }
.photo.full { justify-items: stretch; }
.thumb { width: 2.6rem; height: 2.6rem; object-fit: cover; border-radius: 8px; margin-top: 0.25rem; }
.chk { display: flex; gap: 0.5rem; align-items: center; }
.pbtns { display: flex; gap: 0.6rem; }
