:root {
  --t-bg: #f8fafc;
  --t-surface: #ffffff;
  --t-surface-subtle: #ecfdf5;
  --t-header-bg: #0c1317;
  --t-header-text: #f8fafc;
  --t-text: #0f172a;
  --t-muted: #475569;
  --t-border: #d1d5db;
  --t-accent: #059669;
  --t-accent-soft: rgba(5, 150, 105, 0.14);
}

html[data-tech-mode="dark"] {
  --t-bg: #090d12;
  --t-surface: #111820;
  --t-surface-subtle: #06281e;
  --t-text: #e2e8f0;
  --t-muted: #94a3b8;
  --t-border: #1e293b;
}

.ksef-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--t-bg);
  color: var(--t-text);
  font-family: var(--font-body, "Inter", system-ui, sans-serif);
}

.ksef-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--t-header-bg);
  color: var(--t-header-text);
  border-bottom: 2px solid var(--t-accent);
}

.ksef-header-inner,
.ksef-footer-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0.78rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ksef-brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ksef-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  text-decoration: none;
}

.ksef-brand-icon {
  border-radius: 6px;
}

.ksef-brand-badge {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
  border-radius: 5px;
  border: 1px solid rgba(5, 150, 105, 0.5);
  background: rgba(5, 150, 105, 0.2);
  color: #6ee7b7;
}

.ksef-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.88rem;
}

.ksef-nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
}

.ksef-nav a:hover {
  color: #6ee7b7;
}

.ksef-mode-btn {
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 6px;
  padding: 0.28rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.ksef-main {
  flex: 1;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
}

.ksef-hero-intro h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0.4rem 0 0.55rem;
}

.ksef-hero-intro p {
  color: var(--t-muted);
  max-width: 68ch;
  line-height: 1.65;
  margin: 0;
}

.ksef-mono-tag {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.75rem;
  color: var(--t-accent);
  font-weight: 600;
}

.ksef-filter-bar {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ksef-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ksef-pill {
  border: 1px solid var(--t-border);
  background: var(--t-surface);
  color: var(--t-text);
  border-radius: 6px;
  padding: 0.32rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.ksef-search-input {
  border: 1px solid var(--t-border);
  background: var(--t-surface);
  color: var(--t-text);
  border-radius: 6px;
  padding: 0.42rem 0.75rem;
  min-width: 250px;
  font-size: 0.85rem;
}

.ksef-bento-top {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .ksef-bento-top {
    grid-template-columns: 1.2fr 1fr;
  }
}

.ksef-bento-featured,
.ksef-bento-card,
.ksef-dense-row {
  background: var(--t-surface);
  border: 1px solid var(--t-border);
  border-radius: 8px;
  padding: 1.2rem;
}

.ksef-bento-featured {
  border-top: 3px solid var(--t-accent);
}

.ksef-bento-featured a,
.ksef-bento-card a,
.ksef-dense-row a {
  color: inherit;
  text-decoration: none;
}

.ksef-bento-featured a:hover,
.ksef-bento-card a:hover,
.ksef-dense-row a:hover {
  text-decoration: underline;
}

.ksef-bento-side-stack {
  display: grid;
  gap: 0.9rem;
}

.ksef-meta-row,
.ksef-badge-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.ksef-cat-chip,
.ksef-status-chip,
.ksef-mono-pill {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  padding: 0.14rem 0.48rem;
  border-radius: 4px;
  border: 1px solid var(--t-border);
  background: var(--t-surface-subtle);
}

.ksef-mono-date,
.ksef-meta-mono {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.75rem;
  color: var(--t-muted);
}

.ksef-dense-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.ksef-section-bar {
  margin-top: 2.2rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.ksef-grid-3zone {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}

@media (min-width: 1120px) {
  .ksef-grid-3zone {
    grid-template-columns: 215px minmax(0, 70ch) 235px;
    justify-content: space-between;
    align-items: start;
  }
}

.ksef-toc-col,
.ksef-meta-col {
  display: none;
}

@media (min-width: 1120px) {
  .ksef-toc-col,
  .ksef-meta-col {
    display: block;
    position: sticky;
    top: 4.75rem;
  }
}

.ksef-toc-title,
.ksef-side-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t-muted);
  margin-bottom: 0.6rem;
}

.ksef-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.ksef-toc-list a {
  display: block;
  font-size: 0.82rem;
  color: var(--t-muted);
  text-decoration: none;
  padding: 0.26rem 0.55rem;
  border-left: 2px solid var(--t-border);
}

.ksef-toc-sub a {
  padding-left: 1.15rem;
  font-size: 0.78rem;
}

.ksef-side-box {
  border: 1px solid var(--t-border);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--t-surface);
}

.ksef-side-dl {
  margin: 0;
  display: grid;
  gap: 0.65rem;
  font-size: 0.82rem;
}

