/* ===== RESET & BASE (Mobile-First) ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #252536;
    --bg-hover: #2e2e42;
    --border-color: #2a2a3c;
    --text-primary: #e8e8f0;
    --text-secondary: #9494b0;
    --text-muted: #60607a;
    --accent: #7c5ce7;
    --accent-light: #9b7ef0;
    --accent-glow: rgba(124, 92, 231, 0.3);
    --success: #34d399;
    --danger: #f87171;
    --danger-glow: rgba(248, 113, 113, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --section-gap: 20px;
    --touch-min-height: 44px;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
    padding-top: 8px;
    padding-bottom: 40px;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    padding-bottom: 0;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== TEXTAREA ===== */
.textarea-wrapper {
    position: relative;
}

#textInput {
    width: 100%;
    min-height: 200px;
    padding: 14px 14px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#textInput::placeholder {
    color: var(--text-muted);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.88rem;
}

#textInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ===== BUTTON GRID (Mobile-first: 2 columns) ===== */
.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.case-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--touch-min-height);
    padding: 10px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    font-family: inherit;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.case-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.case-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.case-btn .btn-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-align: center;
    line-height: 1.25;
}

.case-btn .btn-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

/* ===== STATS BAR (Mobile-first: stacked layout) ===== */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-top: 12px;
}

.stats-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 55px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-light);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
}

.stat-divider.mobile-hidden {
    display: none;
}

.stat-action-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
    flex-basis: 100%;
}

/* ===== ACTION BUTTONS ===== */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--touch-min-height);
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    font-family: inherit;
    white-space: nowrap;
    flex: 1;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

.copy-btn:hover {
    background: #1e3a3a;
    border-color: var(--success);
    box-shadow: 0 4px 16px rgba(52, 211, 153, 0.2);
}

.clear-btn:hover {
    background: #3a1e1e;
    border-color: var(--danger);
    box-shadow: 0 4px 16px var(--danger-glow);
}

.action-btn svg {
    flex-shrink: 0;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
    z-index: 1000;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

.toast.error {
    border-color: var(--danger);
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding-top: 4px;
}

footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ========================================================= */
/*  RESPONSIVE: Tablety a malé desktopy (>= 600px)            */
/* ========================================================= */
@media (min-width: 600px) {
    body {
        padding: 20px;
    }

    .container {
        gap: 24px;
        padding-top: 10px;
        padding-bottom: 20px;
    }

    header h1 {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 0.92rem;
    }

    #textInput {
        min-height: 240px;
        padding: 16px 18px;
        font-size: 0.92rem;
    }

    #textInput::placeholder {
        font-size: 0.92rem;
    }

    .button-grid {
        grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
        gap: 10px;
    }

    .case-btn {
        min-height: 50px;
        padding: 12px 10px;
    }

    .case-btn .btn-label {
        font-size: 0.87rem;
    }

    .case-btn .btn-desc {
        font-size: 0.7rem;
    }

    .stats-bar {
        gap: 16px;
        padding: 18px 18px;
        margin-top: 14px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .stat-divider.mobile-hidden {
        display: block;
    }

    .stat-action-buttons {
        flex-basis: auto;
        width: auto;
        margin-left: auto;
        flex: 0 0 auto;
    }

    .action-btn {
        flex: 0 1 auto;
        min-width: 120px;
    }
}

/* ========================================================= */
/*  RESPONSIVE: Velké obrazovky (>= 768px)                    */
/* ========================================================= */
@media (min-width: 768px) {
    body {
        padding: 28px;
    }

    header h1 {
        font-size: 2.4rem;
    }

    #textInput {
        min-height: 260px;
        padding: 18px 20px;
        font-size: 0.95rem;
    }

    #textInput::placeholder {
        font-size: 0.95rem;
    }

    .button-grid {
        grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
        gap: 10px;
    }

    .case-btn {
        min-height: 56px;
        padding: 14px 12px;
    }

    .case-btn .btn-label {
        font-size: 0.9rem;
    }

    .case-btn .btn-desc {
        font-size: 0.72rem;
    }

    .stats-bar {
        padding: 16px 20px;
        margin-top: 16px;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .action-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }
}