/* MANFAQ ? Icebean layout */

:root,
[data-theme="light"] {
  --bg-deep: #cce6ff;
  --bg-surface: #d4d4d4;
  --bg-raised: #f2f2f2;
  --bg-hover: rgba(255, 255, 255, 0.45);
  --border: #9a9a9a;
  --border-subtle: #b5b5b5;
  --text: #111111;
  --text-muted: #333333;
  --text-faint: #595959;
  --accent: #005cb3;
  --accent-hover: #3a88c5;
  --accent-soft: rgba(58, 136, 197, 0.18);
  --code-bg: #e6e6e6;
  --pre-bg: #f7f7f7;
  --pre-text: #111111;
  --shadow: none;
  --header-bg: #6a8099;
  --header-text: #ffffff;
  --header-muted: #ffffff;
  --header-faint: rgba(255, 255, 255, 0.82);
  --panel-bg: #bfbfbf;
  --panel-shadow: none;
  --badge-m3: #2d6a4f;
  --badge-m5: #1d4e89;
  --badge-both: #6b4c9a;
  --download-bg: #efefef;
  --note-bg: rgba(58, 136, 197, 0.12);
  --note-border: #3a88c5;
  --input-bg: #f7f7f7;
  --input-border: #888888;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius: 0.55rem;
  --sidebar-width: 300px;
}

