/* Aritmapedia 4: shared surfaces for public pages, forms and dialogs. */
:root {
  --header-height: 80px;
  --wide-content: 100%;
  --page-gutter: clamp(16px, 4vw, 2cm);
  --radius: 8px;
  --radius-sm: 5px;
  --bg-body: #101415;
  --bg-body-soft: #171d1e;
  --bg-card: #191f20;
  --bg-card-strong: #1d2526;
  --bg-elevated: #283334;
  --input-bg: #141a1b;
  --text-main: #d3dede;
  --text-heading: #f3f7f7;
  --text-muted: #a7b8b9;
  --text-faint: #91a4a5;
  --border-color: #303c3d;
  --border-strong: #516667;
  --primary-color: #6bdecc;
  --primary-hover: #a0f0e2;
  --primary-text: #092823;
  --secondary-color: #9ccee5;
  --warning-color: #edc27a;
  --danger-color: #ffaaaa;
  --success-color: #6bdecc;
  --accent-soft: rgba(107, 222, 204, .09);
  --header-surface: rgba(16, 20, 21, .96);
  --shadow-soft: 0 3px 12px rgba(0, 0, 0, .12);
  --shadow-card: 0 20px 64px rgba(0, 0, 0, .30);
  --ring: 0 0 0 3px rgba(107, 222, 204, .25);
  --water-opacity: .16;
}
html[data-theme="light"] {
  --bg-body: #f8fafb;
  --bg-body-soft: #edf2f3;
  --bg-card: #ffffff;
  --bg-card-strong: #f4f7f8;
  --bg-elevated: #e6eef0;
  --input-bg: #ffffff;
  --text-main: #33464b;
  --text-heading: #152e34;
  --text-muted: #546c72;
  --text-faint: #5b7379;
  --border-color: #d6e1e4;
  --border-strong: #a6bec4;
  --primary-color: #096d63;
  --primary-hover: #07564e;
  --primary-text: #ffffff;
  --secondary-color: #286981;
  --warning-color: #845411;
  --danger-color: #b13240;
  --success-color: #096d63;
  --accent-soft: rgba(9, 109, 99, .06);
  --header-surface: rgba(248, 250, 251, .96);
  --shadow-soft: 0 3px 14px rgba(21, 46, 52, .04);
  --shadow-card: 0 20px 64px rgba(21, 46, 52, .12);
  --ring: 0 0 0 3px rgba(9, 109, 99, .18);
  --water-opacity: .42;
}
html { scroll-padding-top: calc(var(--header-height) + 24px); }
body, html[data-theme="light"] body { background: var(--bg-body); letter-spacing: 0; }
body::before, body::after { display: none; }
body { line-height: 1.7; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: var(--text-heading); overflow-wrap: anywhere; letter-spacing: 0; }
::selection { background: var(--primary-color); color: var(--primary-text); }
input, select, textarea { accent-color: var(--primary-color); }
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 3px; box-shadow: none; }
[hidden] { display: none !important; }
.site-header, html[data-theme="light"] .site-header { background: var(--header-surface); backdrop-filter: blur(16px); }
.header-inner { grid-template-columns: minmax(200px, 1fr) minmax(240px, 640px) minmax(170px, 1fr); gap: 24px; }
.header-left, .header-right, .header-search-wrapper { grid-row: 1; }
.site-wordmark { font-family: Georgia, "Times New Roman", serif; font-size: 23px; font-weight: 500; }
.home-icon-link { border-color: transparent; background: var(--accent-soft); color: var(--primary-color); flex-shrink: 0; }
.theme-toggle-btn { flex-shrink: 0; }
.toggle-icon { display: flex; }
.user-nav-link { font-size: 14px; font-weight: 650; }
.header-search-box input { background: var(--bg-body-soft); min-height: 44px; height: 44px; font-size: 14px; }
.header-search-submit { border: 0; }
.site-main { z-index: auto; }
/* Keep WordPress overlays above the fixed site header. */
body > [id^="__wp-uploader-id-"] { z-index: auto; }
@media screen {
  body.admin-bar #wpadminbar { position: fixed; }
  html:has(body.admin-bar) { scroll-padding-top: calc(var(--header-height) + 56px); }
}
@media screen and (max-width: 782px) {
  html:has(body.admin-bar) { scroll-padding-top: calc(var(--header-height) + 70px); }
}
.site-footer-grok, html[data-theme="light"] .site-footer-grok { background: var(--bg-body); }
.footer-content { font-size: 13px; min-height: 100px; }
.footer-stat { border: 0; background: transparent; padding: 0; }
.stat-number { font-variant-numeric: tabular-nums; color: var(--primary-color); }
.site-title-large, .entry-title, .archive-title { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.entry-title { font-size: 44px; line-height: 1.18; }
.section-title { font-size: 24px; font-weight: 650; }
.neon-btn, .action-pill, .correction-btn, .auth-text-btn, .back-link, .search-more-link,
.btn-primary, .btn-warn, .btn-danger, .btn-soft, .btn-ghost, .btn-solid-primary,
.btn-outline-danger, .btn-outline-warn, .sa-btn-confirm, .sa-btn-cancel, .sa-correction-cancel {
  min-height: 44px; font-size: 14px; font-weight: 650; line-height: 1.4;
  white-space: normal; overflow-wrap: anywhere; transition: background-color .18s, border-color .18s, box-shadow .18s;
}
.action-pill:hover, .correction-btn:hover, .auth-text-btn:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.back-link { background: transparent; border-color: transparent; padding-left: 0; }
.auth-card { box-shadow: var(--shadow-card); padding: 32px; }
.auth-tabs { gap: 0; border-bottom: 1px solid var(--border-color); }
.auth-tab { flex: 1; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; font-weight: 650; }
.auth-tab.active { border-bottom-color: var(--primary-color); background: transparent; }
label { font-size: 14px; font-weight: 650; }
.form-row, .technical-fields-grid, .term-quality-list { min-width: 0; }
.technical-fields, .term-quality-box { border: 0; border-top: 1px solid var(--border-color); border-radius: 0; background: transparent; padding: 24px 0; }
.term-quality-list li { border: 0; border-radius: 0; background: transparent; }
.profile-section-card, .approval-header-card, .terim-form-card { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.profile-section-card { border-top: 1px solid var(--border-color); }
.result-item, .az-item { background: transparent; border-width: 0 0 1px; border-radius: 0; padding: 20px 4px; }
.result-item:hover, .az-item:hover { background: var(--accent-soft); }
.item-title, .tc-title { font-weight: 650; }
.search-result-title { font-weight: 650; }
.search-result-header, .search-result-footer { flex-wrap: wrap; }
.search-result-badge, .term-badge, .tc-badge, .correction-status { font-weight: 600; white-space: normal; }
.term-badge { line-height: 1.45; }
.az-nav-wrapper { background: var(--header-surface); }
.terms-grid, .profile-terms-grid, .archive-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.term-card-mini { background: var(--bg-card); box-shadow: none; }
.pagination-wrapper ul.page-numbers, .pagination-wrapper .nav-links,
html[data-theme="light"] .pagination-wrapper ul.page-numbers,
html[data-theme="light"] .pagination-wrapper .nav-links { background: var(--bg-body-soft); }

/* Search remains the primary action; water is a local, decorative photograph. */
body.home .site-main { display: block; min-height: 0; padding: var(--header-height) 0 0; }
.ap-home-shell.ap-home-minimal { position: relative; width: 100%; min-height: 510px; padding: 82px var(--page-gutter) 66px; isolation: isolate; }
.ap-home-minimal::before { content: ""; position: absolute; inset: 0; z-index: -1; background: url('../images/water-surface.webp') center / cover; opacity: var(--water-opacity); pointer-events: none; }
.ap-home-hero { width: min(860px, 100%); max-width: 860px; }
.ap-home-kicker, .ap-eyebrow { font-size: 11px; font-weight: 700; color: var(--primary-color); }
.ap-home-minimal .ap-home-title { font-size: 76px; line-height: 1.12; margin: 14px 0 18px; font-weight: 500; }
.ap-home-minimal .ap-home-description { font-size: 18px; color: var(--text-main); }
.ap-home-search-wrap { max-width: 740px; margin-top: 32px; }
.search-input.ap-home-search-input, html[data-theme="light"] .search-input.ap-home-search-input {
  min-height: 68px; border-color: var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-card);
  font-size: 17px; padding: 0 76px 0 52px; border-radius: 8px;
}
.search-submit-btn { width: 46px; height: 46px; right: 11px; border-radius: 5px; }
.ap-topic-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin-top: 23px; }
.ap-topic-links a { color: var(--text-main); font-size: 13px; text-underline-offset: 5px; }
.ap-topic-links a:hover { text-decoration: underline; color: var(--primary-color); }
.ap-library { padding: 36px var(--page-gutter) 64px; border-top: 1px solid var(--border-color); }
.ap-library-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; }
.ap-library-heading h2 { font-family: Georgia, serif; font-weight: 500; font-size: 30px; margin: 4px 0 0; line-height: 1.3; }
.ap-text-link { color: var(--primary-color); font-size: 14px; white-space: nowrap; }
.ap-text-link span { margin-left: 12px; }
.ap-library-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; }
.ap-library-item { display: flex; flex-direction: column; border-top: 1px solid var(--border-strong); padding: 18px 0 0; min-width: 0; }
.ap-library-item:hover { border-color: var(--primary-color); }
.ap-library-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 10px; color: var(--text-faint); }
.ap-library-item h3 { font-size: 21px; font-weight: 600; line-height: 1.35; margin: 16px 0 10px; }
.ap-library-item p { font-size: 14px; color: var(--text-muted); margin: 0 0 20px; line-height: 1.65; overflow-wrap: anywhere; }
.ap-library-read { display: flex; justify-content: space-between; color: var(--primary-color); font-size: 12px; margin-top: auto; }

