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

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

/* ── Design Tokens ── */
:root {
    /* Curated, harmonious, premium cool/neutral gray palette */
    --color-bg:       #EAECEF; /* Level 0: page canvas - clean slate gray */
    --color-surface:  #F3F4F6; /* Level 1: sidebar, grid-wrapper outer frame */
    --color-card:     #FFFFFF; /* Level 2: bento cards, flyouts - pure white to pop */
    --color-cell:     #FFFFFF; /* Level 3: grid cells - purest white inside grid */
    --color-cell-shaded: #F8FAFC; /* Shaded checkerboard blocks - ultra soft cool tint */

    --color-border:   #D1D5DB; /* Clean border */
    --color-text:     #1F2937; /* Rich charcoal text */
    --color-text-muted: #6B7280;

    --grid-line-thick: #1F2937;
    --grid-line-thin:  #E5E7EB; /* visible between cells */

    --cell-highlight-same:    #C2DBFA; /* Soft clear blue for active cell and same digits */
    --cell-highlight-axis:    #E8F0FE; /* Soft light blue/gray for crosshair row/column */
    --cell-highlight-block:   #E8F0FE; /* Unified soft light blue/gray for crosshair 3x3 block */

    --color-accent-blue: #0F62FE; /* IBM Blue */

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --transition-smooth: 0.2s cubic-bezier(0.16, 1, 0.3, 1);

    color-scheme: light;
}

:root[data-theme="dark"] {
    /* Curated, deep slate dark mode palette */
    --color-bg:       #0B0F19; /* Level 0: page canvas - deep slate blue/black */
    --color-surface:  #111827; /* Level 1: sidebar, grid-wrapper */
    --color-card:     #1F2937; /* Level 2: bento cards */
    --color-cell:     #1F2937; /* Level 3: grid cells */
    --color-cell-shaded: #182030; /* Shaded checkerboard blocks - slightly darker slate tint */

    --color-border:   #374151;
    --color-text:     #F9FAFB;
    --color-text-muted: #9CA3AF;

    --grid-line-thick: #F9FAFB;
    --grid-line-thin:  #374151;

    --cell-highlight-same:    rgba(224, 157, 217, 0.22); /* Translucent pink — matches light mode feel */
    --cell-highlight-axis:    rgba(199, 140, 197, 0.18);
    --cell-highlight-block:   rgba(179, 116, 177, 0.14);

    --color-accent-blue: #E09DD9; /* Softer pastel pink accent for dark mode */

    color-scheme: dark;
}

html,
body {
    height: 100vh;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    position: relative;
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── App Layout ── */
.app-layout {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100vh;
    width: 100%;
    margin: 0;
    overflow: hidden;
}

/* ── Main Area ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 48px 48px 48px;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow-y: auto;
}

.studio-header {
    width: 100%;
    max-width: 524px;
    margin-bottom: 20px;
    text-align: left;
}

.brand-title {
    font-family: 'Instrument Serif', 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--color-text);
}

/* ── Grid Panel ── */
.grid-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
}

#grid-wrapper {
    position: relative;
    padding: 20px;
    background-color: var(--color-surface); /* L1: lighter than page */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

#grid {
    display: grid;
    grid-template-columns: repeat(3, auto);
    background-color: var(--grid-line-thick);
    border: 2px solid var(--grid-line-thick);
    gap: 2px;
    border-radius: var(--radius-md);
    overflow: hidden;
    width: fit-content;
    height: fit-content;
}

.box {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    background-color: var(--grid-line-thin);
    gap: 1px;
}

/* ── Cell Container & Inputs ── */
.cell-container {
    position: relative;
    width: 52px;
    height: 52px;
    background-color: var(--color-cell); /* L3: purest white inside grid */
    transition: background-color 0.15s ease;
}

/* 3x3 sub-grid alternating shading */
.box:nth-child(even) .cell-container {
    background-color: var(--color-cell-shaded);
}

.cell-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    text-align: center;
    font-size: 21px;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    color: var(--color-text);
    z-index: 2;
    caret-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cell-input:focus {
    background-color: var(--color-cell);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent-blue) 35%, transparent);
    font-weight: 600;
}

/* Cell highlight states (high specificity to override checkerboard shading) */
.box .cell-container.highlight-axis {
    background-color: var(--cell-highlight-axis);
}