[data-theme="dark"] {
  --bg-deep: #0b1020;
  --bg-surface: #101628;
  --bg-raised: rgba(5, 7, 17, 0.55);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text: #f5f5f7;
  --text-muted: #c4c7d1;
  --text-faint: #8a8ea0;
  --accent: #7ee0ff;
  --accent-hover: #4da3ff;
  --accent-soft: rgba(77, 163, 255, 0.15);
  --code-bg: rgba(255, 255, 255, 0.06);
  --pre-bg: #050711;
  --pre-text: #f5f5f7;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.8);
  --header-bg: radial-gradient(circle at top left, #243b6b 0, #0b1020 45%);
  --header-text: #f5f5f7;
  --header-muted: #c4c7d1;
  --header-faint: #8a8ea0;
  --panel-bg: radial-gradient(circle at top left, #181f38 0, #080b16 55%);
  --panel-shadow: 0 18px 55px rgba(0, 0, 0, 0.8);
  --badge-m3: #3d9970;
  --badge-m5: #4a90d9;
  --badge-both: #9b7ed8;
  --download-bg: rgba(77, 163, 255, 0.12);
  --note-bg: rgba(77, 163, 255, 0.1);
  --note-border: #4da3ff;
  --input-bg: rgba(9, 12, 24, 0.85);
  --input-border: rgba(255, 255, 255, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-deep: #0b1020;
    --bg-surface: #101628;
    --bg-raised: rgba(5, 7, 17, 0.55);
    --bg-hover: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --text: #f5f5f7;
    --text-muted: #c4c7d1;
    --text-faint: #8a8ea0;
    --accent: #7ee0ff;
    --accent-hover: #4da3ff;
    --accent-soft: rgba(77, 163, 255, 0.15);
    --code-bg: rgba(255, 255, 255, 0.06);
    --pre-bg: #050711;
    --pre-text: #f5f5f7;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.8);
    --header-bg: radial-gradient(circle at top left, #243b6b 0, #0b1020 45%);
    --header-text: #f5f5f7;
    --header-muted: #c4c7d1;
    --header-faint: #8a8ea0;
    --panel-bg: radial-gradient(circle at top left, #181f38 0, #080b16 55%);
    --panel-shadow: 0 18px 55px rgba(0, 0, 0, 0.8);
    --badge-m3: #3d9970;
    --badge-m5: #4a90d9;
    --badge-both: #9b7ed8;
    --download-bg: rgba(77, 163, 255, 0.12);
    --note-bg: rgba(77, 163, 255, 0.1);
    --note-border: #4da3ff;
    --input-bg: rgba(9, 12, 24, 0.85);
    --input-border: rgba(255, 255, 255, 0.2);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.55;
}

/* Header ? same chrome as icebean.online */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  color: var(--header-text);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-logo-link {
  display: flex;
  flex-shrink: 0;
  line-height: 0;
}

.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  cursor: pointer;
}

.app-header h1 {
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 1.15rem;
  color: var(--header-text);
  cursor: pointer;
}

.app-header .subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: var(--header-muted);
}

.subtitle-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.app-header .version {
  display: block;
  font-size: 0.65rem;
  color: var(--header-faint);
}

.header-partner-logo {
  display: inline-block;
  height: 32px;
  width: auto;
  opacity: 0.95;
  flex: 0 0 auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill-btn,
.theme-toggle {
  cursor: pointer;
  border-radius: 999px;
  border: none;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  font-family: inherit;
  background: linear-gradient(135deg, #4da3ff, #00d5ff);
  color: #050711;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.pill-btn:hover,
.theme-toggle:hover { filter: brightness(1.08); }

[data-theme="light"] .pill-btn,
[data-theme="light"] .theme-toggle {
  background: #3a88c5;
  color: #fff;
  box-shadow: none;
}

/* Layout */

.app-main {
  flex: 1;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 0;
  padding: 1rem 1.5rem 1.25rem;
  gap: 0.75rem;
}

.panel {
  background: var(--panel-bg);
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  box-shadow: var(--panel-shadow);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 1rem 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 1.15rem 1.35rem 1.35rem;
}

/* Search */

.search-box {
  position: relative;
  padding: 0 0.85rem;
}

.search-box input {
  width: 100%;
  padding: 0.35rem 2rem 0.35rem 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 0.35rem;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
}

.search-box input:focus {
  outline: 2px solid #4da3ff;
  outline-offset: 1px;
  border-color: #4da3ff;
}

.search-box input::placeholder { color: var(--text-faint); }

.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration,
.search-box input[type="search"]::-webkit-search-results-button,
.search-box input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-clear {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
}

.search-clear:hover { color: var(--text); background: var(--bg-hover); }

/* TOC */

.toc { padding: 0 0.85rem; }

.sidebar-heading {
  margin: 0 0 0.5rem;
  padding: 0 0.85rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.toc-topic { margin-bottom: 1rem; }

.toc-topic-title {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.toc-topic-desc {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  line-height: 1.35;
}

.toc-articles {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-articles li { margin: 0; }

.toc-link {
  display: block;
  padding: 0.3rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
  transition: background 0.12s, color 0.12s;
}

.toc-link:hover { background: var(--bg-hover); color: var(--accent); }

.toc-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* External links */

.external-links {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.external-links ul {
  list-style: none;
  margin: 0;
  padding: 0 0.85rem;
}

.external-links li {
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
}

.external-links a {
  color: var(--accent);
  text-decoration: none;
}

.external-links a:hover { text-decoration: underline; }

.ext-group-item { margin-bottom: 0.45rem; }

.ext-group-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.ext-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.65rem;
}

.ext-group a { font-size: 0.78rem; }

.ext-desc {
  display: block;
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

/* Welcome */

.welcome h2 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.welcome p {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
  max-width: 42rem;
}

.welcome-hint {
  font-size: 0.88rem;
  color: var(--text-faint) !important;
  font-style: italic;
}

/* Search results */

.results-heading {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.results-count {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.result-item:last-child { border-bottom: none; }

.result-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 500;
  font-size: 1rem;
}

.result-link:hover .result-title { text-decoration: underline; }

.result-topic {
  display: block;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}

.result-summary {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Article */

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb-sep { margin: 0 0.35rem; }

.article-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.article-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.article-summary {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.article-section {
  margin-bottom: 1.75rem;
}

.article-section h3 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.article-section p { margin: 0 0 0.65rem; }

.article-section ul,
.article-section ol {
  margin: 0 0 0.65rem;
  padding-left: 1.4rem;
}

.article-section li { margin-bottom: 0.3rem; }

/* Badges */

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  color: #fff;
  vertical-align: middle;
}

.badge-m3 { background: var(--badge-m3); }
.badge-m5 { background: var(--badge-m5); }
.badge-both { background: var(--badge-both); }

/* Code & pre */

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  margin: 0 0 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--pre-bg);
  color: var(--pre-text);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  border: 1px solid var(--border);
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Tables */

.info-table {
  width: 100%;
  max-width: 28rem;
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}

.info-table.wide {
  max-width: 46rem;
}

.info-table.wide th {
  width: 9.5rem;
}

.info-table th,
.info-table td {
  padding: 0.45rem 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
}

.info-table th {
  background: var(--bg-surface);
  font-weight: 600;
  width: 40%;
  color: var(--text-muted);
}

.info-table td { background: var(--bg-raised); }

.info-table code { font-size: 0.95em; }

/* Field list */

.field-list {
  margin: 0 0 0.75rem;
}

.field-list dt {
  font-weight: 600;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.field-list dd {
  margin: 0.15rem 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Notes */

.note {
  padding: 0.65rem 0.85rem;
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Downloads */

.download-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.download-list li {
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: var(--download-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  width: fit-content;
  transition: background 0.12s, border-color 0.12s;
}

.download-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.download-icon { font-size: 1rem; }

.download-desc {
  font-size: 0.78rem;
  color: var(--text-faint);
  padding-left: 0.25rem;
}

/* Related links */

.related-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.related-links li { margin-bottom: 0.35rem; }

.related-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
}

.related-links a:hover { text-decoration: underline; }

/* Keywords */

.article-keywords {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-faint);
}

.keywords-label { margin-right: 0.25rem; }

.keyword-tag {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  cursor: pointer;
  margin: 0.1rem 0.15rem 0.1rem 0;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.keyword-tag:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Ask form */

.welcome-ask {
  margin-top: 1rem;
}

.welcome .pill-btn,
.article-ask .pill-btn {
  margin-top: 0.35rem;
}

.article-ask {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.article-ask h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.article-ask p {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
}

.article-ask .ask-secondary {
  margin-left: 0.4rem;
}

.ask-secondary {
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}

.ask-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ask-dialog[hidden] { display: none; }

.ask-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ask-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 17, 0.72);
}

.ask-panel {
  position: relative;
  width: min(32rem, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  margin: 0;
  padding: 1.15rem 1.25rem 1.2rem;
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  box-shadow: var(--panel-shadow);
}

.ask-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 500;
}

.ask-lead,
.ask-page-label,
.ask-general-hint {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ask-subject-line {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--text);
}

.ask-subject-k {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ask-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
}

.ask-mode {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
}

.ask-panel label {
  display: block;
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ask-panel input[type="text"],
.ask-panel select,
.ask-panel textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.ask-panel textarea { resize: vertical; }

.ask-panel input:focus,
.ask-panel select:focus,
.ask-panel textarea:focus {
  outline: 2px solid #4da3ff;
  outline-offset: 1px;
  border-color: #4da3ff;
}

.ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

/* Utilities */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Responsive */

@media (max-width: 768px) {
  .app-header { padding: 0.6rem 1rem; }

  .app-main {
    flex-direction: column;
    padding: 0.75rem;
  }

  .sidebar {
    width: 100%;
    max-height: 42vh;
  }

  .main { padding: 1rem; }

  .header-partner-logo { height: 28px; }
}
