/* ============================================
   GRINDSCOPE — Chiaroscuro Design System
   Premium dark UI. Inter + JetBrains Mono.
   Rounded surfaces, progressive shadows, blue accent.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    color-scheme: dark;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

    /* Backgrounds */
    --bg: #0B0B0F;
    --bg-warm: #13141a;
    --surface: #16171c;
    --surface-hover: #1c1d22;
    --surface-raised: #222328;
    --surface-raised-gradient: linear-gradient(180deg, #222328 0%, #1e1f27 100%);
    --surface-element: #2b2c32;
    --overlay: rgba(0, 0, 0, 0.6);
    --overlay-bg: var(--overlay);

    /* White overlays for subtle elevation */
    --white-5: rgba(255, 255, 255, 0.03);
    --white-8: rgba(255, 255, 255, 0.05);
    --white-12: rgba(255, 255, 255, 0.08);
    --white-15: rgba(255, 255, 255, 0.18);
    --white-20: rgba(255, 255, 255, 0.25);

    /* Text */
    --text: #E6E6E6;
    --text-white: #FFFFFF;
    --text-muted: #9592A4;
    --text-placeholder: #6A7782;
    --text-disabled: #46474F;

    /* Accent */
    --blue: #3B8EFF;
    --blue-hover: #5EA8FF;
    --blue-light: #70bcff;
    --blue-dim: rgba(59, 142, 255, 0.14);
    --blue-glow: rgba(59, 142, 255, 0.28);
    --blue-ring: rgba(59, 142, 255, 0.22);

    /* Semantic */
    --teal: #2CC9A0;
    --teal-dim: rgba(44, 201, 160, 0.16);
    --rose: #E84466;
    --rose-dim: rgba(232, 68, 102, 0.16);
    --rose-hover: #F05878;
    --rose-light: #f07088;
    --peach: #FFA86E;
    --orange: #FF8C4A;
    --orange-dim: rgba(255, 140, 74, 0.16);

    /* Borders */
    --border: #222328;
    --border-strong: #31323a;
    --border-focus: rgba(230, 230, 230, 0.4);

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:
        0 0 rgba(0,0,0,0.30),
        0 9px 20px rgba(0,0,0,0.29),
        0 37px 37px rgba(0,0,0,0.26);
    --shadow-lg:
        0 0 rgba(0,0,0,0.30),
        0 9px 20px rgba(0,0,0,0.29),
        0 37px 37px rgba(0,0,0,0.26),
        0 84px 50px rgba(0,0,0,0.15),
        0 149px 60px rgba(0,0,0,0.04),
        0 233px 65px rgba(0,0,0,0.01);

    /* Legacy shadow aliases */
    --shadow-1: var(--shadow-sm);
    --shadow-2: var(--shadow-sm);
    --shadow-3: var(--shadow-md);
    --shadow-4: var(--shadow-lg);
    --shadow-5: var(--shadow-lg);
    --shadow-6: var(--shadow-lg);

    /* Motion */
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --duration-fast: 200ms;
    --duration-base: 320ms;
    --duration-slow: 450ms;

    /* Transition aliases (72+ usages — keep for compat) */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

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

/* ============================================
   Base / Body
   ============================================ */
body {
    font-family: var(--font-sans);
    background:
        radial-gradient(circle, rgba(255,255,255,0.09) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(180deg, #0b0b11 0%, #0c0d14 100%);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100dvh;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(59,142,255,0.10) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

::selection {
    background: var(--blue);
    color: var(--text-white);
}

/* ============================================
   Scrollbar
   ============================================ */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* ============================================
   Skeleton Loading
   ============================================ */
@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.15; }
}

.skeleton {
    background: var(--surface-raised);
    border-radius: var(--radius-sm);
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-text-short {
    height: 14px;
    margin-bottom: 8px;
    width: 40%;
}

.skeleton-heading {
    height: 20px;
    margin-bottom: 16px;
    width: 60%;
}

.skeleton-card {
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.skeleton-row {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.skeleton-block {
    flex: 1;
}

.skeleton-stats-row {
    gap: 16px;
    flex-wrap: wrap;
}

.skeleton-stat-card {
    flex: 1;
    min-width: 120px;
    height: 80px;
}

.calendar-skeleton {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-skeleton-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
}

.table-skeleton-row {
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    height: 60px;
}

/* ============================================
   Layout / Container
   ============================================ */
.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px 64px;
    position: relative;
    z-index: 1;
}

/* Entrance animation */
@keyframes panel-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container > * {
    animation: panel-enter 400ms var(--ease) both;
}

.container > *:nth-child(1) { animation-delay: 0ms; }
.container > *:nth-child(2) { animation-delay: 60ms; }
.container > *:nth-child(3) { animation-delay: 120ms; }
.container > *:nth-child(4) { animation-delay: 180ms; }
.container > *:nth-child(5) { animation-delay: 240ms; }

/* ============================================
   Typography
   ============================================ */
h1 {
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.04em;
    line-height: 1.2;
    margin: 0;
}

h2 {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 24px;
    padding-bottom: 16px;
    position: relative;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -24px;
    right: -24px;
    height: 1px;
    background: var(--border);
}

label {
    font-family: var(--font-sans);
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: color var(--transition-fast);
}

/* ============================================
   Floating Pill Navigation
   ============================================ */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin-bottom: 16px;
    margin-top: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.nav-brand-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand {
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.04em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-xs);
    margin: 0;
}

.nav-link:hover {
    color: var(--text);
    filter: brightness(1.3);
}

.nav-link:active {
    opacity: 0.8;
}

.nav-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue-glow);
}

.nav-link.active {
    color: var(--text);
    background: radial-gradient(ellipse at bottom, var(--white-8) 0%, var(--white-5) 80%);
}

.nav-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
}

