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

:root {
    --bg: #f5f3f0;
    --surface: #fff;
    --text: #1a1a1a;
    --muted: #888;
    --accent: #2d6a4f;
    --accent-light: #d8f3dc;
    --danger: #c0392b;
    --border: #e0dcd7;
    --radius: 10px;
    --dialog-bg: #fff;
    --dialog-text: #1a1a1a;
}

[data-theme="dark"] {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #e0e0e0;
    --muted: #999;
    --accent: #4caf7c;
    --accent-light: #1b3a2a;
    --danger: #e74c3c;
    --border: #333;
    --dialog-bg: #1e1e1e;
    --dialog-text: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    -webkit-user-select: none;
    user-select: none;
}

header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-row:last-child {
    justify-content: center;
}

header button {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text);
    touch-action: manipulation;
}

header button:active {
    background: var(--accent-light);
}

#date-display {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
}

main {
    padding: 8px 12px 24px;
    touch-action: pan-y;
}

.slot {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    margin-bottom: 4px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    touch-action: manipulation;
}

.slot:active {
    background: var(--accent-light);
}

.slot.booked {
    background: var(--accent-light);
    border-color: var(--accent);
}



.slot-time {
    width: 110px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
}

.slot-name {
    flex: 1;
    font-size: 16px;
}

.slot-name.free {
    color: var(--muted);
    font-style: italic;
}

.slot-history {
    color: var(--muted);
    font-size: 14px;
    padding: 8px 4px;
    flex-shrink: 0;
    line-height: 1;
}

.slot-delete {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 20px;
    padding: 8px;
    cursor: pointer;
    line-height: 1;
    touch-action: manipulation;
}

/* Dialogs */
dialog {
    border: none;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 340px;
    width: calc(100vw - 48px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    background: var(--dialog-bg);
    color: var(--dialog-text);
}

dialog::backdrop {
    background: rgba(0,0,0,0.4);
}

dialog h2 {
    margin-bottom: 8px;
    font-size: 18px;
}

dialog p {
    margin-bottom: 16px;
    color: var(--muted);
}

dialog label {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--muted);
}

dialog input {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    outline: none;
    background: var(--bg);
    color: var(--text);
}

dialog input:focus {
    border-color: var(--accent);
}

.dialog-buttons {
    display: flex;
    gap: 8px;
}

.dialog-buttons button {
    flex: 1;
    padding: 10px 12px;
    font-size: 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    touch-action: manipulation;
}

.dialog-buttons button[value="confirm"] {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.dialog-buttons button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

/* Log dialog */
#log-entries {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.log-entry {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--muted);
    flex-shrink: 0;
    font-size: 13px;
}

.log-action {
    font-weight: 600;
}

.log-action.booked {
    color: var(--accent);
}

.log-action.deleted {
    color: var(--danger);
}

.log-empty {
    color: var(--muted);
    font-style: italic;
    padding: 12px 0;
}