.box .cell-container.highlight-block {
    background-color: var(--cell-highlight-block);
}

/* Given (board-generated) numbers: accent blue, clearly distinct from user entries */
.cell-input.given {
    background-color: transparent;
    color: var(--color-accent-blue);
    font-weight: 700;
}

/* highlight-same must come AFTER given — same specificity, last rule wins.
   This ensures given cells also receive the highlight background. */
.cell-input.highlight-same {
    background-color: var(--cell-highlight-same);
    font-weight: 700;
}

.cell-input.solved {
    color: var(--color-text);
    font-weight: 500;
    animation: solvePulse 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cell-input.error-cell {
    color: #C2410C !important; /* Muted technical red/orange */
    text-decoration: underline;
    text-decoration-style: dotted;
    font-weight: 700;
}
[data-theme="dark"] .cell-input.error-cell {
    color: #F97316 !important;
}

@keyframes solvePulse {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* ── Notes/Candidates Grid ── */
.notes-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 3px;
    box-sizing: border-box;
    z-index: 3;
    pointer-events: none;
}

.notes-grid span {
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    line-height: 1;
    transition: opacity 0.1s ease;
}

.notes-grid span.active {
    opacity: 1;
    font-weight: 500;
}

/* Hide notes grid when cell has value */
.cell-input.has-value ~ .notes-grid {
    display: none !important;
}

/* ── Remaining Placements Tracker ── */
.tracker-card {
    width: 100%;
}

.card-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.tracker-digits {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
}

.tracker-digit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 38px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface); /* L1: sits inside card (L2) */
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 0;
    margin: 0;
    outline: none;
    box-sizing: border-box;
}

.tracker-digit-btn:hover,
.tracker-digit:hover {
    border-color: var(--color-text-muted);
    background-color: rgba(224, 157, 217, 0.08); /* gentle pink tint */
}

[data-theme="dark"] .tracker-digit-btn:hover,
[data-theme="dark"] .tracker-digit:hover {
    border-color: var(--color-text-muted);
    background-color: rgba(224, 157, 217, 0.08); /* gentle pink tint */
}

.tracker-digit-btn:active,
.tracker-digit:active {
    transform: scale(0.98);
}

.tracker-digit-btn .digit-num {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: var(--color-text);
    line-height: 1.2;
}

.tracker-digit-btn .digit-count {
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* Complete digit style (Clean, no background tint) */
.tracker-digit-btn.digit-complete {
    background-color: var(--color-surface);
    border-color: var(--color-border);
}

.tracker-digit-btn.digit-complete .digit-num {
    color: var(--color-text-muted);
    font-weight: 400;
}

.tracker-digit-btn.digit-complete .digit-count {
    color: var(--color-text-muted);
}

/* Highlight state when filter is active */
.tracker-digit.active-filter,
.tracker-digit-btn.active-filter {
    background-color: var(--color-accent-blue) !important;
    border-color: var(--color-accent-blue) !important;
}

.tracker-digit.active-filter .digit-num,
.tracker-digit-btn.active-filter .digit-num {
    color: #FFFFFF !important;
    font-weight: 600;
}

.tracker-digit.active-filter .digit-count,
.tracker-digit-btn.active-filter .digit-count {
    color: rgba(255, 255, 255, 0.85) !important;
}

[data-theme="dark"] .tracker-digit.active-filter .digit-num,
[data-theme="dark"] .tracker-digit-btn.active-filter .digit-num {
    color: #0B0F19 !important; /* dark canvas color for contrast */
}

[data-theme="dark"] .tracker-digit.active-filter .digit-count,
[data-theme="dark"] .tracker-digit-btn.active-filter .digit-count {
    color: rgba(11, 15, 25, 0.85) !important;
}

/* ── Sidebar ── */
.sidebar {
    width: 320px;
    min-width: 320px;
    border-left: 1px solid var(--color-border);
    background-color: var(--color-surface);
    padding: 60px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 2px;
}

/* Bento Card Panels — Level 2 */
.bento-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    background-color: var(--color-card);
}

/* Timer Card */
.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timer-header .card-label {
    margin-bottom: 0;
}

.timer-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.4rem;
    font-weight: 500;
    line-height: 1;
    color: var(--color-text);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.guide-separator {
    margin: 0 4px;
    color: var(--color-text-muted);
    font-size: 0.65rem;
}