.nav-logout svg {
    width: 16px;
    height: 16px;
}

.nav-logout:hover {
    color: var(--rose);
}

.version-pill {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: radial-gradient(ellipse at bottom, var(--white-5) 0%, transparent 80%);
    color: var(--text-placeholder);
    cursor: pointer;
}

.version-pill:hover {
    filter: brightness(1.3);
    color: var(--text-muted);
    border-color: var(--border-strong);
}

.version-pill:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.version-pill:active {
    filter: brightness(0.9);
}

.tab-content {
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.tab-content.active {
    display: block;
    animation: fadeIn var(--transition-normal) forwards;
}

#create-tab {
    padding-bottom: 64px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Card
   ============================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 32px;
    position: relative;
    box-shadow: var(--shadow-2);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    background: var(--surface-hover);
}

/* Section Card (non-hoverable structural container) */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 16px;
    position: relative;
}

.section-header {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

/* ============================================
   Panel Header (Create tab date/weather)
   ============================================ */
.panel-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hero-card {
    margin-bottom: 16px;
}

.header-row-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
}

.header-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 32px;
}

.header-day {
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-white);
    line-height: 1.15;
    letter-spacing: -0.04em;
}

.header-time {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--blue);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.header-date {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--text-placeholder);
    letter-spacing: 0;
}

.header-weather {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-sans);
}

.weather-temp {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.weather-condition {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-placeholder);
    text-transform: capitalize;
}

/* ============================================
   Form Grid & Form Groups
   ============================================ */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.section-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--border);
    margin: 8px -24px;
}

.label-with-value {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-with-value label {
    margin-bottom: 0;
}

.grind-value-inline {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.form-group:hover .grind-value-inline {
    color: var(--text);
}

/* ============================================
   Inputs
   ============================================ */
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    font-family: var(--font-sans);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:hover,
input[type="number"]:hover,
input[type="password"]:hover,
select:hover,
textarea:hover {
    border-color: var(--border-strong);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: var(--text-placeholder);
    font-style: normal;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-ring);
}

input[type="text"]:disabled,
input[type="number"]:disabled,
input[type="password"]:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-disabled);
}

/* Override browser autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    background-color: var(--surface) !important;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============================================
   Input Suggestions (quick-fill tags)
   ============================================ */
.input-suggestions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.suggestion-tag {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: radial-gradient(ellipse at bottom, var(--white-8) 0%, transparent 80%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    padding: 4px 12px;
    cursor: pointer;
    user-select: none;
    text-transform: none;
    letter-spacing: normal;
    margin: 0;
    line-height: 1.5;
}

.suggestion-tag:hover {
    color: var(--blue);
    filter: brightness(1.3);
    border-color: var(--text-placeholder);
}

.suggestion-tag:active {
    filter: brightness(0.9);
}

.suggestion-tag:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* ============================================
   Brew Ratio Display
   ============================================ */
.brew-ratio-display {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-align: center;
    transition: border-color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brew-ratio-display span {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-placeholder);
    transition: color var(--transition-fast);
}

.brew-ratio-display:hover {
    border-color: var(--border-strong);
}

.brew-ratio-display.active {
    border-color: var(--border-strong);
}

.brew-ratio-display.active span {
    color: var(--blue);
}

/* ============================================
   Grind Size Slider
   ============================================ */
.grind-slider-container {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color var(--transition-fast);
}

.grind-slider-container:hover {
    border-color: var(--border-strong);
}

.grind-slider {
    position: relative;
    height: 20px;
    cursor: pointer;
}

.grind-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-strong);
    border-radius: var(--radius-sm);
    transform: translateY(-50%);
}

