:root {
    --bg: #0d0d0d;
    --fg: #f2f2f2;
    --muted: #9e9e9e;
    --accent: #ff4d00;
    --accent-dark: #cc3d00;
    --card: #222222;
    --border: #404040;
    --danger: #ff5252;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    max-width: 600px;
    margin: 0 auto;
    overflow-x: hidden;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

nav a {
    color: var(--fg);
    text-decoration: none;
    margin-left: 1rem;
    font-size: 0.9rem;
}

main {
    padding: 1rem;
}

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.1rem;
    color: var(--muted);
    margin-top: 1.5rem;
}

a {
    color: var(--fg);
}

.btn, button {
    display: inline-block;
    background: var(--card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}

.btn.primary, button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.btn.small {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.btn.large {
    padding: 0.9rem 1.4rem;
    font-size: 1.1rem;
}

.btn.danger, button.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.inline {
    display: inline;
}

.food-list, .cook-list, .step-list {
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
}

.food-row, .cook-row, .step-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #181818;
    border: 1px solid #2c2c2c;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.food-row:nth-child(even),
.cook-row:nth-child(even),
.step-row:nth-child(even) {
    background: #222222;
    border-color: #353535;
}

.food-name, .cook-name {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
    min-width: 0;
}

.food-main, .cook-name > span:first-child {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.food-desc, .cook-meta, .step-meta, .step-instructions {
    color: var(--muted);
    font-size: 0.85rem;
}

.food-desc, .cook-meta {
    margin-top: 0.1rem;
}

.food-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.cook-row {
    align-items: center;
}

.cook-rating {
    color: var(--accent);
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.meta, .description, .notes {
    color: var(--muted);
    margin: 0.25rem 0 1rem 0;
}

.description {
    color: var(--fg);
    font-size: 1.05rem;
}

.notes {
    font-style: italic;
}

.step-row {
    align-items: flex-start;
}

.step-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 3.5rem;
    color: var(--accent);
}

.step-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.step-name {
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.food-form, .log-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.food-form label, .log-form label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.food-form input, .food-form textarea, .log-form textarea {
    background: var(--card);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
}

.ai-generate {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-generate label {
    margin-top: 0;
}

.ai-generate textarea {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
}

.ai-status {
    font-size: 0.85rem;
    color: var(--muted);
    min-height: 1.2em;
}

.ai-status.error {
    color: var(--danger);
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: -0.5rem;
}

.steps-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-editor {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.step-number {
    flex: 1;
    font-weight: 600;
    color: var(--accent);
}

.step-move, .step-delete {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.step-delete {
    color: var(--danger);
    border-color: var(--danger);
}

.step-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.step-fields input,
.step-fields .heat-dial-wrap {
    width: 100%;
    min-width: 0;
}

.step-fields input[name^="step_instructions"] {
    grid-column: 1 / -1;
}

.heat-dial-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-self: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.heat-dial {
    cursor: grab;
    display: block;
    outline: none;
}

.heat-dial:active {
    cursor: grabbing;
}

.heat-dial:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 50%;
}

.heat-dial .hd-body {
    fill: var(--card);
    stroke: var(--border);
    stroke-width: 2;
}

.heat-dial .hd-tick {
    stroke: var(--border);
    stroke-width: 2;
}

.heat-dial .hd-tick.active {
    stroke: var(--accent);
    stroke-width: 3;
}

.heat-dial .hd-pointer line {
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
}

.hd-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

.step-fields .check {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: var(--fg);
}

.timer {
    position: relative;
    width: 260px;
    height: 260px;
    margin: 1.5rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-track, .timer-fill {
    fill: none;
    stroke-width: 8;
}

.timer-track {
    stroke: var(--border);
}

.timer-fill {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

.timer-text {
    text-align: center;
    z-index: 1;
}

.timer-step {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.timer-time {
    font-size: 3.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.timer-detail {
    font-size: 1.1rem;
    margin-top: 0.25rem;
    min-height: 1.5em;
}

.step-info-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.step-heat, .step-surface {
    font-weight: 600;
    color: var(--accent);
}

.step-instructions {
    color: var(--muted);
    margin-top: 0.5rem;
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.up-next {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #181818;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.up-next-label {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.up-next-detail {
    font-size: 1.05rem;
    font-weight: 600;
}

.push-status {
    min-height: 1.25rem;
    margin: -0.25rem 0 0.75rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.push-status a {
    color: var(--accent);
    font-weight: 600;
}

.push-status.error {
    color: var(--danger);
}

.settings-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.rating {
    display: flex;
    gap: 0.5rem;
}

.rating .star {
    flex: 1;
}

.rating .star input {
    display: none;
}

.rating .star span {
    display: block;
    text-align: center;
    padding: 0.75rem 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
}

.rating .star input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.empty {
    color: var(--muted);
    padding: 1rem 0;
}

.error-banner {
    background: #2a0f0f;
    border: 1px solid #5c2020;
    border-left: 4px solid var(--danger);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: var(--fg);
}

.warmup-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #150f05;
    border: 1px solid #3d2815;
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    color: var(--fg);
    font-size: 0.95rem;
    text-decoration: none;
}

.warmup-action {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

@keyframes flash-anim {
    0%, 100% { background: var(--bg); }
    20% { background: var(--accent); }
    40% { background: var(--bg); }
    60% { background: var(--accent-dark); }
    80% { background: var(--bg); }
}

@keyframes shake-anim {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, 2px); }
    20% { transform: translate(6px, -2px); }
    30% { transform: translate(-5px, -3px); }
    40% { transform: translate(5px, 3px); }
    50% { transform: translate(-3px, 2px); }
    60% { transform: translate(3px, -2px); }
    70% { transform: translate(-2px, 1px); }
    80% { transform: translate(2px, -1px); }
}

.step-done-flash {
    animation: flash-anim 0.45s ease-in-out 4;
}

.step-done-flash .timer {
    animation: shake-anim 0.5s ease-in-out 2;
}

/* Explosion burst around the timer ring. */
.explosion-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 5;
}

.explosion-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px 2px var(--accent);
    transform: translate(-50%, -50%);
    animation: particle-fly 1.1s cubic-bezier(0.2, 0.7, 0.3, 1) var(--delay, 0s) forwards;
}

@keyframes particle-fly {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    70% { opacity: 1; }
    100% {
        transform:
            translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
            rotate(var(--rot))
            scale(0.2);
        opacity: 0;
    }
}

.cook-form {
    margin-top: 1rem;
}

.cook-step {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.cook-step-name {
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.cook-step-fields {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 0.4rem 0.75rem;
    align-items: center;
}

.cook-step-fields label {
    color: var(--muted);
    font-size: 0.9rem;
}

.cook-step-fields input,
.cook-step-fields .stepper,
.cook-step-fields .heat-dial-wrap {
    min-width: 0;
}

.cook-step-meta {
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
}

.stepper input {
    flex: 1;
    min-width: 0;
}

.stepper .stepper-btn {
    padding: 0.25rem 0.5rem;
    min-width: 2rem;
    font-size: 1rem;
    line-height: 1;
}

@media (min-width: 600px) {
    .step-fields {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .cook-step-fields {
        grid-template-columns: auto 1fr auto 1fr;
    }
}

.cooking {
    color: var(--accent);
    font-weight: 600;
}

.gas-list {
    list-style: none;
    margin: 0 0 1rem 0;
    padding: 0;
}

.gas-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #181818;
    border: 1px solid #2c2c2c;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.gas-row:nth-child(even) {
    background: #222222;
    border-color: #353535;
}

.gas-row-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gas-row-main {
    display: flex;
    align-items: center;
}

.gas-date {
    font-weight: 600;
}

.gas-badge {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.gas-stats {
    color: var(--muted);
    font-size: 0.85rem;
}

.gas-avg {
    color: var(--muted);
    font-size: 0.9rem;
}
