:root {
    --sage-primary: var(--sage);
    --sage-dark: var(--sage-dark);
    --cream-bg: var(--paper-bg);
    --cream-card: var(--surface-color);
    --ink-text: var(--ink);
    --ink-muted: var(--ink-soft);
    --terracotta: var(--coral);
    --accent-gold: var(--honey);
    --border-color: var(--border);
    --radius-card: 16px;
    --radius-pill: 30px;
    --space-xs: 0.3rem;
    --space-sm: 0.5rem;
    --space-md: 0.8rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --font-main: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-serif); font-weight: 700; }
body { background: var(--paper-gradient, var(--cream-bg)); background-attachment: fixed; color: var(--ink-text); font-family: var(--font-main); min-height: 100vh; display: flex; flex-direction: column; }
.app-container, .tool-container { max-width: 960px; margin: 0 auto; padding: var(--space-xl) var(--space-lg); width: 100%; box-sizing: border-box; flex: 1; display: flex; flex-direction: column; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--space-xl); border-bottom: 2px solid var(--border-color); margin-bottom: var(--space-2xl); flex-wrap: wrap; gap: var(--space-lg); }
.logo-badge { display: flex; align-items: center; gap: var(--space-lg); }
.brand-icon { font-size: 2.2rem; background-color: var(--cream-card); padding: 0.6rem; border-radius: 12px; border: 1px solid var(--border-color); }
.brand-text h1 { font-size: 1.6rem; color: var(--sage-primary); font-weight: 700; }
.brand-text .tagline { font-size: 0.9rem; color: var(--ink-muted); }
.mode-toggle-btn { background-color: var(--cream-card); border: 2px solid var(--sage-primary); color: var(--sage-primary); padding: 0.6rem 1.2rem; border-radius: var(--radius-pill); font-weight: 700; cursor: pointer; transition: all var(--transition-speed, 0.3s) ease; }
.mode-toggle-btn:hover { background-color: var(--sage-primary); color: var(--warm-white); transform: translateY(-1px); }
.search-section { position: relative; margin-bottom: var(--space-2xl); }
.search-box { display: flex; align-items: center; background-color: rgba(255, 255, 255, 0.9); border: 2px solid var(--border-color); border-radius: var(--radius-pill); padding: 0.85rem 1.6rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.search-box:focus-within { border-color: var(--sage-primary); box-shadow: 0 0 0 4px rgba(65, 107, 73, 0.18), 0 10px 28px rgba(0, 0, 0, 0.08); transform: translateY(-2px); }
.search-box input { border: none; outline: none; width: 100%; font-size: 1.15rem; background: transparent; color: var(--ink-text); font-family: var(--font-main); }
.clear-btn { background: none; border: none; font-size: 1.4rem; color: var(--ink-muted); cursor: pointer; display: none; }
.suggestions-list, .suggestions-box { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); z-index: 100; display: none; overflow: hidden; animation: slideUpFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.suggestion-item { padding: 0.85rem 1.4rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; border-bottom: 1px solid rgba(0,0,0,0.03); transition: background-color 0.15s ease; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background-color: var(--sage-mist); }
.noun-result-card, .verb-result-card, .result-card, .game-card { background: rgba(255, 255, 255, 0.92); border: 1px solid var(--border-color); border-radius: var(--radius-card); padding: 2.25rem 2rem; margin-bottom: 2rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.05); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.noun-result-card:hover, .verb-result-card:hover, .result-card:hover, .game-card:hover { box-shadow: 0 16px 36px rgba(0, 0, 0, 0.1); transform: translateY(-4px); }

html[data-theme="dark"] .search-box, body.theme-dark .search-box {
    background-color: rgba(34, 43, 34, 0.9) !important;
    border-color: rgba(107, 143, 113, 0.3) !important;
}
html[data-theme="dark"] .suggestions-list, html[data-theme="dark"] .suggestions-box,
body.theme-dark .suggestions-list, body.theme-dark .suggestions-box {
    background: rgba(34, 43, 34, 0.95) !important;
    border-color: rgba(107, 143, 113, 0.3) !important;
}
html[data-theme="dark"] .suggestion-item:hover, body.theme-dark .suggestion-item:hover {
    background-color: rgba(107, 143, 113, 0.2) !important;
}
html[data-theme="dark"] .noun-result-card, html[data-theme="dark"] .verb-result-card, html[data-theme="dark"] .result-card, html[data-theme="dark"] .game-card,
body.theme-dark .noun-result-card, body.theme-dark .verb-result-card, body.theme-dark .result-card, body.theme-dark .game-card {
    background: rgba(34, 43, 34, 0.92) !important;
    border-color: rgba(107, 143, 113, 0.25) !important;
}
.badge { background-color: var(--cream-card); padding: 0.35rem 0.8rem; border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 600; border: 1px solid var(--border-color); }
.aux-badge { background-color: var(--sage-light); color: var(--sage-primary); }
.lexical-box { background-color: var(--cream-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: var(--space-lg); margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lexical-label { font-weight: 700; color: var(--sage-primary); }
.usage-block { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; background-color: var(--sage-mist); padding: 0.4rem 0.8rem; border-radius: 8px; border-left: 3px solid var(--sage-primary); }
.usage-text { font-weight: 600; color: var(--sage-primary); }
.grammar-rule-block { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; background-color: var(--honey-pale); padding: 0.45rem 0.85rem; border-radius: 8px; border-left: 3px solid var(--terracotta); }
.rule-text { font-weight: 600; color: var(--ink-text); }
.pills-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.antonym-pill { background-color: var(--surface-color); border: 1px solid var(--accent-gold); padding: 0.2rem 0.7rem; border-radius: var(--radius-pill); font-size: 0.85rem; cursor: pointer; }
.stem { color: var(--sage-dark); font-weight: 700; }
.ending { color: var(--terracotta); font-weight: 800; }
.empty-state-box { background: var(--surface-color); border: 2px dashed var(--border); border-radius: var(--radius-card); padding: 3rem 2rem; text-align: center; box-shadow: var(--shadow-sm); transition: all 0.3s ease; }
.empty-state-box h3 { font-family: var(--font-serif); font-size: 1.5rem; color: var(--sage-primary); margin-bottom: 0.5rem; }
.empty-state-box p { color: var(--ink-muted); line-height: 1.6; max-width: 580px; margin: 0 auto 1.5rem; }
.quick-tags { display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.tag-btn { background-color: var(--cream-card); border: 1px solid var(--border-color); padding: 0.3rem 0.8rem; border-radius: var(--radius-pill); cursor: pointer; color: var(--sage-primary); font-weight: 600; transition: all var(--transition-speed, 0.3s) ease; }
.tag-btn:hover { background-color: var(--sage-primary); color: var(--warm-white); transform: translateY(-1px); }
.app-footer { text-align: center; padding: 1.5rem 0; border-top: 1px solid var(--border-color); color: var(--ink-muted); font-size: 0.85rem; margin-top: auto; }
.game-prompt-box { text-align: center; background-color: var(--cream-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.game-input-group { display: flex; gap: 0.8rem; margin-bottom: 1rem; }
.game-input-group input { flex: 1; padding: 0.8rem 1.2rem; border: 2px solid var(--border-color); border-radius: var(--radius-pill); font-size: 1.1rem; outline: none; background: var(--surface-color); color: var(--ink-text); }
.game-btn { background-color: var(--sage-primary); color: var(--warm-white); border: none; padding: 0.8rem 1.8rem; border-radius: var(--radius-pill); font-size: 1rem; font-weight: 700; cursor: pointer; transition: all var(--transition-speed, 0.3s) ease; }
.game-btn:hover { background-color: var(--sage-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.feedback-card { padding: 1rem; border-radius: 12px; text-align: center; font-weight: 600; margin-bottom: 1rem; }
.feedback-card.correct { background-color: var(--green-light); color: var(--sage-dark); }
.feedback-card.wrong { background-color: var(--rose-light); color: var(--rose); }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.5rem;
    border-radius: 12px;
    width: 100%;
}

@media (max-width: 768px) {
    .app-container { padding: 1rem 0.8rem; }
    .app-header { flex-direction: column; align-items: stretch; text-align: center; gap: 0.8rem; margin-bottom: 1.2rem; padding-bottom: 1rem; }
    .logo-badge { justify-content: center; }
    .header-actions { justify-content: center; width: 100%; gap: 0.5rem; }
    .mode-toggle-btn, .install-pwa-btn, .tag-btn, .choice-btn, .game-btn, .tts-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .mode-toggle-btn { width: 100%; }
    .verb-result-card, .game-card, .noun-result-card, .empty-state-box { padding: 1.25rem 1rem; }
    .verb-title-group, .noun-title-group { justify-content: center; text-align: center; }
    .game-input-group, .game-choice-group { flex-direction: column; }
    .game-input-group input { width: 100%; min-height: 44px; }
    .game-btn, .choice-btn { width: 100%; }
    .tense-cards, .plural-grid { grid-template-columns: 1fr; }
}

.mc-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.mc-option-btn { background: var(--cream-card, var(--surface-color)); border: 2px solid var(--sage-light, var(--border)); border-radius: 8px; padding: 0.75rem 0.875rem; font-size: 0.95rem; font-weight: 500; color: var(--ink-main, var(--ink)); cursor: pointer; transition: all 0.2s ease; text-align: left; }
.mc-option-btn:hover { border-color: var(--terracotta, var(--coral)); background: var(--surface-color); transform: translateY(-2px); }
.active-mode { background: var(--terracotta, var(--coral)) !important; color: var(--warm-white) !important; cursor: pointer; }
