:root {
    color-scheme: light;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: #29263a;
    background: #f3f1f6;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    --ink: #29263a;
    --muted: #656276;
    --purple: #352b69;
    --purple-dark: #28214f;
    --purple-soft: #eeebf5;
    --border: #e3dfeb;
    --gold: #c49a58;
}

* { box-sizing: border-box; }

body {
    min-width: 320px;
    margin: 0;
    color: var(--ink);
    background: #f3f1f6;
    font-size: 16px;
    line-height: 1.6;
}

body[data-language="kankanaey"] {
    --purple: #096b91;
    --purple-dark: #064b70;
    --purple-soft: #e8f4fa;
    --border: #d7e7ef;
    --gold: #168bac;
}

body[data-language="kankanaey"] .site-header {
    background: linear-gradient(115deg, #075777, #1689a8);
}

body[data-language="kankanaey"] .brand {
    background: #e9f5fb;
}

body[data-language="kankanaey"] .site-nav {
    background: #064b70;
}

body[data-language="kankanaey"] button,
body[data-language="kankanaey"] .post-action {
    background: #096b91;
}

body[data-language="kankanaey"] button:hover,
body[data-language="kankanaey"] button:focus-visible,
body[data-language="kankanaey"] .post-action:hover,
body[data-language="kankanaey"] .post-action:focus-visible {
    background: #064b70;
}

a { color: #493c84; }
a:hover { color: #30265f; }

:focus-visible {
    outline: 3px solid #c9b36f;
    outline-offset: 3px;
}

.site-shell {
    max-width: 1160px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.15rem 1.5rem;
    color: #fff;
    background: linear-gradient(115deg, #30265f, #493c7b);
    border-radius: 16px 16px 0 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    padding: .45rem;
    background: #eee5fa;
    border: 1px solid #ffffff70;
    border-radius: 11px;
    box-shadow: 0 4px 14px #17132d30;
}

.brand img {
    display: block;
    width: 264px;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.header-note {
    max-width: 390px;
    margin: 0;
    color: #e5e0f0;
    line-height: 1.55;
    text-align: right;
}

.header-note strong {
    display: block;
    margin-bottom: .15rem;
    color: #fff;
    font-size: 1.05rem;
}

.site-header > strong {
    color: #f4f0fb;
    line-height: 1.5;
    text-align: right;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    padding: .55rem 1rem;
    background: var(--purple-dark);
    border-top: 1px solid #ffffff20;
}

.site-nav > a,
.account-links > a {
    padding: .65rem .95rem;
    color: #f7f5fb;
    font-size: .92rem;
    font-weight: 650;
    text-decoration: none;
    border-radius: 7px;
    transition: background-color .18s ease, color .18s ease;
}

.site-nav > a:hover,
.site-nav > a:focus-visible,
.site-nav > a[aria-current="page"],
.account-links > a:hover,
.account-links > a:focus-visible {
    color: #fff;
    background: #ffffff20;
}

.account-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-left: auto;
}

.account-links > span {
    padding: .5rem .65rem;
    color: #e5e0f0;
    font-size: .88rem;
}

.account-menu { position: relative; }
.account-menu summary {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .95rem;
    color: #f7f5fb;
    font-size: .92rem;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
    border-radius: 7px;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after {
    width: 0;
    height: 0;
    border: .3rem solid transparent;
    border-top-color: currentColor;
    content: "";
    transform: translateY(.15rem);
}
.account-menu[open] summary,
.account-menu summary:hover { background: #ffffff20; }
.account-menu-items {
    position: absolute;
    z-index: 5;
    top: calc(100% + .25rem);
    right: 0;
    display: grid;
    min-width: 190px;
    padding: .4rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 9px;
    box-shadow: 0 8px 24px #17132d30;
}
.account-menu-items a {
    padding: .55rem .65rem;
    color: var(--ink);
    font-size: .92rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
}
.account-menu-items a:hover,
.account-menu-items a:focus-visible { color: var(--purple); background: var(--purple-soft); }
.account-links form { margin: 0; }
.account-menu-items button {
    width: 100%;
    padding: .55rem .65rem;
    color: var(--ink);
    background: transparent;
    font-size: .92rem;
    font-weight: 500;
    text-align: left;
}
.account-menu-items button:hover,
.account-menu-items button:focus-visible { color: var(--purple); background: var(--purple-soft); }

.page-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
    gap: 1.15rem;
    padding: 1.25rem;
    background: #f6f4f8;
    border: 1px solid var(--border);
    border-top: 0;
}

.page-layout--single { display: block; }
.page-layout--single > .panel { max-width: 900px; margin: 0 auto; }

.panel,
.side-card,
body > main {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px #2920440a;
}

.panel { padding: clamp(1.25rem, 3vw, 2rem); }
.account-panel { width: min(100%, 700px); margin: 0 auto; }

.panel h1,
.panel h2,
.side-card h2,
.side-card h3,
body > main h1,
body > main h2 {
    color: var(--purple);
    line-height: 1.25;
}

.panel h1 { margin-top: 0; font-size: clamp(1.65rem, 3vw, 2rem); }
.panel h2 { font-size: 1.3rem; }
.panel-intro,
.intro,
.hint,
.meta,
.chat-hint,
#chatbox-status,
#chatbox-load-status {
    color: var(--muted);
}

.panel-intro,
.intro { line-height: 1.7; }
.intro { padding: 1rem 1.15rem; background: #f5f2f8; border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; }
.hint { margin: .45rem 0; font-size: .92rem; line-height: 1.55; }

label {
    display: block;
    margin: 1rem 0 .4rem;
    color: #353148;
    font-size: .94rem;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    padding: .75rem .85rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid #c9c4d4;
    border-radius: 8px;
    font: inherit;
}

textarea { min-height: 8rem; resize: vertical; }
textarea#content { min-height: 18rem; }

input:focus,
select:focus,
textarea:focus {
    border-color: #7669a5;
    outline: 3px solid #ded8ee;
    outline-offset: 1px;
}

button,
.post-action {
    display: inline-block;
    padding: .72rem 1.1rem;
    color: #fff;
    background: #493c7b;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, transform .18s ease;
}

button:hover,
button:focus-visible,
.post-action:hover,
.post-action:focus-visible {
    color: #fff;
    background: #30265f;
}

button:active,
.post-action:active { transform: translateY(1px); }
.actions { margin-top: 1rem; }
.actions button { min-width: 120px; }

.notice {
    margin: 1rem 0;
    padding: .85rem 1rem;
    background: #edf6ef;
    border: 1px solid #d5e9d8;
    border-radius: 8px;
}

.error { background: #fff1ef; border-color: #f1d5d0; }
.sidebar { display: grid; gap: 1rem; }
.side-card { padding: 1.2rem; }
.side-card h2,
.side-card h3 { margin: 0 0 .65rem; font-size: 1.12rem; }
.side-card p { margin: 0; color: #5c596a; font-size: .94rem; line-height: 1.7; }

.kankanaey-profile {
    padding: 1.4rem;
    color: #fff;
    background: linear-gradient(145deg, #075777, #1689a8);
    border-color: #0c7597;
}

.kankanaey-profile h2 {
    margin: .45rem 0 .65rem;
    color: #fff;
    font-size: 1.4rem;
}

.kankanaey-profile p { color: #edf9fd; }
.kankanaey-profile .kankanaey-eyebrow { color: #c8eff6; font-size: .7rem; font-weight: 750; letter-spacing: .09em; }
.kankanaey-help { background: #f0f8fb; }
.sidebar-action {
    display: inline-block;
    margin-top: 1rem;
    padding: .55rem .8rem;
    color: #fff;
    background: #096b91;
    border-radius: 7px;
    font-size: .9rem;
    font-weight: 650;
    text-decoration: none;
}
.sidebar-action:hover,
.sidebar-action:focus-visible { color: #fff; background: #064b70; }

.dictionary-visual { padding: .75rem; }
.sidebar-image {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #d8d1e4;
    border-radius: 9px;
}

.visual-caption {
    margin: .85rem .3rem .25rem;
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.55;
}

.dictionary-stats { margin: 0; }
.dictionary-stats div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem 0;
    border-bottom: 1px solid #efedf3;
}
.dictionary-stats div:last-child { padding-bottom: 0; border-bottom: 0; }
.dictionary-stats dt { color: var(--muted); }
.dictionary-stats dd { margin: 0; color: var(--purple); font-weight: 700; }

#chatbox,
#contribution,
.section {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

#chat-messages {
    display: grid;
    gap: .45rem;
    max-height: 420px;
    overflow-y: auto;
    padding: .75rem;
    background: #f8f7fa;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.chat-message { margin: 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
#chatbox-form { margin-top: 1rem; }
#chatbox-form textarea { min-height: 5rem; }
.chat-hint { font-size: .9rem; }

#suggestions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
#suggestions button {
    padding: .45rem .7rem;
    color: #342d58;
    background: #eeeaf6;
    font-size: .9rem;
}
#suggestions button:hover { color: #fff; background: #493c7b; }
#results { padding-left: 1.4rem; line-height: 1.8; overflow-wrap: anywhere; }
#result-heading:empty { display: none; }
#not-found { color: var(--muted); }

#phrase-suggestions { display: grid; gap: .5rem; margin-top: .5rem; }
#phrase-suggestions a,
.question-link {
    display: block;
    padding: .8rem .9rem;
    background: #f8f7fa;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    overflow-wrap: anywhere;
}
#phrase-suggestions a:hover,
#phrase-suggestions a:focus-visible,
.question-link:hover,
.question-link:focus-visible { background: var(--purple-soft); }
#phrase-suggestions .empty { margin: 0; padding: .5rem; }
#suggestion-heading { margin-bottom: 0; font-weight: 650; }
.question-list { display: grid; gap: .65rem; margin-top: 1.2rem; }
.question-text { display: block; color: #302d40; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { margin: .35rem 0 0; font-size: .84rem; }
.thread-post { margin: 1rem 0; padding: 1rem 1.1rem; background: #f8f7fa; border: 1px solid #efedf3; border-radius: 9px; }
.thread-post p { margin-bottom: 0; }
.thread-post .meta { margin-top: .75rem; }
.empty { color: var(--muted); }

.post { padding: 1.4rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.post:last-child { border-bottom: 0; }
.post h2 { margin: .25rem 0; color: var(--purple); }
.post-meta { color: var(--muted); font-size: .85rem; }
.post-content { line-height: 1.75; white-space: normal; }
.post iframe { display: block; width: 100%; max-width: 640px; aspect-ratio: 16 / 9; margin: 1rem auto; border: 0; border-radius: 9px; }
.post-action { display: block; margin: .55rem 0; }

.news-list { display: grid; gap: 1rem; }
.news-card {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 1.1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.news-card-image img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 9px;
}
.news-card h2 { margin: .2rem 0 .45rem; font-size: 1.25rem; }
.news-card h2 a { color: var(--purple); text-decoration: none; }
.news-card h2 a:hover { text-decoration: underline; }
.news-meta { margin: 0 0 .45rem; color: var(--muted); font-size: .88rem; }
.news-admin-item {
    display: grid;
    gap: .75rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.news-admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}
.news-admin-actions form { margin: 0; }
.news-admin-actions .post-action,
.news-admin-actions button { margin: 0; }
.news-delete-button { background: #8d3e42; }
.news-delete-button:hover,
.news-delete-button:focus-visible { background: #6f2e32; }
.news-article-image {
    display: block;
    width: min(100%, 900px);
    max-height: 560px;
    margin: 1rem auto;
    object-fit: cover;
    border-radius: 10px;
}
.news-content { font-size: 1.08rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.news-authoring { margin-top: 1rem; }
.news-authoring textarea { min-height: 16rem; }
.site-footer {
    padding: 1.15rem;
    color: #6a6677;
    background: #f6f4f8;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    font-size: .86rem;
    text-align: center;
}

.adsense-unit {
    display: block;
    min-height: 90px;
    margin: 1.25rem auto;
    text-align: center;
}
.adsense-unit--inline { margin-top: 2rem; }
.adsense-unit--sidebar { min-height: 250px; padding: .5rem; }
.adsense-unit--banner { min-height: 90px; }

body.admin-page {
    padding: 2rem 1rem;
}

body > main {
    max-width: 1000px;
    margin: 0 auto;
    padding: clamp(1.25rem, 3vw, 2rem);
}

body > main > header {
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

body > main article {
    padding: 1.2rem 0;
    border-top: 1px solid var(--border);
}

body > main article:first-of-type { margin-top: 1rem; }
body > main .status { display: inline-block; padding: .2rem .6rem; background: #edf6ef; border-radius: 999px; font-weight: 650; }
body > main .status-hidden { background: #fff0ed; }
body > main .content { max-height: 24rem; overflow: auto; margin-bottom: 1rem; padding: .9rem; background: #f8f7fa; border: 1px solid var(--border); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
body > main button.disapprove { background: #8d3e42; }

@media (max-width: 760px) {
    .site-shell { margin: 1rem auto; }
    .site-header { align-items: flex-start; flex-direction: column; gap: .9rem; padding: 1rem; }
    .header-note,
    .site-header > strong { text-align: left; }
    .page-layout { grid-template-columns: 1fr; }
    .sidebar { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
    .sidebar-image { max-width: 300px; margin: 0 auto; }
    .news-card { grid-template-columns: 1fr; }
    .news-card-image img { max-height: 260px; }
    .site-footer { border-radius: 0 0 14px 14px; }
}

@media (max-width: 480px) {
    .site-shell { padding: 0 .55rem; }
    .site-header { border-radius: 12px 12px 0 0; }
    .brand { max-width: 100%; }
    .site-nav { gap: .15rem; padding: .4rem; }
    .site-nav a { padding: .6rem .7rem; font-size: .84rem; }
    .page-layout { gap: .8rem; padding: .7rem; }
    .panel { padding: 1.1rem; }
    body.admin-page { padding: 1rem .65rem; }
    body > main { padding: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