/* Article and supporting navigation share the page surface. */
.terim-wrapper-wide { width: 100%; }
.wiki-layout-grid { grid-template-columns: 250px minmax(0, 1fr); gap: 44px; }
.wiki-sidebar { align-self: stretch; }
.sticky-toc-container { top: calc(var(--header-height) + 24px); max-height: calc(100dvh - var(--header-height) - 48px); overflow-y: auto; scrollbar-width: thin; }
.toc-box { border: 0; border-radius: 0; background: transparent; }
.toc-header { padding: 12px 0; font-size: 12px; font-weight: 700; }
.toc-root { padding: 12px 0; }
.toc-box a { padding: 9px 12px; border-left: 2px solid transparent; border-radius: 0; line-height: 1.5; overflow-wrap: anywhere; }
.toc-box a.is-active { border-left-color: var(--primary-color); background: var(--accent-soft); }
.toc-label-row { justify-content: space-between; }
.toc-toggle-btn { flex-shrink: 0; width: 34px; height: 34px; }
.wiki-main-article, .wiki-article { border: 0; border-left: 1px solid var(--border-color); border-radius: 0; box-shadow: none; background: transparent; padding: 12px 0 32px 42px; }
.wiki-header { padding-bottom: 26px; margin-bottom: 30px; }
.entry-meta-row { font-size: 12px; gap: 12px; }
.wiki-content { font-size: 17px; line-height: 1.85; }
.wiki-content h2 { font-size: 28px; font-weight: 600; border-top: 0; margin-top: 40px; }
.wiki-content h3 { font-size: 22px; font-weight: 600; }
.wiki-content a, .entry-content a { text-decoration-thickness: 1px; }
.wiki-content blockquote { border-radius: 0; padding: 16px 24px; }
.infobox-table { font-size: 13px; table-layout: fixed; }
.infobox-table th, .infobox-table td { padding: 12px 4px; overflow-wrap: anywhere; }
.infobox-table td { font-weight: 600; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.table-scroll table { min-width: 100%; table-layout: auto; }
.wiki-content th, .wiki-content td { font-size: 15px; padding: 13px 16px; overflow-wrap: normal; word-break: normal; }
.wiki-content tbody tr:nth-child(even) { background: var(--bg-body-soft); }
.edit-log-wrap, .sa-term-comment-entry { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.edit-log { max-width: 100%; overflow-x: auto; }
.sa-term-comment-entry { display: flex; gap: 18px; align-items: center; border-width: 1px 0; border-radius: 0; background: transparent; padding: 22px 0; }
.sa-term-comment-entry p { margin: 0; font-size: 13px; }
.sa-term-comments-open { flex-shrink: 0; font-size: 14px; font-weight: 650; min-height: 44px; }
.sa-term-comment-head { flex-wrap: wrap; }
.sa-term-comment-body { overflow-wrap: anywhere; }
.sa-term-comments-dialog, .sa-correction-dialog, .sa-modal-box { max-height: calc(100dvh - 36px); overscroll-behavior: contain; }
.sa-term-comments-headline, .sa-correction-dialog > h3 { padding-right: 36px; }
.sa-term-comments-close, .sa-correction-close { width: 38px; height: 38px; }
.sa-term-comments-list-wrap { max-height: min(360px, 40dvh); }
.ap-reading-progress { position: fixed; top: var(--header-height); left: 0; width: 100%; height: 2px; z-index: 1001; background: var(--primary-color); transform: scaleX(0); transform-origin: left; pointer-events: none; }
body.admin-bar .ap-reading-progress { top: calc(var(--header-height) + 32px); }
.ap-sidebar-toggle, .ap-sidebar-close, .ap-sidebar-backdrop { display: none; }

/* WordPress media / TinyMCE surfaces live outside the article tree. */
.mce-panel, .mce-toolbar-grp, .mce-statusbar, .mce-menu, .mce-window, .mce-window-head,
.mce-foot, .mce-container-body, .mce-btn, .mce-listbox, .mce-menu-item,
.quicktags-toolbar, .wp-editor-tabs .wp-switch-editor,
.media-modal-content, .media-frame-content, .media-frame-toolbar .media-toolbar,
.media-frame-title, .media-frame-router .media-router, .media-sidebar, .attachment-details,
.media-menu, .uploader-inline, .attachments-browser .media-toolbar {
  background: var(--bg-card) !important; color: var(--text-main) !important; border-color: var(--border-color) !important;
}
.mce-ico, .mce-txt, .mce-label, .mce-title, .mce-menu-item .mce-text, .mce-btn button,
.media-modal h1, .media-modal h2, .media-modal h3, .media-menu-item, .media-router .media-menu-item {
  color: var(--text-heading) !important; text-shadow: none !important;
}
.mce-textbox, .mce-combobox input, .media-modal input, .media-modal select, .media-modal textarea { background: var(--input-bg) !important; color: var(--text-heading) !important; border-color: var(--border-strong) !important; }
.mce-btn:hover, .mce-menu-item:hover, .media-menu-item:hover, .media-router .active { background: var(--bg-elevated) !important; }
.mce-btn.mce-active, .mce-btn.mce-active:hover { background: var(--accent-soft) !important; border-color: var(--primary-color) !important; }
.html-active .switch-html, .tmce-active .switch-tmce { background: var(--bg-elevated) !important; color: var(--primary-color) !important; }
.has-deep-surface-background-color { background-color: var(--bg-card-strong) !important; }
.has-paper-surface-background-color { background-color: var(--bg-body-soft) !important; }
.has-deep-surface-color, .has-paper-surface-color { color: var(--text-heading) !important; }
.has-aritmapedia-green-color { color: var(--primary-color) !important; }
.has-fresh-cyan-color { color: var(--secondary-color) !important; }
.has-soft-gold-color { color: var(--warning-color) !important; }

@media (max-width: 1100px) {
  .header-inner { grid-template-columns: minmax(170px, 1fr) minmax(180px, 1.4fr) auto; gap: 14px; }
  .wiki-layout-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .wiki-main-article, .wiki-article { padding: 12px 0 24px; border: 0; }
  .sticky-toc-container { position: static; grid-template-columns: 1fr; max-height: none; overflow: visible; }
  .ap-sidebar-ready .wiki-sidebar { display: none; }
  .ap-sidebar-ready .wiki-sidebar.is-open { display: block; position: fixed; inset: 0 auto 0 0; width: min(340px, calc(100% - 44px)); z-index: 1900; background: var(--bg-card); padding: 20px 20px 90px; overflow-y: auto; box-shadow: var(--shadow-card); overscroll-behavior: contain; }
  .ap-sidebar-ready .ap-sidebar-toggle { display: inline-flex; position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); width: 48px; height: 48px; justify-content: center; align-items: center; z-index: 1200; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--primary-color); color: var(--primary-text); box-shadow: var(--shadow-card); }
  .ap-sidebar-close { display: flex; margin-left: auto; width: 40px; height: 40px; align-items: center; justify-content: center; color: var(--text-heading); background: var(--bg-body-soft); border: 1px solid var(--border-color); border-radius: 5px; }
  .ap-sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; z-index: 1890; background: rgba(0,0,0,.48); }
  body.ap-sidebar-open { overflow: hidden; }
  body.admin-bar .wiki-sidebar.is-open { top: 32px; }
  .ap-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
}
@media (max-width: 782px) {
  :root { --header-height: 120px; --page-gutter: 18px; }
  body.home { --header-height: 68px; }
  .header-inner { width: calc(100% - 32px); grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 42px 44px; gap: 10px 12px; padding: 12px 0; align-content: center; }
  .header-left { grid-column: 1; grid-row: 1; }
  .header-right { grid-column: 2; grid-row: 1; }
  .header-search-wrapper { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .header-inner .site-wordmark { display: block; min-width: 0; font-size: 21px; max-width: none; overflow: hidden; text-overflow: ellipsis; }
  body.home .header-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 42px; }
  .home-icon-link, .theme-toggle-btn { width: 40px; height: 40px; }
  .header-left, .header-right { gap: 8px; }
  .user-nav-link { padding: 0 12px; min-height: 40px; }
  body:not(.home) .site-main { width: calc(100% - 36px); }
  body.home .site-main { padding: var(--header-height) 0 0; }
  .ap-home-shell.ap-home-minimal { min-height: 420px; padding: 60px 20px 48px; }
  .ap-home-minimal .ap-home-title { font-size: 52px; }
  .ap-home-minimal .ap-home-description { font-size: 16px; }
  .search-input.ap-home-search-input, html[data-theme="light"] .search-input.ap-home-search-input { min-height: 62px; font-size: 16px; padding-right: 68px; }
  .search-submit-btn { width: 42px; height: 42px; right: 10px; }
  .ap-topic-links { gap: 10px 18px; }
  .ap-library { padding: 28px 20px 40px; }
  .ap-library-heading h2 { font-size: 26px; }
  .ap-library-heading { align-items: flex-start; }
  .ap-text-link { font-size: 12px; padding-top: 7px; }
  .entry-title { font-size: 34px; }
  .wiki-content { font-size: 16px; line-height: 1.8; }
  .wiki-content h2 { font-size: 25px; }
  .wiki-content h3 { font-size: 21px; }
  .table-scroll table { min-width: 640px; }
  .wiki-content .wp-block-table { overflow-x: auto; }
  .sa-term-comment-entry { flex-direction: column; align-items: flex-start; gap: 12px; }
  .sa-modal-overlay, .sa-term-comments-modal, .sa-correction-modal { padding: 10px; }
  .sa-modal-box, .sa-term-comments-dialog, .sa-correction-dialog { max-height: calc(100dvh - 20px); padding: 18px; }
  .footer-content { width: calc(100% - 36px); gap: 16px; padding: 28px 0 80px; }
  .footer-links { justify-content: center; }
  .auth-card { padding: 24px 18px; }
  .terim-form-card { padding: 0; }
  .technical-fields-grid, .term-quality-list { grid-template-columns: minmax(0, 1fr); }
  body.admin-bar .ap-reading-progress { top: calc(var(--header-height) + 46px); }
  body.admin-bar .wiki-sidebar.is-open { top: 46px; }
}
@media (max-width: 420px) {
  .header-inner .site-wordmark { font-size: 18px; }
  .header-left { gap: 6px; }
  .ap-home-minimal .ap-home-title { font-size: 42px; }
  .ap-home-kicker { font-size: 10px; }
  .ap-library-grid { grid-template-columns: minmax(0, 1fr); }
  .ap-library-item h3 { font-size: 20px; }
  .ap-library-heading { flex-wrap: wrap; gap: 12px; }
  .entry-title { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
