/* ============================================================
   Kekuk IPA Library — Editorial Light/Dark Responsive Stylesheet
   Zero emojis · Bootstrap Icons · Mobile-first iPhone & iPad UX
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg:           light-dark(#f8fafc, #0b0f17);
  --surface:      light-dark(#ffffff, #111827);
  --surface-2:    light-dark(#f1f5f9, #1a2234);
  --surface-tint: light-dark(#eff6ff, #172554);
  --border:       light-dark(#e2e8f0, #1f2937);
  --border-strong:light-dark(#cbd5e1, #334155);
  --text:         light-dark(#0f172a, #f8fafc);
  --text-2:       light-dark(#334155, #cbd5e1);
  --muted:        light-dark(#64748b, #94a3b8);
  --brand:        light-dark(#2563eb, #3b82f6);
  --brand-hover:  light-dark(#1d4ed8, #60a5fa);
  --brand-soft:   light-dark(rgba(37, 99, 235, 0.10), rgba(59, 130, 246, 0.18));
  --ok:           light-dark(#059669, #34d399);
  --ok-soft:      light-dark(rgba(5, 150, 105, 0.10), rgba(52, 211, 153, 0.16));
  --warn:         light-dark(#d97706, #fbbf24);
  --warn-soft:    light-dark(rgba(217, 119, 6, 0.10), rgba(251, 191, 36, 0.14));
  --shadow-sm:    light-dark(0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(0, 0, 0, 0.35));
  --shadow-md:    light-dark(0 8px 24px rgba(15, 23, 42, 0.07), 0 10px 28px rgba(0, 0, 0, 0.45));
  --radius-sm:    10px;
  --radius-md:    16px;
  --radius-lg:    22px;
  --max-w:        1140px;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 16px;
}
@media (min-width: 768px) {
  .container { padding-inline: 28px; }
}

.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 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 62px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  text-decoration: none !important;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.brand-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  letter-spacing: 0.02em;
}
@media (max-width: 480px) {
  .brand-badge { display: none; }
}
.nav-links {
  display: none;
  align-items: center;
  gap: 20px;
}
.nav-links a {
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 600;
}
.nav-links a:hover { color: var(--brand); text-decoration: none; }
@media (min-width: 820px) {
  .nav-links { display: flex; }
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.header-actions .btn-sm {
  white-space: nowrap;
  padding: 7px 11px;
  font-size: 0.8rem;
}

/* Theme toggle (branching via meta + media query, zero FOUC) */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.theme-toggle:hover { border-color: var(--border-strong); background: var(--surface-2); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-flex; }

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .icon-sun { display: inline-flex; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle .icon-moon { display: none; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-sun { display: inline-flex; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-moon { display: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--brand);
  color: #ffffff;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-soft {
  background: var(--brand-soft);
  color: var(--brand);
}
.btn-soft:hover { filter: brightness(0.96); }
.btn-sm {
  min-height: 36px;
  padding: 7px 13px;
  font-size: 0.84rem;
}
.btn-block { width: 100%; }

/* Hero */
.hero {
  padding: 36px 0 24px;
}
@media (min-width: 768px) {
  .hero { padding: 52px 0 32px; }
}
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 20px;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) {
  .hero-card { padding: 38px 36px; }
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 6px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.hero-kicker i { flex-shrink: 0; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 5.2vw, 2.45rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  font-weight: 800;
  overflow-wrap: break-word;
}
.hero-sub {
  margin: 0 0 22px;
  color: var(--text-2);
  font-size: 0.95rem;
  max-width: 68ch;
  overflow-wrap: break-word;
}

/* Search & Filters */
.search-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 600px) {
  .search-bar { flex-direction: row; }
}
.search-input-wrap {
  position: relative;
  flex: 1;
}
.search-input-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px 10px 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.search-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--muted);
}
.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.trust-item i { color: var(--brand); }

/* Category Pills */
.cat-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 14px;
  scrollbar-width: none;
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none !important;
  transition: all 0.15s ease;
}
.cat-pill:hover { border-color: var(--brand); color: var(--brand); }
.cat-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