.grind-fill {
    position: absolute;
    top: 50%;
    left: 0;
    height: 3px;
    background: var(--blue);
    border-radius: var(--radius-sm);
    transform: translateY(-50%);
    width: 0%;
    transition: width var(--transition-fast);
}

.grind-markers {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
}

.grind-marker {
    width: 10px;
    height: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    cursor: pointer;
}

.grind-marker:hover {
    background: var(--surface-element);
    border-color: var(--text-muted);
}

.grind-marker:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.grind-marker.active {
    background: var(--blue);
    border-color: var(--blue);
}

.grind-handle {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    background: var(--blue);
    border: 2px solid var(--text-white);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: all var(--transition-fast);
    opacity: 0;
    left: 0%;
    box-shadow: var(--shadow-2);
}

.grind-handle.active {
    opacity: 1;
}

.grind-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.grind-handle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* ============================================
   Custom Dropdown Select
   ============================================ */
.custom-select {
    position: relative;
}

.custom-select select {
    display: none;
}

.select-trigger {
    font-family: var(--font-sans);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.select-trigger:hover {
    border-color: var(--border-strong);
}

.select-trigger.active {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-ring);
}

.select-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.select-trigger-text {
    flex: 1;
}

.select-trigger-text.placeholder {
    color: var(--text-placeholder);
}

.select-arrow {
    width: 16px;
    height: 16px;
    margin-left: 16px;
    transition: transform var(--transition-fast);
}

/* Override inline stroke on SVG arrows/carets */
.select-arrow path,
.dev-tools-caret path,
.statistics-caret path,
.week-caret path,
.report-card-caret path {
    stroke: var(--text-muted) !important;
}

.select-trigger.active .select-arrow {
    transform: rotate(180deg);
}

.select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    z-index: 10;
    opacity: 0;
    transform: translateY(-4px);
    transform-origin: top;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
    visibility: hidden;
    box-shadow: var(--shadow-3);
}

.select-dropdown.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    visibility: visible;
}

.select-options {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 0;
}

.select-option {
    font-family: var(--font-sans);
    padding: 12px 16px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    font-size: 15px;
}

.select-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.select-option.selected {
    background: var(--surface-element);
    color: var(--blue);
}

.select-option.focused {
    background: var(--surface-hover);
    color: var(--text);
}

.select-option.placeholder {
    color: var(--text-placeholder);
}

/* ============================================
   Rating Stars
   ============================================ */
.rating-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stars {
    display: flex;
    gap: 8px;
}

.star {
    font-size: 28px;
    cursor: pointer;
    color: var(--border-strong);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.star:hover,
.star.active {
    color: var(--peach);
}

.star:active {
    transform: scale(0.9);
}

.star:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
    border-radius: var(--radius-sm);
}

/* ============================================
   Buttons
   ============================================ */
button {
    font-family: var(--font-sans);
    background: radial-gradient(ellipse at bottom, var(--white-8) 0%, transparent 80%);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-xs);
    cursor: pointer;
    margin-top: 16px;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1;
}

button:hover {
    color: var(--text);
    filter: brightness(1.3);
    border-color: var(--text-placeholder);
}

button:active:not(:disabled) {
    filter: brightness(0.9);
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-disabled);
}

/* Primary button — form submit */
button[type="submit"] {
    background: radial-gradient(ellipse at bottom, var(--blue-light) 0%, var(--blue) 80%);
    color: var(--text-white);
    border: 1px solid var(--white-15);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

button[type="submit"]:hover {
    filter: brightness(1.2);
    border-color: var(--white-20);
    color: var(--text-white);
}

button[type="submit"]:active:not(:disabled) {
    filter: brightness(0.9);
}

button[type="submit"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* Danger button */
.delete-btn {
    background: radial-gradient(ellipse at bottom, var(--rose-light) 0%, var(--rose) 80%);
    border: 1px solid var(--white-15);
    color: var(--text-white);
    padding: 8px 16px;
    font-size: 13px;
    margin-top: 16px;
}

.delete-btn:hover {
    filter: brightness(1.2);
    border-color: var(--white-20);
    color: var(--text-white);
}

.delete-btn:active {
    filter: brightness(0.9);
}

/* ============================================
   Coffee Entry Card (History items)
   ============================================ */
.coffee-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.coffee-entry:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-2);
}

.coffee-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.coffee-title {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-white);
    letter-spacing: -0.02em;
}

.coffee-rating {
    color: var(--peach);
    font-size: 18px;
}

.coffee-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 8px;
}

.detail {
    font-size: 14px;
}