.ksef-side-dl dt {
  color: var(--t-muted);
  font-size: 0.74rem;
}

.ksef-side-dl dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
}

.ksef-reading-col {
  min-width: 0;
  max-width: 72ch;
}

.ksef-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--t-muted);
  margin-bottom: 0.8rem;
}

.ksef-breadcrumbs a {
  color: inherit;
  text-decoration: none;
}

.ksef-article-header h1 {
  font-size: clamp(1.75rem, 3vw, 2.3rem);
  font-weight: 800;
  line-height: 1.24;
  margin: 0.6rem 0;
}

.ksef-status-badge {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.16rem 0.52rem;
  border-radius: 5px;
  border: 1px solid var(--t-accent);
}

.ksef-lead {
  font-size: 1.07rem;
  line-height: 1.65;
  color: var(--t-muted);
}

.ksef-tldr-box {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--t-border);
  border-left: 4px solid var(--t-accent);
  border-radius: 8px;
  background: var(--t-surface);
}

.ksef-tldr-head {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.ksef-prose {
  font-size: 1.09375rem;
  line-height: 1.7;
}

.ksef-prose h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 5rem;
}

.ksef-prose h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.45rem 0 0.5rem;
  scroll-margin-top: 5rem;
}

.ksef-prose pre,
.ksef-prose code {
  font-family: var(--font-mono, ui-monospace, monospace);
}

.ksef-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}

.ksef-prose th,
.ksef-prose td {
  border: 1px solid var(--t-border);
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.ksef-related-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.ksef-related-card {
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem;
  border: 1px solid var(--t-border);
  border-radius: 8px;
  background: var(--t-surface);
  color: inherit;
  text-decoration: none;
}

.ksef-footer {
  border-top: 1px solid var(--t-border);
  background: var(--t-surface);
  font-size: 0.85rem;
  color: var(--t-muted);
}

.ksef-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.ksef-footer-links a {
  color: inherit;
  text-decoration: none;
}

/* ---- hero, covers, card polish (shared across tech variants; P- = portal prefix) ---- */

.ksef-home-wrap {
  display: block;
}

.ksef-hero-intro {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 1.5rem;
  align-items: center;
  padding: 2rem 1.75rem;
  border: 1px solid var(--t-border);
  border-radius: 18px;
  background:
    radial-gradient(60% 80% at 100% 0%, var(--t-accent-soft), transparent 70%),
    linear-gradient(color-mix(in srgb, var(--t-border) 55%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, color-mix(in srgb, var(--t-border) 55%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--t-surface);
  background-blend-mode: normal;
}

.ksef-hero-intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, var(--t-surface) 100%);
  opacity: 0.55;
}

.ksef-hero-intro > * {
  position: relative;
  z-index: 1;
}

@media (min-width: 900px) {
  .ksef-hero-intro.ksef-has-art {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    padding: 2.5rem 2.25rem;
  }
}

.ksef-hero-text h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.65rem);
  line-height: 1.15;
}

.ksef-hero-art {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--t-border);
  background: var(--t-surface-subtle);
  box-shadow: 0 18px 40px -24px color-mix(in srgb, var(--t-accent) 55%, transparent);
}

.ksef-hero-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.ksef-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 1.1rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--t-muted);
}

.ksef-hero-stats strong {
  color: var(--t-accent);
  font-size: 0.95rem;
}

.ksef-pill {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ksef-pill:hover {
  border-color: var(--t-accent);
  color: var(--t-accent);
}

.ksef-pill-active,
.ksef-pill-active:hover {
  background: var(--t-accent);
  border-color: var(--t-accent);
  color: #fff;
}

.ksef-search-input:focus {
  outline: 2px solid var(--t-accent-soft);
  border-color: var(--t-accent);
}

.ksef-bento-featured,
.ksef-bento-card,
.ksef-dense-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.ksef-bento-featured:hover,
.ksef-bento-card:hover,
.ksef-dense-row:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--t-accent) 45%, var(--t-border));
  box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--t-accent) 60%, transparent);
}

.ksef-card-thumb {
  display: block;
  margin: -1.25rem -1.25rem 0.85rem;
  aspect-ratio: 16 / 9;
  background: var(--t-surface-subtle);
  overflow: hidden;
}

.ksef-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.ksef-bento-featured:hover .ksef-card-thumb img,
.ksef-bento-card:hover .ksef-card-thumb img,
.ksef-dense-row:hover .ksef-card-thumb img {
  transform: scale(1.03);
}

