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

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --accent: #6366f1;
    --green: #22c55e;
    --red: #ef4444;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.header-sub {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Main */
main {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 16px 100px;
}

/* Summary */
.summary-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.summary-bar > div {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-align: center;
}
.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Add project form */
.add-project {
    margin-bottom: 20px;
}
.add-project form {
    display: flex;
    gap: 8px;
}
.add-project input[type="text"] {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.add-project input[type="text"]:focus {
    border-color: var(--accent);
}
.add-project input[type="text"]::placeholder {
    color: var(--text-dim);
}
.add-project input[type="color"] {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    background: none;
    padding: 2px;
}
.add-project input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.add-project input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}
.add-project button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.add-project button:active { opacity: 0.8; }

/* Project cards */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.project-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    border-left: 4px solid var(--accent);
    transition: background 0.15s;
}
.project-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.project-info {
    flex: 1;
    min-width: 0;
}
.project-name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-elapsed {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}
.project-elapsed.running {
    color: var(--green);
}
.project-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Timer button */
.btn-timer {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, opacity 0.15s;
}
.btn-timer:active { transform: scale(0.92); }
.btn-timer.start {
    background: var(--green);
}
.btn-timer.stop {
    background: var(--red);
}
.btn-timer svg {
    width: 22px;
    height: 22px;
    fill: white;
}

/* Small icon buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--surface2);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    font-size: 1.1rem;
}
.btn-icon:hover { background: #475569; color: var(--text); }

/* Session info below card */
.project-session {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--surface2);
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.open {
    display: flex;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--surface2);
}
.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
}
.modal-body {
    overflow-y: auto;
    padding: 12px 20px 20px;
    flex: 1;
}

/* History entries */
.history-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface2);
    gap: 12px;
}
.history-entry:last-child { border-bottom: none; }
.history-date {
    font-size: 0.8rem;
    color: var(--text-dim);
}
.history-times {
    font-size: 0.85rem;
    margin-top: 2px;
}
.history-duration {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1rem;
    white-space: nowrap;
}
.history-note {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 2px;
}
.history-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.history-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 0;
}
.history-total {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
}

/* Delete confirm */
.btn-delete {
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}
.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

@media (min-width: 640px) {
    .modal {
        border-radius: var(--radius);
        margin-bottom: 40px;
        max-height: 70dvh;
    }
}
