:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: rgba(9, 15, 20, 0.88);
  --cyan: #2de1c2;
  --text: #f2f7f6;
  --muted: #8ea29f;
  --line: rgba(89, 224, 204, 0.14);
  --edge: clamp(24px, 3vw, 58px);
  --kc-stats-band: 112px;
  --kc-header-band: 96px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  font-size: 20px;
}

.kc-app {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 50% 55%, rgba(28, 48, 72, 0.28), transparent 62%),
    linear-gradient(180deg, #080b0e 0%, var(--bg) 70%);
}

.kc-ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(45, 225, 194, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 225, 194, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 50% 52%, #000 12%, transparent 78%);
}

.kc-brand {
  position: absolute;
  top: var(--edge);
  left: var(--edge);
  right: var(--edge);
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.kc-brand__home {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}

.kc-brand__mark {
  width: var(--header-brand-mark, 52px);
  height: var(--header-brand-mark, 52px);
  overflow: visible;
  display: grid;
  place-items: center;
}

.kc-brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.kc-brand__name {
  font-size: var(--header-brand-name, 28px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.kc-brand__tagline {
  font-size: var(--header-brand-sub, 14px);
  color: var(--muted);
  line-height: 1.35;
}

.kc-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.kc-clock time {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.kc-clock span {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kc-caption {
  position: absolute;
  top: calc(var(--edge) + var(--kc-header-band));
  left: var(--edge);
  right: var(--edge);
  z-index: 3;
  max-width: min(920px, 58vw);
  pointer-events: none;
}

.kc-caption__kicker {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 8px;
}

.kc-caption__title {
  margin: 0 0 8px;
  font-size: clamp(28px, 3.2vw, 44px);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.15;
}

.kc-caption__detail {
  margin: 0;
  font-size: clamp(14px, 1.35vw, 18px);
  color: var(--muted);
  line-height: 1.45;
  max-width: 42em;
}

.kc-river-wrap {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  top: calc(var(--edge) + var(--kc-header-band) + 118px);
  bottom: calc(var(--kc-stats-band) + 28px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.kc-river {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(10px, 1.2vw, 22px);
  align-items: end;
  min-height: 0;
  padding: 8px 0 4px;
}

.kc-phase {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  height: 100%;
  min-height: 0;
}

.kc-phase__bar {
  position: relative;
  width: 100%;
  min-height: 8px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(
    180deg,
    var(--phase-color) 0%,
    var(--phase-color) 55%,
    rgba(7, 9, 12, 0.55) 100%
  );
  box-shadow:
    0 0 24px rgba(45, 225, 194, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: height 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  overflow: hidden;
}

.kc-phase__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255, 255, 255, 0.14) 48%,
    transparent 66%
  );
  background-size: 220% 100%;
  animation: kc-flow 4.8s linear infinite;
  opacity: 0.55;
  pointer-events: none;
}

.kc-phase--empty .kc-phase__bar {
  opacity: 0.28;
  box-shadow: none;
}

.kc-phase--empty .kc-phase__bar::after {
  animation: none;
  opacity: 0;
}

.kc-phase--spotlight .kc-phase__bar {
  box-shadow:
    0 0 36px rgba(255, 255, 255, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.kc-phase__count {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(16px, 1.6vw, 26px);
  font-weight: 600;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.kc-phase__label {
  margin-top: 12px;
  text-align: center;
  font-size: clamp(12px, 1.1vw, 16px);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.kc-phase__slug {
  display: block;
  margin-top: 4px;
  font-size: clamp(10px, 0.85vw, 12px);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.kc-source-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.kc-app.is-curated .kc-source-note {
  display: block;
}

.kc-spotlight {
  position: absolute;
  top: calc(var(--edge) + var(--kc-header-band));
  right: var(--edge);
  z-index: 5;
  width: min(360px, 28vw);
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.kc-spotlight.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.kc-spotlight__eyebrow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 8px;
}

.kc-spotlight__origin {
  color: var(--muted);
  letter-spacing: 0.06em;
}

.kc-spotlight h2 {
  margin: 0 0 6px;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.2;
}

.kc-spotlight__aliases {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.kc-spotlight__meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.kc-spotlight__meta strong {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.kc-spotlight__meta span {
  font-size: 11px;
  color: var(--muted);
}

.kc-spotlight__profile {
  display: inline-block;
  margin-top: 4px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.kc-spotlight__profile:hover {
  text-decoration: underline;
}

.kc-stats {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: var(--kc-stats-band);
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 36px);
  padding: 0 var(--edge);
  background: linear-gradient(180deg, transparent, rgba(4, 6, 8, 0.92) 28%);
  border-top: 1px solid var(--line);
}

.kc-stat strong {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(24px, 2.4vw, 36px);
  font-weight: 600;
  line-height: 1.1;
}

.kc-stat span {
  font-size: 13px;
  color: var(--muted);
}

.kc-stat--alert strong {
  color: #ff6b5a;
}

.kc-stat--scene {
  margin-left: auto;
  text-align: right;
}

.kc-stat--scene strong {
  font-size: clamp(16px, 1.4vw, 22px);
  letter-spacing: 0.08em;
}

.kc-help {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.kc-help kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(142, 162, 159, 0.35);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text);
}

.kc-mobile-controls {
  display: none;
  position: absolute;
  right: var(--edge);
  bottom: calc(var(--kc-stats-band) + 16px);
  z-index: 6;
  gap: 10px;
}

.kc-mobile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.kc-error {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(7, 9, 12, 0.92);
  font-size: 20px;
  color: var(--muted);
}

.kc-error[hidden] {
  display: none !important;
}

@keyframes kc-flow {
  from { background-position: 120% 0; }
  to { background-position: -40% 0; }
}

@media (max-width: 900px) {
  .kc-caption {
    max-width: none;
  }

  .kc-spotlight {
    display: none;
  }

  .kc-river {
    gap: 8px;
  }

  .kc-phase__slug {
    display: none;
  }

  .kc-mobile-controls {
    display: flex;
  }

  .kc-help {
    display: none;
  }

  .kc-stat--scene {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kc-phase__bar,
  .kc-spotlight {
    transition: none;
  }

  .kc-phase__bar::after {
    animation: none;
  }
}