.ksef-card-thumb-fallback {
  display: flex;
  height: 100%;
  box-sizing: border-box;
  align-items: flex-end;
  padding: 0.85rem 1rem;
  background:
    radial-gradient(70% 90% at 85% 10%, var(--t-accent-soft), transparent 70%),
    linear-gradient(color-mix(in srgb, var(--t-accent) 14%, transparent) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, color-mix(in srgb, var(--t-accent) 14%, transparent) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(135deg, color-mix(in srgb, var(--t-accent) 22%, var(--t-surface-subtle)), var(--t-surface-subtle));
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--t-accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ksef-bento-card .ksef-card-thumb {
  aspect-ratio: 3 / 1;
}

.ksef-bento-featured .ksef-card-thumb {
  aspect-ratio: auto;
  flex: 1 1 auto;
  min-height: 240px;
}

.ksef-bento-featured h2 a,
.ksef-bento-card h3 a,
.ksef-dense-row h3 a {
  background-image: linear-gradient(var(--t-accent), var(--t-accent));
  background-size: 0 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease;
}

.ksef-bento-featured a:hover,
.ksef-bento-card a:hover,
.ksef-dense-row a:hover {
  text-decoration: none;
}

.ksef-bento-featured:hover h2 a,
.ksef-bento-card:hover h3 a,
.ksef-dense-row:hover h3 a {
  background-size: 100% 2px;
}

.ksef-bento-card h3,
.ksef-dense-row h3 {
  font-size: 1.05rem;
  line-height: 1.35;
  margin: 0.45rem 0 0.35rem;
}

.ksef-bento-card p,
.ksef-dense-row p,
.ksef-bento-featured p {
  color: var(--t-muted);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.ksef-cat-chip {
  color: var(--t-accent);
  border-color: color-mix(in srgb, var(--t-accent) 30%, var(--t-border));
  background: var(--t-accent-soft);
}

.ksef-bento-foot {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ksef-tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ksef-read-cta {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--t-accent);
}

.ksef-list-section {
  margin-top: 2.5rem;
}

.ksef-section-bar h2 {
  font-size: 1.25rem;
  margin: 0;
}

.ksef-section-bar a {
  color: var(--t-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}

.ksef-empty-box {
  margin-top: 1.5rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--t-border);
  border-radius: 14px;
  color: var(--t-muted);
  background: var(--t-surface);
}

/* ---- article page ---- */

.ksef-article-page {
  display: block;
}

.ksef-author-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.25rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--t-muted);
}

.ksef-author-line strong {
  color: var(--t-text);
}

.ksef-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--t-accent-soft);
}

.ksef-cover-fig,
.ksef-hero-infographic {
  margin: 1.25rem 0 1.75rem;
}

.ksef-cover-fig img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--t-border);
}

.ksef-cover-fig figcaption {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--t-muted);
}

.ksef-prose a {
  color: var(--t-accent);
  text-underline-offset: 3px;
}

.ksef-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.ksef-prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--t-accent);
  background: var(--t-surface-subtle);
  border-radius: 0 10px 10px 0;
}

.ksef-prose :not(pre) > code {
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--t-surface-subtle);
  border: 1px solid var(--t-border);
}

.ksef-prose th {
  background: var(--t-surface-subtle);
  font-weight: 600;
}

.ksef-tags-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--t-border);
}

.ksef-related-box {
  margin-top: 2.25rem;
}

.ksef-related-box h2 {
  font-size: 1.15rem;
  margin: 0 0 0.85rem;
}

.ksef-related-card {
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ksef-related-card:hover {
  border-color: var(--t-accent);
  transform: translateY(-2px);
}

.ksef-toc-list a:hover {
  color: var(--t-accent);
  border-left-color: var(--t-accent);
}

@media (prefers-reduced-motion: reduce) {
  .ksef-bento-featured,
  .ksef-bento-card,
  .ksef-dense-row,
  .ksef-card-thumb img,
  .ksef-related-card {
    transition: none;
  }
}

.ksef-comments-box {
  margin-top: 2rem;
  padding: 1.4rem;
  border: 1px solid var(--t-border);
  border-radius: 10px;
  background: var(--t-surface);
  display: grid;
  gap: 1rem;
  --color-base-100: var(--t-surface);
  --color-base-200: var(--t-surface-subtle);
  --color-base-300: var(--t-border);
  --color-base-content: var(--t-text);
}

.ksef-comments-box h2 {
  margin: 0;
  font-size: 1.2rem;
}

.ksef-comments-lead {
  margin: 0;
  font-size: 0.88rem;
  color: var(--t-muted);
}

.ksef-comments-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--t-border);
  border-radius: 8px;
}

.ksef-comments-empty p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--t-muted);
}

.ksef-comments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.ksef-comment-item {
  padding: 0.9rem 1rem;
  border: 1px solid var(--t-border);
  border-radius: 8px;
  background: var(--t-surface-subtle);
}

.ksef-comment-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.ksef-comment-body {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.55;
}

.ksef-comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.ksef-comment-replies {
  list-style: none;
  margin: 0.75rem 0 0 1.25rem;
  padding: 0 0 0 0.85rem;
  border-left: 2px solid var(--t-border);
  display: grid;
  gap: 0.65rem;
}

.ksef-comment-reply {
  font-size: 0.9rem;
}