.timer-controls {
    display: flex;
    gap: 6px;
}

/* Badge tags (Monochrome borders, no background colors) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-muted);
}

/* Action Grids */
.action-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.action-grid-three {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

.action-grid-two {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 6px;
    margin-top: 6px;
}

/* Buttons styling following the /minimalist-ui */
.btn {
    height: 36px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 0 10px;
    border: 1px solid var(--color-border);
    background-color: var(--color-card); /* L2: buttons sit on card layer */
    color: var(--color-text);
    white-space: nowrap;
    text-wrap: nowrap;
}

.btn-sm {
    height: 30px;
    font-size: 0.7rem;
    padding: 0 8px;
}

.btn:hover:not(:disabled) {
    background-color: var(--color-surface);
    border-color: var(--color-text-muted);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

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

.btn-primary {
    background-color: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background-color: #374151;
    border-color: #374151;
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
    background-color: #D1D5DB;
    border-color: #D1D5DB;
}

.btn-secondary {
    color: var(--color-text-muted);
    background-color: var(--color-card);
}
.btn-secondary:hover:not(:disabled) {
    color: var(--color-text);
}

.btn-accent {
    border-color: var(--color-text-muted);
    font-weight: 600;
}
.btn-accent:hover:not(:disabled) {
    background-color: var(--color-surface);
    border-color: var(--color-text);
}

/* ── Segmented Control (Mode Switch) ── */
.segmented-control {
    display: flex;
    width: 100%;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 2px;
    height: 36px;
    box-sizing: border-box;
}

.seg-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--color-text-muted);
    border-radius: calc(var(--radius-sm) - 1px);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    height: 100%;
    padding: 0 12px; /* give more breathing room */
    white-space: nowrap;
    text-wrap: nowrap;
}

.seg-btn:hover:not(:disabled) {
    color: var(--color-text);
    background-color: rgba(224, 157, 217, 0.08); /* gentle pink tint */
}

[data-theme="dark"] .seg-btn:hover:not(:disabled) {
    background-color: rgba(224, 157, 217, 0.08); /* gentle pink tint */
}

.seg-btn:active:not(:disabled) {
    transform: scale(0.99);
}

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

.seg-btn.active {
    background-color: var(--color-text);
    color: var(--color-bg);
    font-weight: 600;
}

/* Difficulty dropdown inside sidebar */
.new-game-group {
    position: relative;
    width: 100%;
}

.difficulty-flyout {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 220px;
    z-index: 100;
    padding: 10px;
    background: var(--color-card); /* L2: flyout floats above sidebar (L1) */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    animation: flyoutReveal 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.difficulty-flyout[hidden] {
    display: none;
}

.flyout-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.flyout-options {
    display: flex;
    gap: 4px;
}

.diff-btn {
    flex: 1;
    padding: 5px 0;
    margin: 0;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface); /* L1: diff buttons sit inside flyout (L2) */
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.diff-btn:hover {
    background-color: var(--color-card);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

@keyframes flyoutReveal {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Keyboard Guide Card */
.guide-card {
    display: flex;
    flex-direction: column;
}

.guide-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.guide-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    line-height: 1.4;
}

.guide-keys {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* Physical keys styling <kbd> */
kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 1px 4px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background-color: var(--color-cell);
    color: var(--color-text);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
    line-height: 1.1;
}

.guide-desc {
    color: var(--color-text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

#status {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    font-weight: 500;
    min-height: 1.2em;
    line-height: 1.4;
    flex: 1;
}

#status.success {
    color: var(--color-text);
    font-weight: 650;
}

#status.error {
    color: var(--color-text);
    text-decoration: underline;
    font-weight: 650;
}

/* Theme Toggle Button */
.icon-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

.icon-btn:active {
    transform: scale(0.94);
}

.icon-btn svg {
    width: 14px;
    height: 14px;
}

:root .sun-icon { display: none; }
:root .moon-icon { display: block; }
:root[data-theme="dark"] .sun-icon { display: block; }
:root[data-theme="dark"] .moon-icon { display: none; }

/* Completion Badge */
.grid-complete #grid {
    animation: completePulse 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes completePulse {
    0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0.1); }
    50%  { box-shadow: 0 0 0 8px transparent; transform: scale(1.01); }
    100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
}