/* Section Headings */
.section {
  padding: 24px 0;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-meta {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

/* App Cards Grid */
.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 640px) {
  .app-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (min-width: 1024px) {
  .app-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}

.app-card {
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.app-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.app-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.app-info {
  min-width: 0;
  flex: 1;
}
.app-title {
  margin: 0 0 3px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.app-title a { color: inherit; text-decoration: none; }
.app-title a:hover { color: var(--brand); }
.app-dev {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  min-width: 0;
}
.app-dev span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-dev i { color: var(--ok); flex-shrink: 0; }
.app-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }

.app-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1;
}
.app-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.app-actions .btn {
  min-width: 0;
  white-space: nowrap;
  padding: 7px 12px;
}

/* AdSense Safe Container */
.ad-slot {
  width: 100%;
  max-width: 100%;
  margin: 22px 0;
  padding: 12px 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  min-height: 100px;
  overflow: hidden;
  contain: layout inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ad-slot-compact {
  margin: 0;
}
.ad-slot ins.adsbygoogle {
  display: block;
  width: 100%;
  max-width: 100%;
}
.ad-slot-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

/* Lead Capture Card */
.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 820px) {
  .lead-card {
    grid-template-columns: 1.1fr 1fr;
    padding: 32px 34px;
    align-items: center;
  }
}
.lead-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 520px) {
  .form-row { grid-template-columns: 1.3fr 1fr; }
}
.field {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
}
.field:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form-msg {
  font-size: 0.84rem;
  font-weight: 600;
  min-height: 20px;
}
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: #dc2626; }

/* Signers Comparison Grid */
.signer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 768px) {
  .signer-grid { grid-template-columns: repeat(3, 1fr); }
}
.signer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.signer-card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.signer-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-2);
  flex: 1;
}

/* App Detail Page */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  margin: 20px 0 14px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}
@media (min-width: 900px) {
  .detail-layout { grid-template-columns: 1.65fr 1fr; align-items: start; }
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 768px) {
  .detail-card { padding: 30px; }
}
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}
.detail-icon {
  width: 82px;
  height: 82px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.detail-cta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 20px 0;
}
@media (min-width: 520px) {
  .detail-cta-row { grid-template-columns: 1fr 1fr; }
}
.meta-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  margin-bottom: 20px;
}
.meta-item dt {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.lead-card > *,
.signer-card,
.detail-layout > *,
.footer-col,
.meta-item {
  min-width: 0;
  max-width: 100%;
}
.meta-item dd {
  margin: 3px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.prose {
  font-size: 0.94rem;
  color: var(--text-2);
  line-height: 1.7;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.prose img, .prose iframe, .prose video, .prose table {
  max-width: 100%;
  height: auto;
}
.prose pre, .prose code {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.prose h2, .prose h3 {
  color: var(--text);
  margin: 20px 0 8px;
  font-size: 1.08rem;
}

/* Native Modal Dialogs (Modern Web Guidance compliant) */
dialog.kekuk-dialog {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  width: calc(100% - 24px);
  max-width: 600px;
  max-height: calc(100dvh - 36px);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}
dialog.kekuk-dialog:modal {
  overscroll-behavior: contain;
}
dialog.kekuk-dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(5px);
  overflow: hidden;
  overscroll-behavior: contain;
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.dlg-head h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 9px;
}
.dlg-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
}
.dlg-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100dvh - 150px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.method-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.method-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  background: var(--bg);
}
.method-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.method-item-title {
  font-size: 0.92rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 7px;
}
.method-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-2);
}
.legacy-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--warn-soft);
  font-size: 0.82rem;
  color: var(--text-2);
}
.legacy-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-weight: 700;
}
.countdown-box {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  transition: width 0.25s linear;
}
.related-mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .related-mini-grid { grid-template-columns: repeat(2, 1fr); }
}
.related-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none !important;
}
.related-mini-card:hover { border-color: var(--brand); }
.related-mini-card img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
}
.related-mini-card span {
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.related-mini-card small {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

/* Footer */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 34px 0 42px;
  font-size: 0.86rem;
  color: var(--muted);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 1.6fr 1fr 1fr; }
}
.footer-col h3 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text);
}
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--brand); }
.footer-bottom {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}
