@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&display=swap");

:root {
    --bg: #16120e;
    --bg-soft: #211c17;
    --bg-soft-2: #2a241d;
    --ink: #f4efe6;
    --ink-dim: #b9ad9c;
    --ink-faint: #8f8577;
    --gold: #b8956b;
    --gold-soft: #d4b896;
    --border: rgba(212, 184, 150, 0.16);
    --border-strong: rgba(184, 149, 107, 0.5);
    --green: #7cc9a5;
    --yellow: #f0d17a;
    --red: #e07070;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

/* Режим встраивания в оверлей страницы чая: таймер заполняет iframe целиком. */
body.embed {
    padding: 0;
}
body.embed .app {
    height: 100svh;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

html {
    min-height: 100%;
    background: #e8dfd0 url("/assets/css/images/overlay.png") repeat;
}

body {
    font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #e8dfd0 url("/assets/css/images/overlay.png") repeat;
    color: #3d3830;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    justify-content: center;
    padding: clamp(16px, 3vw, 32px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
}

.app {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: calc(100svh - clamp(16px, 3vw, 32px) - clamp(16px, 3vw, 32px));
    background: var(--bg);
    color: var(--ink);
    border: 1px solid rgba(184, 149, 107, 0.22);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(26, 23, 20, 0.28);
    padding: clamp(18px, 5vw, 28px) clamp(16px, 5vw, 26px) 28px;
    display: flex;
    flex-direction: column;
}

.app-header {
    text-align: center;
    margin-bottom: 22px;
}

.app-header h1 {
    font-size: clamp(1.5rem, 7vw, 2.1rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink);
}

.app-sub {
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
}

.screen {
    width: 100%;
}

#screen-timer {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#screen-input {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 14px;
    width: 100%;
}

#screen-input .input-intro {
    width: 100%;
    max-width: 340px;
}

#start-app {
    width: 100%;
    max-width: 340px;
    margin-bottom: 0;
    margin-top: 4px;
}

.input-intro {
    color: var(--ink-dim);
    font-size: 1.14rem;
    line-height: 1.55;
    margin-bottom: 18px;
    text-align: center;
}

.input-intro strong {
    color: var(--gold-soft);
    font-weight: 600;
}

.card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.field-label {
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--ink-dim);
}

.field-hint {
    font-size: 0.78rem;
    color: var(--ink-faint);
}

input[type="number"] {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid rgba(212, 184, 150, 0.28);
    border-radius: 12px;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(184, 149, 107, 0.2);
}

input.invalid {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(224, 112, 112, 0.18);
}

.times {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.time-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.time-field label {
    font-size: 0.82rem;
    color: var(--ink-dim);
}

.time-field input {
    min-height: 48px;
    font-size: 1rem;
}

.error {
    color: var(--red);
    font-size: 0.85rem;
    margin: -8px 0 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    min-height: 52px;
    font-size: 1rem;
    padding: 12px 16px;
    transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s, transform 0.06s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.btn-primary {
    background: var(--gold);
    color: #16120e;
}

.btn-primary:hover:not(:disabled) {
    background: var(--gold-soft);
}

.btn-block {
    width: 100%;
}

.btn-control {
    background: var(--bg-soft);
    border: 1px solid rgba(212, 184, 150, 0.28);
    color: var(--ink);
}

.btn-control:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold-soft);
}

.btn-start {
    background: var(--green);
    color: #0e241b;
}

.btn-start:hover:not(:disabled) {
    background: #8fd6b3;
}

.btn-stop {
    background: var(--red);
    color: #2a1212;
}

.btn-stop:hover:not(:disabled) {
    background: #eb8a8a;
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 18px 0;
}

.controls.timer-controls {
    grid-template-columns: 1fr;
    margin: 14px 0 26px;
}

.stopwatch-wrap {
    text-align: center;
    margin: 6px 0 2px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stopwatch {
    font-size: clamp(3.5rem, 22vw, 6rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
    transition: color 0.35s;
}

.stopwatch.green {
    color: var(--green);
}

.stopwatch.yellow {
    color: var(--yellow);
}

.stopwatch.red {
    color: var(--red);
}

.stopwatch.neutral {
    color: var(--ink);
}

.stopwatch-unit {
    text-align: center;
    margin-top: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.infusion-list {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    scroll-snap-type: y proximity;
    gap: 8px;
    margin: 4px 0 12px;
}

.infusion-list::-webkit-scrollbar {
    display: none;
}

.infusion-item {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--ink-faint);
    scroll-snap-align: start;
    transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.infusion-item .label {
    font-variant-numeric: tabular-nums;
}

.infusion-item.current {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--bg-soft-2);
    border-color: var(--border-strong);
}

.infusion-empty {
    text-align: center;
    padding: 18px 12px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    color: var(--ink-faint);
    font-size: 0.9rem;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.62);
}

.modal-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: 22px 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--ink);
}

.confirm-text {
    color: var(--ink-dim);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 18px;
}

.modal-card .controls {
    margin-bottom: 0;
}

.back-site {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 6px;
    margin-top: auto;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink-dim);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}

.back-site:hover {
    border-color: var(--gold);
    color: var(--gold-soft);
}

@media (min-width: 760px) {
    .app {
        padding: 18px 26px 18px;
    }

    .app-header {
        margin-bottom: 14px;
    }

    .app-header h1 {
        font-size: 1.7rem;
    }

    .app-sub {
        font-size: 0.72rem;
    }

    .stopwatch-wrap {
        margin: 2px 0 0;
    }

    .stopwatch {
        font-size: 4.25rem;
    }

    .stopwatch-unit {
        margin-top: 4px;
        font-size: 0.72rem;
    }

    .infusion-list {
        gap: 6px;
        margin: 4px 0 12px;
    }

    .infusion-item {
        min-height: 40px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .infusion-item.current {
        font-size: 0.95rem;
    }

    .btn {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    .controls {
        gap: 10px;
        margin: 12px 0;
    }

    .controls.timer-controls {
        margin: 10px 0 16px;
    }

    .card {
        padding: 16px 16px;
    }

    #start-app {
        max-width: 340px;
    }
}