.grid-complete .complete-badge {
    display: flex;
}

.complete-badge {
    display: none;
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-text);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    animation: badgePop 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

@keyframes badgePop {
    from { opacity: 0; transform: scale(0.85) translateY(3px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Spinner */
.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Pause Overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(222, 222, 219, 0.88); /* tinted with --color-bg tone */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease-out;
}

[data-theme="dark"] .pause-overlay {
    background-color: rgba(12, 12, 12, 0.88);
}

.pause-overlay[hidden] {
    display: none !important;
}

.pause-content {
    text-align: center;
    padding: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--color-card); /* L2: card floating above overlay */
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    max-width: 380px;
    width: 90%;
}

.pause-title {
    font-family: 'Instrument Serif', serif;
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 6px;
    color: var(--color-text);
}

.pause-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Scroll Entry Animation ── */
.scroll-reveal {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive Stack ── */
@media (max-width: 960px) {
    html,
    body {
        height: auto;
        overflow: auto;
    }

    .app-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--color-border);
        position: static;
        overflow-y: visible;
        padding: 40px 24px;
    }
    
    .main-content {
        padding: 40px 24px;
        justify-content: flex-start;
        height: auto;
        overflow-y: visible;
    }
}

@media (max-width: 600px) {
    .main-content {
        padding: 28px 16px;
    }
    
    .studio-header {
        max-width: 382px;
    }
    
    .brand-title {
        font-size: 1.7rem;
    }
    
    #grid-wrapper {
        padding: 12px;
    }
    
    .box {
        grid-template-columns: repeat(3, 38px);
        grid-template-rows: repeat(3, 38px);
    }
    
    .cell-container {
        width: 38px;
        height: 38px;
    }
    
    .cell-input {
        font-size: 17px;
    }
    
    .notes-grid {
        padding: 1.5px;
    }
    
    .notes-grid span {
        font-size: 7.5px;
    }
    
    .tracker-digit-btn {
        height: 36px;
    }
    
    .tracker-digit-btn .digit-num {
        font-size: 0.9rem;
    }
    
    .tracker-digit-btn .digit-count {
        font-size: 0.52rem;
    }
}

@media (max-width: 410px) {
    .studio-header {
        max-width: 337px;
    }

    .box {
        grid-template-columns: repeat(3, 33px);
        grid-template-rows: repeat(3, 33px);
    }
    
    .cell-container {
        width: 33px;
        height: 33px;
    }
    
    .cell-input {
        font-size: 15px;
    }
    
    .notes-grid span {
        font-size: 6.5px;
    }
    
    .tracker-card {
        padding: 10px;
    }
    
    .tracker-digit-btn {
        height: 36px;
    }
    
    .tracker-digit-btn .digit-num {
        font-size: 0.85rem;
    }
    
    .tracker-digit-btn .digit-count {
        font-size: 0.5rem;
    }
}

@media (max-width: 350px) {
    .studio-header {
        max-width: 292px;
    }

    .box {
        grid-template-columns: repeat(3, 28px);
        grid-template-rows: repeat(3, 28px);
    }
    
    .cell-container {
        width: 28px;
        height: 28px;
    }
    
    .cell-input {
        font-size: 13px;
    }
    
    .notes-grid {
        padding: 1px;
    }
    
    .notes-grid span {
        font-size: 5.5px;
    }
}

/* ── Keyboard Shortcuts Modal ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(222, 222, 219, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

[data-theme="dark"] .modal-overlay {
    background-color: rgba(12, 12, 12, 0.8);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-content {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--color-card); /* L2: elevated card */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    width: 360px;
    padding: 24px;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.modal-header .card-label {
    margin-bottom: 0;
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
}

.modal-close-btn:hover {
    color: var(--color-text);
}

/* ── Rule Violation Message ── */
.rule-violation {
    background-color: #FDEBEC;
    color: #9F2F2D;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 500;
}

[data-theme="dark"] .rule-violation {
    background-color: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
}

/* ── Ambient Spotlight Glow ── */
.ambient-spotlight {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vh;
    background: radial-gradient(circle, rgba(15, 98, 254, 0.05) 0%, rgba(15, 98, 254, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="dark"] .ambient-spotlight {
    background: radial-gradient(circle, rgba(63, 140, 255, 0.04) 0%, rgba(63, 140, 255, 0) 70%);
}