.detail-label {
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--text-placeholder);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.detail-value {
    font-family: var(--font-sans);
    color: var(--text-muted);
    transition: color var(--transition-fast);
    font-size: 14px;
}

.coffee-entry:hover .detail-value {
    color: var(--text);
}

.coffee-entry:hover .detail-label {
    color: var(--text-muted);
}

.coffee-notes {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-style: normal;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 65ch;
    font-family: var(--font-sans);
    font-size: 14px;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 64px 40px;
    color: var(--text-placeholder);
    font-family: var(--font-sans);
    font-size: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.empty-calendar {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-placeholder);
    font-family: var(--font-sans);
    font-size: 15px;
}

/* ============================================
   Developer Tools
   ============================================ */
.dev-tools-card {
    border-color: var(--border);
}

.dev-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin: 0 -24px 8px -24px;
    padding: 0 24px;
    transition: background var(--transition-fast);
    border-radius: var(--radius-sm);
}

.dev-tools-header.collapsed {
    margin: -24px;
    padding: 24px;
}

.dev-tools-header.collapsed:hover {
    background: var(--surface-hover);
}

.dev-tools-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    text-transform: none;
    flex: 1;
}

.dev-tools-header h2::after {
    display: none;
}

.dev-tools-caret {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
    flex-shrink: 0;
    transform: rotate(180deg);
}

.dev-tools-header.collapsed .dev-tools-caret {
    transform: rotate(0deg);
}

.dev-tools-content {
    max-height: 500px;
    opacity: 1;
    overflow: hidden;
    transition: max-height var(--transition-normal), opacity var(--transition-normal);
}

.dev-tools-content.collapsed {
    max-height: 0;
    opacity: 0;
}


/* ============================================
   Changelog Panel
   ============================================ */
.changelog-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.changelog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.changelog-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(8px) scale(0.98);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: var(--surface-raised-gradient);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 25;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), transform var(--transition-normal), visibility var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.changelog-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) translateY(0) scale(1);
}

.changelog-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.changelog-title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.changelog-close {
    background: none;
    border: none;
    color: var(--text-placeholder);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
}

.changelog-close:hover {
    color: var(--text);
    filter: brightness(1.3);
}

.changelog-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.changelog-content {
    overflow-y: auto;
    padding: 16px 24px 20px;
    flex: 1;
    min-height: 0;
}

/* Clockwork-style changelog rows */
.changelog-list {
    display: flex;
    flex-direction: column;
}

.changelog-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 0;
    cursor: default;
}

.changelog-row + .changelog-row {
    border-top: 1px solid var(--border-strong);
}

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

.changelog-date {
    font-size: 12px;
    color: var(--text-placeholder);
    margin-left: auto;
    white-space: nowrap;
}

.changelog-version {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.changelog-type-badge {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.changelog-type-badge[data-type="minor"] {
    background: var(--blue-dim);
    color: var(--blue);
}

.changelog-type-badge[data-type="major"] {
    background: var(--rose-dim);
    color: var(--rose);
}

.changelog-type-badge[data-type="patch"] {
    background: var(--teal-dim);
    color: var(--text-muted);
}

.changelog-desc {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ============================================
   Dialog (Confirm/Alert)
   ============================================ */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(8px) scale(0.98);
    width: 90%;
    max-width: 400px;
    background: var(--surface-raised-gradient);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), transform var(--transition-normal), visibility var(--transition-normal);
    overflow: hidden;
}

.dialog-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) translateY(0) scale(1);
}

.dialog-content {
    padding: 32px;
}

.dialog-message {
    font-family: var(--font-sans);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
}

.dialog-actions {
    display: flex;
    border-top: 1px solid var(--border);
}

.dialog-btn {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-transform: none;
    letter-spacing: 0;
    border-radius: 0;
    margin: 0;
}

.dialog-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.dialog-btn:active {
    background: var(--surface-element);
}

.dialog-btn:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--blue-glow);
}

.dialog-btn + .dialog-btn {
    border-left: 1px solid var(--border);
}

.dialog-btn.primary {
    color: var(--blue);
    font-weight: 600;
}

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

.dialog-btn.danger {
    color: var(--rose);
}

.dialog-btn.danger:hover {
    background: var(--surface-hover);
    color: var(--rose);
}

/* ============================================
   Filter Modal (Slide-in panel)
   ============================================ */
.filter-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.filter-overlay.active {
    opacity: 1;
    visibility: visible;
}

.filter-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 500px;
    max-width: 90vw;
    height: 100dvh;
    background: var(--surface-raised-gradient);
    border-left: 1px solid var(--border-strong);
    z-index: 25;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--transition-normal), visibility var(--transition-normal);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.filter-modal.active {
    visibility: visible;
    transform: translateX(0);
}

