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

:root {
    --site-bg: #f3f5f8;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #dbe3ea;
    --border-soft: #e5e7eb;
    --primary: #0b4b36;
    --primary-hover: #14503c;
    --primary-soft: #e5f3ef;
    --accent: #f4a300;
    --accent-hover: #db9200;
    --neutral-btn: #e5e7eb;
    --neutral-btn-hover: #d1d5db;
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10);
    --radius-sm: 8px;
    --radius-md: 12px;
    --content-width: 1180px;
    --transition: 0.2s ease;
    --footer-height: 48px;
    --mobile-header-height: 220px;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    background: var(--site-bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--footer-height);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition), background-color var(--transition), border-color var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 10px 12px 12px;
}

.site-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.site-title a {
    color: #ffffff;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 10px;
}

.search-row input[type="text"] {
    min-width: 0;
    width: 100%;
    height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-row input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(244, 163, 0, 0.18);
}

.search-row button,
.reset-btn,
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.search-row button {
    background: var(--accent);
    color: #111827;
}

.search-row button:hover {
    background: var(--accent-hover);
    color: #111827;
}

.reset-btn,
.back-link {
    background: var(--neutral-btn);
    color: #111827;
}

.reset-btn:hover,
.back-link:hover {
    background: var(--neutral-btn-hover);
    color: #111827;
}

.az-toggle {
    display: block;
    margin-bottom: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.az-grid {
    display: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
    padding-right: 0;
}

.az-grid.open {
    display: grid;
}

.az-grid a {
    display: block;
    padding: 10px 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
}

.az-grid a:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.az-grid a.active {
    background: var(--accent);
    color: #111827;
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.header-meta h1 {
    margin: 0;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.25;
}

.header-meta .count {
    color: #d1fae5;
    font-size: 12px;
    line-height: 1.35;
}

.page-shell {
    max-width: var(--content-width);
    width: 100%;
    margin: 0 auto;
    padding: 12px 12px 18px;
    flex: 1 0 auto;
    min-height: calc(100vh - 220px - var(--footer-height));
}

.results-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 100%;
}

.results-scroll,
.word-panel {
    overflow: visible;
    padding-right: 0;
}

.word-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-content: start;
}

.word-card,
.card,
.empty,
.not-found {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.word-card {
    padding: 14px;
    min-height: 96px;
}

.card,
.empty,
.not-found {
    padding: 16px;
}

.word-card h2,
.word-head h2,
.section h3,
.site-title,
.header-meta h1 {
    word-break: break-word;
}

.word-card h2 {
    margin: 0 0 8px;
    font-size: 17px;
    line-height: 1.3;
}

.word-card h2 a {
    color: var(--primary);
}

.word-card h2 a:hover {
    color: var(--primary-hover);
}

.meta {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
}

.word-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.word-head h2 {
    margin: 0;
    color: var(--primary);
    font-size: 24px;
    line-height: 1.2;
}

.part-of-speech {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
}

.section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.section h3 {
    margin: 0 0 8px;
    color: #111827;
    font-size: 16px;
    line-height: 1.3;
}

.section p {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.pagination {
    display: none;
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--footer-height);
    margin: 0;
    padding: 0;
    background: var(--primary);
    color: #d1fae5;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.12);
}

.site-footer-text {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 12px;
    line-height: 1.3;
    color: #d1fae5;
    background: transparent;
}

.site-footer-text strong {
    color: #ffffff;
}

.site-header.compact .header-inner,
.site-header.compact .site-title,
.site-header.compact .search-row,
.site-header.compact .search-row input[type="text"],
.site-header.compact .search-row button,
.site-header.compact .reset-btn,
.site-header.compact .az-toggle,
.site-header.compact .header-meta,
.site-header.compact .header-meta h1,
.site-header.compact .header-meta .count {
}

.site-header.compact {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
    }

    .site-header {
        position: fixed !important;
        top: 0 !important;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 10000;
        transform: none !important;
        -webkit-transform: none !important;
    }

    .page-shell {
        margin-top: var(--mobile-header-height);
    }

    .site-footer-text {
        padding: 0 10px;
        font-size: 11px;
    }
}

@media (max-width: 380px) {
    .header-inner {
        padding-left: 10px;
        padding-right: 10px;
    }

    .search-row {
        grid-template-columns: 1fr 1fr;
    }

    .search-row input[type="text"] {
        grid-column: 1 / -1;
    }

    .search-row button,
    .reset-btn {
        width: 100%;
    }

    .az-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .page-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .word-card {
        padding: 13px;
    }

    .word-card h2 {
        font-size: 16px;
    }
}

@media (min-width: 769px) {
    .header-inner {
        padding: 14px 16px 12px;
    }

    .site-title {
        font-size: 20px;
    }

    .search-row {
        display: flex;
        flex-wrap: nowrap;
    }

    .search-row input[type="text"] {
        flex: 1 1 auto;
        height: 46px;
    }

    .search-row button,
    .reset-btn,
    .back-link {
        flex: 0 0 auto;
        min-width: 86px;
        height: 46px;
    }

    .az-toggle {
        display: none;
    }

    .az-grid {
        display: grid;
        grid-template-columns: repeat(13, minmax(0, 1fr));
        gap: 8px;
    }

    .az-grid a {
        font-size: 14px;
    }

    .header-meta h1 {
        font-size: 28px;
    }

    .header-meta .count {
        font-size: 14px;
    }

    .page-shell {
        margin-top: 0;
        padding: 14px 16px 22px;
        min-height: calc(100vh - 220px - var(--footer-height));
    }

    .word-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }

    .word-card {
        padding: 18px;
        min-height: 110px;
    }

    .word-card h2 {
        font-size: 20px;
    }

    .word-head h2 {
        font-size: 32px;
    }

    .part-of-speech {
        font-size: 14px;
    }

    .section h3 {
        font-size: 18px;
    }

    .site-footer-text {
        font-size: 13px;
        padding: 0 16px;
    }
}

@media (min-width: 1024px) {
    .word-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}