:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --ink: #14213d;
  --muted: #667085;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 20px 60px rgba(20, 33, 61, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(245, 247, 251, 0.88), rgba(245, 247, 251, 0.98)),
    repeating-linear-gradient(
      90deg,
      rgba(15, 118, 110, 0.09) 0,
      rgba(15, 118, 110, 0.09) 1px,
      transparent 1px,
      transparent 64px
    );
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef3f8;
  color: #344054;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.page-hero {
  padding: 24px 0 18px;
}

.hero-copy {
  max-width: 820px;
  margin-top: 16px;
  color: #475467;
  font-size: 1rem;
  line-height: 1.6;
}

.constraint-grid,
.option-overview {
  display: grid;
  gap: 12px;
}

.constraint-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.constraint-grid div,
.option-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.constraint-grid div {
  padding: 14px;
}

.constraint-grid strong,
.constraint-grid span,
.option-card span,
.option-card strong,
.option-card small {
  display: block;
}

.constraint-grid strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.constraint-grid span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.option-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.option-card {
  padding: 16px;
  color: inherit;
  text-decoration: none;
  transition:
    border-color 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.option-card:hover {
  border-color: #9fb3c8;
  box-shadow: 0 12px 28px rgba(20, 33, 61, 0.08);
  transform: translateY(-1px);
}

.option-card span,
.option-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.option-card strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.08rem;
}

.option-card small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.option-section {
  margin-top: 26px;
}

.option-heading {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.option-heading h2 {
  margin-top: 4px;
  font-size: 1.35rem;
}

.option-heading p:last-child {
  max-width: 900px;
  margin-top: 8px;
  line-height: 1.6;
}

.converter-tool {
  margin-top: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 22px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 33, 61, 0.08);
}

.brand-mark span {
  border-radius: 3px;
  background: var(--accent);
}

.brand-mark span:nth-child(2) {
  background: #f59e0b;
}

.brand-mark span:nth-child(3) {
  background: #2563eb;
}

.brand-mark span:nth-child(4) {
  background: #475467;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 720;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.primary-action,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 700;
}

.primary-action {
  flex: 0 0 auto;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.converter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pane {
  min-width: 0;
  background: var(--surface);
}

.pane + .pane {
  border-left: 1px solid var(--line);
}

.pane-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

label {
  color: #344054;
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ghost-button {
  min-width: 70px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: #344054;
}

.ghost-button:hover {
  border-color: #b7c3d0;
  background: #f8fafc;
}

textarea {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 0;
  padding: 22px 20px;
  color: var(--ink);
  background: transparent;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1.12rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

textarea::placeholder {
  color: #98a2b3;
}

.status-row {
  min-height: 46px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.95rem;
}

.status-row.error {
  border-color: #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}

.explainer {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 38px rgba(20, 33, 61, 0.08);
}

.explainer-heading {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 1.15rem;
  font-weight: 760;
}

h3 {
  color: #344054;
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bit-map {
  display: flex;
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bit-segment {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 16px;
  color: #ffffff;
}

.bit-segment strong {
  font-size: 1rem;
}

.bit-segment span {
  font-size: 0.9rem;
}

.timestamp-segment {
  flex: 0 0 37.5%;
  background: #2563eb;
}

.random-segment {
  flex: 1;
  background: #0f766e;
}

.snowflake-bit-map {
  display: flex;
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.snowflake-segment {
  display: flex;
  min-height: 82px;
  min-width: 82px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px;
  color: #ffffff;
}

.snowflake-segment strong {
  font-size: 0.98rem;
}

.snowflake-segment span {
  font-size: 0.86rem;
  line-height: 1.3;
}

.sign-segment {
  flex: 0.25;
  background: #475467;
}

.snow-time-segment {
  flex: 4.1;
  background: #2563eb;
}

.worker-segment {
  flex: 1;
  background: #f59e0b;
}

.sequence-segment {
  flex: 1.2;
  background: #0f766e;
}

.sequence-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.sequence-step {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.sequence-step strong {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.88rem;
}

.sequence-step span {
  display: block;
  margin-top: 10px;
  color: #475467;
  font-size: 0.86rem;
  line-height: 1.42;
}

.limits-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.limit-item {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.limit-item strong,
.limit-item span {
  display: block;
}

.limit-item strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.limit-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.tradeoffs-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.tradeoffs-panel p {
  line-height: 1.55;
}

.tradeoffs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tradeoffs-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
}

.tradeoffs-grid strong,
.tradeoffs-grid span {
  display: block;
}

.tradeoffs-grid strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.tradeoffs-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.42;
}

.explain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.snowflake-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.explain-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.explain-panel-wide {
  grid-column: 1 / -1;
}

.ulid-split,
.formula,
.decode-loop,
.alphabet-strip {
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.ulid-split {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  font-size: 1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.timestamp-text,
.random-text {
  display: inline-block;
  padding: 7px 8px;
  border-radius: 6px;
}

.timestamp-text {
  background: #eff6ff;
  color: #1d4ed8;
}

.random-text {
  background: #ecfdf5;
  color: #047857;
}

.facts-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 0;
}

.facts-list div {
  min-width: 0;
}

.facts-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.facts-list dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.fact-subvalue {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.formula {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.explain-panel p {
  line-height: 1.55;
}

.decode-loop {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.decode-loop span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 0.9rem;
}

.alphabet-strip {
  display: grid;
  grid-template-columns: repeat(32, minmax(0, 1fr));
  gap: 4px;
  margin-top: 14px;
}

.alphabet-strip span {
  display: grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  background: #ffffff;
  color: #475467;
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding: 18px 0;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .constraint-grid,
  .option-overview,
  .snowflake-grid,
  .sequence-flow {
    grid-template-columns: 1fr;
  }

  .primary-action {
    width: 100%;
  }

  .converter-grid {
    grid-template-columns: 1fr;
  }

  .pane + .pane {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  textarea {
    min-height: 190px;
    font-size: 1rem;
  }

  .explainer {
    padding: 16px;
  }

  .bit-map {
    flex-direction: column;
  }

  .snowflake-bit-map {
    flex-direction: column;
  }

  .timestamp-segment,
  .random-segment,
  .sign-segment,
  .snow-time-segment,
  .worker-segment,
  .sequence-segment {
    flex: 1 1 auto;
  }

  .explain-grid,
  .facts-list,
  .limits-grid,
  .tradeoffs-panel,
  .tradeoffs-grid {
    grid-template-columns: 1fr;
  }

  .alphabet-strip {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}