.filter-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-modal-title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-modal-close {
    background: none;
    border: none;
    color: var(--text-placeholder);
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    border-radius: var(--radius-xs);
}

.filter-modal-close:hover {
    color: var(--text);
    filter: brightness(1.3);
}

.filter-modal-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.filter-modal-content {
    overflow-y: auto;
    padding: 32px;
    flex: 1;
}

.filter-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 32px;
    border-top: 1px solid var(--border);
}

.filter-reset-btn,
.filter-save-btn {
    font-family: var(--font-sans);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    margin: 0;
}

.filter-reset-btn {
    background: radial-gradient(ellipse at bottom, var(--white-8) 0%, transparent 80%);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.filter-reset-btn:hover {
    color: var(--text);
    filter: brightness(1.3);
    border-color: var(--text-placeholder);
}

.filter-reset-btn:active {
    filter: brightness(0.9);
}

.filter-save-btn {
    background: radial-gradient(ellipse at bottom, var(--blue-light) 0%, var(--blue) 80%);
    border: 1px solid var(--white-15);
    color: var(--text-white);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.filter-save-btn:hover {
    filter: brightness(1.2);
    border-color: var(--white-20);
    color: var(--text-white);
}

.filter-reset-btn:active,
.filter-save-btn:active {
    filter: brightness(0.9);
}

.filter-reset-btn:focus-visible,
.filter-save-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* ============================================
   History Controls
   ============================================ */
.history-controls {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-btn {
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    margin: 0;
}

.filter-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.filter-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.filter-icon {
    font-size: 16px;
}

.filter-count {
    font-family: var(--font-mono);
    color: var(--text-placeholder);
    font-weight: 600;
    font-size: 0.9em;
}

/* View Mode Switcher */
.view-mode-switcher {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 0;
}

.view-mode-label {
    font-family: var(--font-sans);
    background: transparent;
    border: none;
    color: var(--text-placeholder);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    padding: 8px 16px;
    line-height: 1;
    border-radius: var(--radius-sm);
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}

.view-mode-label:hover {
    color: var(--text-muted);
}

.view-mode-label:active {
    background: var(--surface-element);
}

.view-mode-label.active {
    background: var(--surface-element);
    color: var(--blue);
    font-weight: 600;
}

.view-mode-label:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* Hide old toggle slider */
.view-toggle {
    display: none;
}

.toggle-slider {
    display: none;
}

/* ============================================
   Statistics Section
   ============================================ */
.statistics-section {
    margin: -24px;
    overflow: hidden;
}

.statistics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin: 0;
    padding: 32px;
    transition: background var(--transition-fast);
}

.statistics-header.collapsed .stats-time-toggle {
    opacity: 0;
    pointer-events: none;
}

.statistics-header.collapsed:hover {
    background: var(--surface-hover);
}

.statistics-header h2 {
    margin: 0;
    padding: 0;
    text-transform: none;
    flex: 1;
    line-height: 1.2;
}

.statistics-header h2::after {
    display: none;
}

.statistics-caret {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
    flex-shrink: 0;
    transform: rotate(180deg);
    display: block;
}

.statistics-header.collapsed .statistics-caret {
    transform: rotate(0deg);
}

.statistics-content {
    max-height: 800px;
    overflow: hidden;
    padding: 8px 32px 24px 32px;
    transition: max-height var(--transition-normal), opacity var(--transition-normal), padding var(--transition-normal);
}

.statistics-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.statistics-content.fading {
    opacity: 0;
}

.statistics-empty {
    text-align: center;
    color: var(--text-placeholder);
    font-family: var(--font-sans);
    font-size: 15px;
    padding: 24px 0;
}

/* Stats Time Toggle */
.stats-time-toggle {
    display: flex;
    align-items: center;
    gap: 0;
    margin-left: auto;
    margin-right: 12px;
    transition: opacity var(--transition-fast);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.stats-time-btn {
    font-family: var(--font-sans);
    background: transparent;
    border: none;
    color: var(--text-placeholder);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}

.stats-time-btn:hover {
    color: var(--text-muted);
}

.stats-time-btn:active {
    background: var(--surface-element);
}

.stats-time-btn.active {
    background: var(--surface-element);
    color: var(--blue);
    font-weight: 600;
}

.stats-time-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

/* Stats Overview Cards */
.stats-overview {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    aspect-ratio: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-1);
}

.stat-card-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 8px;
    line-height: 1;
}

.stat-card-label {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-card-comparison {
    font-family: var(--font-mono);
    font-size: 0.9em;
    margin-top: 4px;
}

.stat-card-comparison.positive {
    color: var(--teal);
}

.stat-card-comparison.negative {
    color: var(--rose);
}

.stat-card-comparison.neutral {
    color: var(--text-placeholder);
}

/* Chart Sections */
.stats-chart-section {
    margin-bottom: 20px;
}

.stats-chart-section:last-child {
    margin-bottom: 0;
}

.stats-chart-title {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* Horizontal Bar Chart */
.stat-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.stat-bar:last-child {
    margin-bottom: 0;
}

.stat-bar-label {
    font-family: var(--font-sans);
    width: 100px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-bar-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--blue);
    border-radius: var(--radius-sm);
    transition: width var(--transition-normal);
}

.stat-bar-value {
    font-family: var(--font-mono);
    width: 45px;
    font-size: 0.9em;
    color: var(--text-placeholder);
    text-align: right;
}

/* Vertical Time Chart */
.time-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 80px;
    padding-top: 12px;
}

.time-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.time-bar-fill {
    width: 50px;
    background: var(--blue);
    border-radius: var(--radius-sm);
    transition: height var(--transition-normal);
}

.time-bar-label {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-placeholder);
}

