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

:root {
    --primary: #ef4444;
    --primary-dark: #dc2626;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Timer Section */
.timer-section {
    grid-column: 1;
    display: flex;
    flex-direction: column;
}

.timer-display {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fef9f3 100%);
    border-radius: 12px;
    margin-bottom: 2rem;
    transition: background 0.3s;
}

.timer-display.break {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
}

.timer-display.long-break {
    background: linear-gradient(135deg, #fffbeb 0%, #fef9f3 100%);
}

.timer-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 500;
}

.timer-status.work {
    color: var(--primary);
}

.timer-status.break {
    color: var(--secondary);
}

.timer-status.long-break {
    color: var(--accent);
}

.timer-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.5rem;
    font-family: 'Monaco', 'Courier New', monospace;
}

.timer-value.is-paused {
    opacity: 0.65;
}

.session-counter {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

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

.btn-secondary:disabled:hover {
    background: var(--bg-tertiary);
}

.btn:focus-visible,
.mute-toggle:focus-visible,
.goal-input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.mute-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    transition: all 0.2s;
    font-family: inherit;
}

.mute-toggle:hover {
    background: var(--bg-tertiary);
}

.timer-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
    margin-top: 0.25rem;
}

/* Daily Goal Section */
.goal-section {
    grid-column: 2;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.goal-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.goal-target {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--secondary-dark));
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.progress-fill.has-label {
    min-width: 3.25rem;
    padding: 0 0.5rem;
}

.goal-remaining {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.goal-edit {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.goal-input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.goal-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    min-height: 1.2em;
}

.goal-note.is-error {
    color: var(--primary-dark);
}

/* History Section */
.history-section {
    grid-column: 1 / -1;
}

.history-container {
    max-height: 400px;
    overflow-y: auto;
}

.history-day {
    margin-bottom: 2rem;
}

.history-day:last-child {
    margin-bottom: 0.5rem;
}

.history-day-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.history-day-total {
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.session-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.session-badge.work {
    background: var(--primary);
}

.session-badge.break {
    background: var(--secondary);
}

.session-badge.long {
    background: var(--accent);
}

.session-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.session-type {
    font-weight: 600;
    color: var(--text-primary);
}

.session-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.session-duration {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.history-empty {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.history-actions {
    margin-top: 1rem;
}

.noscript-note {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .timer-section,
    .goal-section {
        grid-column: 1;
    }

    .history-section {
        grid-column: 1;
    }
}

@media (max-width: 720px) {
    header {
        padding: 1rem;
    }

    .header-title {
        font-size: 1.25rem;
    }

    .container {
        padding: 1rem;
        gap: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .timer-value {
        font-size: 3rem;
    }

    .timer-controls {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        min-width: 100px;
    }

    .goal-value {
        font-size: 1.5rem;
    }

    .history-container {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .header-user span {
        display: none;
    }

    .timer-display {
        padding: 1.5rem 0.75rem;
    }

    .session-item {
        padding: 0.75rem;
    }

    .session-info {
        gap: 0.75rem;
    }

    .goal-edit .btn {
        flex: 0 1 auto;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Scrollbar styling */
.history-container::-webkit-scrollbar {
    width: 6px;
}

.history-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.history-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.history-container::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}
