/* CSS Variables & Theming */
:root {
    --bg-color: #f8fafc;
    --container-bg: rgba(255, 255, 255, 0.9);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #ec4899;
    --border-color: #e2e8f0;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --transition: all 0.3s ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --container-bg: rgba(30, 41, 59, 0.85);
        --text-color: #f8fafc;
        --text-muted: #94a3b8;
        --primary-color: #60a5fa;
        --primary-hover: #93c5fd;
        --border-color: #334155;
        --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    }
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    transition: var(--transition);
    /* Dynamic background gradient */
    background-image:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(236, 72, 153, 0.15), transparent 40%);
    background-attachment: fixed;
}

.container {
    width: 100%;
    max-width: 900px;
    background: var(--container-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1 {
    text-align: center;
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 0.95rem;
}

/* Controls Area */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Mode Toggle */
.mode-selector {
    display: flex;
    background: rgba(100, 116, 139, 0.1);
    border-radius: 0.75rem;
    padding: 0.35rem;
    border: 1px solid var(--border-color);
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    transition: var(--transition);
    font-family: inherit;
    font-size: 0.9rem;
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

/* Action Buttons */
.actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn:hover {
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

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

/* Textarea */
textarea {
    width: 100%;
    height: 350px;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1.05rem;
    resize: vertical;
    transition: var(--transition);
    margin-bottom: 2rem;
    line-height: 1.7;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Results Grid */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-hover);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Reading Time */
.reading-time {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-color);
    color: var(--bg-color);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    transform: translateX(150%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.show {
    transform: translateX(0);
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .mode-selector {
        justify-content: center;
    }

    .actions {
        justify-content: center;
    }
}

/* English Mode Theme Overlay */
body[data-mode="en"] {
    --primary-color: #0ea5e9;    /* Sky blue */
    --primary-hover: #0284c7;
    --secondary-color: #10b981;  /* Emerald green */
    --accent-glow: rgba(14, 165, 233, 0.25);
}

@media (prefers-color-scheme: dark) {
    body[data-mode="en"] {
        --primary-color: #38bdf8;
        --primary-hover: #7dd3fc;
        --secondary-color: #34d399;
        --accent-glow: rgba(56, 189, 248, 0.35);
    }
}