.time-bar-value {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--text-muted);
    position: absolute;
    top: -20px;
}

.time-bar-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Ratings Chart */
.rating-bar-label {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100px;
}

.rating-star {
    color: var(--peach);
    font-size: 14px;
}

/* ============================================
   Calendar
   ============================================ */
.calendar-container {
    width: 100%;
    transition: opacity var(--transition-fast);
}

.calendar-container.hidden {
    display: none;
}

.calendar-container.fading {
    opacity: 0;
}

.calendar-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
}

.calendar-controls-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-nav-btn {
    font-family: var(--font-sans);
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    margin: 0;
}

.calendar-nav-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.calendar-nav-btn:active {
    background: var(--surface-element);
}

.calendar-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.calendar-today-btn {
    font-family: var(--font-sans);
    padding: 8px 16px;
    font-size: 13px;
    letter-spacing: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    margin: 0;
    text-transform: none;
}

.calendar-today-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.calendar-today-btn:active {
    background: var(--surface-element);
}

.calendar-header-text {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-family: var(--font-sans);
    line-height: 1;
    margin-top: 16px;
}

.calendar-month {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-white);
    letter-spacing: -0.02em;
}

.calendar-year {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Calendar Grid */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.calendar-weekday {
    text-align: center;
    padding: 8px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-placeholder);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-placeholder);
    font-family: var(--font-sans);
    font-size: 14px;
    position: relative;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
    cursor: default;
}

.calendar-day.other-month {
    opacity: 0.3;
    pointer-events: none;
}

.calendar-day.today {
    border-color: var(--blue);
    background: var(--surface-hover);
    color: var(--blue);
    box-shadow: var(--shadow-1);
}

.calendar-day.has-reports {
    cursor: pointer;
    border-color: var(--border-strong);
    background: var(--surface-raised);
    color: var(--text-muted);
}

.calendar-day.has-reports:hover {
    border-color: var(--blue);
    color: var(--text);
    box-shadow: var(--shadow-2);
}

.calendar-day.has-reports:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.calendar-day-number {
    font-weight: 600;
    margin-bottom: 4px;
}

.calendar-day-indicators {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    align-items: center;
}

.calendar-day-indicator {
    width: 5px;
    height: 5px;
    background: var(--blue);
    border-radius: 50%;
}

.calendar-day-indicator-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-placeholder);
    margin-left: 2px;
}

/* Hover Tooltip */
.calendar-day-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    white-space: nowrap;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text);
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity var(--transition-fast);
    box-shadow: var(--shadow-3);
}

.calendar-day:hover .calendar-day-tooltip {
    opacity: 1;
    transition-delay: 300ms;
}

.calendar-day-tooltip-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.calendar-day-tooltip-more {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-placeholder);
    margin-top: 2px;
}

/* ============================================
   Table View
   ============================================ */
.table-container {
    width: 100%;
    transition: opacity var(--transition-fast);
}

.table-container.hidden {
    display: none;
}

.table-container.fading {
    opacity: 0;
}

/* Week Section */
.week-section {
    margin-bottom: 24px;
}

.week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    margin-bottom: 12px;
}

.week-header:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.week-header-text {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.week-title {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.week-date-range {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-placeholder);
}

.week-caret {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
    flex-shrink: 0;
}

.week-header.expanded .week-caret {
    transform: rotate(180deg);
}

.week-content {
    display: none;
    padding-left: 0;
}

.week-content.expanded {
    display: block;
}

/* Report Card in Table */
.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.report-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-1);
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.report-card-header:hover {
    background: var(--surface-hover);
}

.report-card-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-date {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-placeholder);
    font-weight: 500;
}

.report-bean-name {
    font-family: var(--font-sans);
    font-size: 16px;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.report-card-caret {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
    flex-shrink: 0;
}

.report-card.expanded .report-card-caret {
    transform: rotate(180deg);
}

.report-card-content {
    display: none;
    padding: 0 24px 24px 24px;
}

.report-card.expanded .report-card-content {
    display: block;
}

.report-card-content .coffee-entry {
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.report-card-content .coffee-header {
    margin-bottom: 16px;
}

/* ============================================
   Day Panel (Side Panel from calendar)
   ============================================ */
.day-panel-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.day-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

.day-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 500px;
    max-width: 90vw;
    height: 100dvh;
    background: var(--surface-raised-gradient);
    border-left: 1px solid var(--border-strong);
    z-index: 25;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.day-panel.active {
    transform: translateX(0);
}

.day-panel-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-panel-title {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-white);
    letter-spacing: -0.02em;
}

.day-panel-close {
    background: none;
    border: none;
    color: var(--text-placeholder);
    font-size: 22px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    border-radius: var(--radius-xs);
}

.day-panel-close:hover {
    color: var(--text);
    filter: brightness(1.3);
}

.day-panel-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.day-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.day-panel-content .coffee-entry {
    margin-bottom: 24px;
}

.day-panel-content .coffee-entry:last-child {
    margin-bottom: 0;
}

/* ============================================
   PIN Login Screen
   ============================================ */
.pin-screen {
    position: fixed;
    inset: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 32px;
    background:
        radial-gradient(circle, rgba(255,255,255,0.09) 1px, transparent 1px) 0 0 / 32px 32px,
        linear-gradient(180deg, #0b0b11 0%, #0c0d14 100%);
    z-index: 10;
}

.pin-screen.hidden {
    display: none;
}

.pin-screen::before {
    content: 'Grindscope';
    display: block;
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.04em;
}

.pin-container {
    display: flex;
    gap: 12px;
}

.pin-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition:
        border-color var(--duration-fast) var(--ease),
        box-shadow var(--duration-fast) var(--ease);
}

.pin-input:hover {
    border-color: var(--border-strong);
}

.pin-input:focus,
.pin-input:focus-visible {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-ring);
}

.pin-input.error {
    border-color: var(--rose);
}

.pin-screen .demo-button {
    font-family: var(--font-sans);
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.pin-screen .demo-button:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.pin-screen .demo-button:active {
    filter: brightness(0.9);
}

.pin-screen .demo-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}


/* ============================================
   Notification Toast
   ============================================ */
.notification {
    font-family: var(--font-sans);
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 14px;
    z-index: 40;
    box-shadow: var(--shadow-4);
    animation: slideIn var(--transition-fast);
}

.notification-success {
    border-color: var(--teal);
}

.notification-error {
    border-color: var(--rose);
}

.notification-info {
    border-color: var(--blue);
}

.notification.fade-out {
    opacity: 0;
    transition: opacity var(--transition-normal);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Scan Zone
   ============================================ */
.scan-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 20px;
    cursor: pointer;
    text-align: center;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
    margin-bottom: 24px;
}

.scan-zone:hover {
    border-color: var(--blue);
    background: var(--surface);
}

.scan-zone.drag-over {
    border-color: var(--blue);
    background: rgba(59, 142, 255, 0.06);
}

.scan-zone:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.scan-zone-idle,
.scan-zone-loading,
.scan-zone-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.scan-zone-icon {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.scan-zone-title {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.scan-zone-hint {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-placeholder);
}

.scan-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--blue);
    border-radius: 9999px;
    animation: scan-spin 0.8s linear infinite;
    margin-bottom: 4px;
}

@keyframes scan-spin {
    to { transform: rotate(360deg); }
}

.scan-result-text {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--teal);
}

.scan-clear-btn {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.scan-clear-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.scan-clear-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

.scan-zone-thumbs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.scan-zone-thumbs:empty {
    display: none;
}

.scan-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
}

/* ============================================
   Demo Mode
   ============================================ */
.demo-mode .scan-zone {
    display: none;
}

.demo-mode .delete-btn,
.demo-mode .add-coffee-btn,
.demo-mode .dev-tools-card {
    display: none;
}

.demo-banner {
    font-family: var(--font-sans);
    background: var(--surface);
    border: 1px solid var(--blue);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.demo-banner.hidden {
    display: none;
}



/* ============================================
   Disabled States
   ============================================ */
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    color: var(--text-disabled);
}

/* ============================================
   Global Transitions
   ============================================ */
button,
a,
input,
textarea,
select {
    transition:
        color var(--duration-base) var(--ease),
        background-color var(--duration-base) var(--ease),
        border-color var(--duration-base) var(--ease),
        box-shadow var(--duration-base) var(--ease),
        opacity var(--duration-base) var(--ease),
        filter var(--duration-base) var(--ease);
}

/* ============================================
   Global Focus-Visible
   ============================================ */
:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-glow);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue-ring);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none;
}

.container.hidden {
    display: none;
}

body.no-scroll {
    overflow: hidden;
}

.inline {
    display: inline;
}

.sr-only {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sr-only:focus {
    position: fixed;
    top: 16px;
    left: 16px;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 12px 20px;
    background: var(--surface-raised);
    border: 2px solid var(--blue);
    color: var(--blue);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-3);
}

/* ============================================
   Responsive — Mobile (max-width: 767px)
   ============================================ */
@media (max-width: 767px) {
    .container {
        padding: 0 16px;
        padding-bottom: max(64px, env(safe-area-inset-bottom));
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .coffee-details {
        grid-template-columns: 1fr;
    }

    /* Nav responsive */
    .nav {
        padding: 10px 16px;
    }

    .nav-brand {
        font-size: 18px;
    }

    .nav-link {
        font-size: 12px;
        padding: 6px 8px;
    }

    .changelog-panel {
        width: 95%;
        max-height: 90vh;
    }

    .changelog-header {
        padding: 20px 24px;
    }

    .changelog-entry {
        padding: 12px 24px;
    }

    .card,
    .section-card {
        padding: 20px;
    }

    /* Panel header responsive */
    .header-row-top,
    .header-row-bottom {
        flex-direction: column;
        gap: 8px;
    }

    .header-day {
        font-size: 22px;
    }

    .header-time {
        font-size: 22px;
    }

    .weather-temp,
    .weather-condition {
        font-size: 13px;
    }

    /* History controls responsive */
    .history-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Statistics responsive */
    .statistics-section {
        margin: -20px;
    }

    .statistics-header {
        padding: 24px;
    }

    .statistics-content {
        padding: 16px 24px 24px 24px;
    }

    .stats-overview {
        gap: 12px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card-value {
        font-size: 22px;
    }

    .stat-bar-label {
        width: 80px;
        font-size: 12px;
    }

    .stat-bar-value {
        width: 55px;
        font-size: 12px;
    }

    .rating-bar-label {
        width: 80px;
        font-size: 12px;
    }

    .time-bar-fill {
        width: 40px;
    }

    /* Calendar responsive */
    .calendar-controls-left {
        justify-content: center;
        flex-wrap: nowrap;
    }

    .calendar-header-text {
        justify-content: center;
    }

    .view-mode-switcher {
        gap: 4px;
    }

    .filter-modal {
        width: 100%;
        max-width: none;
        border-left: none;
    }

    .calendar-days {
        gap: 4px;
    }

    .calendar-day {
        font-size: 12px;
        padding: 6px;
        min-height: 44px;
    }

    .calendar-day-tooltip {
        display: none !important;
    }

    .day-panel {
        width: 100%;
        max-width: none;
        border-left: none;
    }

    .filter-modal-header {
        padding: 20px 24px;
    }

    .filter-modal-content {
        padding: 24px;
    }

    .filter-modal-actions {
        padding: 12px 24px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        flex-direction: column;
    }

    .filter-reset-btn,
    .filter-save-btn {
        width: 100%;
    }

    /* Table view responsive */
    .report-card-header {
        padding: 12px 16px;
    }

    .report-card-content {
        padding: 0 16px 16px 16px;
    }

    .week-header {
        padding: 12px 16px;
    }

    /* Section divider responsive */
    .section-divider {
        margin-left: -20px;
        margin-right: -20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .nav-brand {
        font-size: 16px;
    }

    .version-pill {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .pin-screen::before {
        font-size: 20px;
    }
}

@media (max-width: 400px) {
    .pin-input {
        width: 40px;
        height: 48px;
        font-size: 16px;
    }

    .pin-container {
        gap: 8px;
    }
    .container {
        padding: 0 12px;
    }

    .calendar-weekdays {
        gap: 2px;
    }

    .calendar-weekday {
        padding: 4px 2px;
        font-size: 11px;
        letter-spacing: 0;
    }

    .calendar-days {
        gap: 2px;
    }

    .calendar-day {
        padding: 4px;
        font-size: 11px;
        min-height: 40px;
    }

    .card,
    .section-card {
        padding: 16px;
    }

    .statistics-section {
        margin: -16px;
    }

    .section-divider {
        margin-left: -16px;
        margin-right: -16px;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
