:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #64748b;
  --paper: #ffffff;
  --line: #d7e1e8;
  --green: #45bf7f;
  --green-dark: #168a5b;
  --blue: #40add8;
  --blue-dark: #167aa4;
  --red: #ff6b72;
  --red-dark: #c4374a;
  --amber: #f59e0b;
  --violet: #7c3aed;
  --soft-green: #eef8ee;
  --shadow: 0 18px 50px rgba(30, 41, 59, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #edf7f3;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfffd 0, #edf7f3 320px, #f7fafc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.is-embed {
  background: #ffffff;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(69, 191, 127, 0.28);
  background: rgba(251, 255, 253, 0.94);
  backdrop-filter: blur(16px);
}

.header-inner {
  width: min(1120px, calc(100% - 32px));
  min-height: 118px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(320px, 0.9fr);
  gap: 28px;
  align-items: center;
}

.brand-block {
  display: grid;
  gap: 2px;
}

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #0f5138;
  font-size: clamp(2.1rem, 4vw, 4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hash-form {
  display: grid;
  gap: 9px;
}

.hash-form label {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.control-row input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.16);
}

.control-row input:focus {
  outline: 3px solid rgba(69, 191, 127, 0.23);
  border-color: var(--green);
}

.control-row button {
  min-width: 120px;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  color: #ffffff;
  background: #0f5138;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.control-row button:hover {
  transform: translateY(-1px);
  background: var(--green-dark);
}

.page-shell {
  width: min(1040px, calc(100% - 28px));
  margin: 34px auto 76px;
}

.status-panel {
  display: none;
  margin-bottom: 24px;
  border: 1px solid #cbd5e1;
  border-left: 6px solid var(--green);
  border-radius: 8px;
  padding: 18px 20px;
  background: var(--paper);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

.status-panel.is-visible {
  display: block;
}

.status-panel strong {
  display: block;
  margin-bottom: 4px;
  color: #111827;
  font-size: 1rem;
}

.status-panel p {
  margin: 0;
  color: var(--muted);
}

.part-stack {
  display: grid;
  gap: 0;
}

.part-card {
  --accent: var(--green);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.part-card[data-kind="b"],
.part-card[data-kind="l"],
.part-card[data-kind="n"] {
  --accent: var(--blue);
}

.part-card[data-kind="r"] {
  --accent: var(--red);
}

.part-card[data-kind="h"] {
  --accent: var(--green-dark);
}

.part-card[data-kind="s"] {
  --accent: var(--amber);
}

.part-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  padding: 15px 18px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 13%, #ffffff), #ffffff 72%);
}

.part-kicker {
  min-width: 40px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 5px 9px 6px;
  color: var(--accent);
  background: #ffffff;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.part-heading h2 {
  margin: 0;
  color: #111827;
  font-size: clamp(1.16rem, 2.2vw, 1.65rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.image-frame {
  padding: clamp(12px, 2.6vw, 26px);
  background: #ffffff;
}

.image-frame img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.part-card.is-error {
  border-color: rgba(255, 107, 114, 0.5);
}

.part-card.is-error .part-heading {
  background: #fff4f4;
}

.missing-box {
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed #f3a0a5;
  border-radius: 8px;
  color: #9f2534;
  background: #fff8f8;
  font-weight: 800;
  text-align: center;
}

.part-separator {
  width: 100%;
  height: 30px;
  margin: 28px 0;
  position: relative;
}

.part-separator::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #94a3b8 12%, #94a3b8 88%, transparent);
}

.part-separator::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90px;
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--red));
  transform: translate(-50%, -50%);
}

.embed-toggle {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 30;
  width: 44px;
  height: 34px;
  border: 1px solid rgba(15, 81, 56, 0.18);
  border-radius: 8px;
  color: rgba(15, 81, 56, 0.72);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  transition: opacity 160ms ease, transform 160ms ease, color 160ms ease, border-color 160ms ease;
}

.embed-toggle:hover,
.embed-toggle:focus-visible {
  opacity: 1;
  color: #0f5138;
  border-color: rgba(15, 81, 56, 0.45);
  outline: none;
  transform: translateY(-1px);
}

.embed-panel {
  position: fixed;
  right: 14px;
  bottom: 56px;
  z-index: 31;
  width: min(390px, calc(100% - 28px));
  display: none;
}

.embed-panel.is-open {
  display: block;
}

.embed-panel-inner {
  border: 1px solid rgba(69, 191, 127, 0.32);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 54px rgba(15, 23, 42, 0.2);
}

.embed-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.embed-panel-head h2 {
  margin: 0;
  color: #0f5138;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.embed-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: #64748b;
  background: #f1f5f9;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.embed-close:hover,
.embed-close:focus-visible {
  color: #0f5138;
  outline: 2px solid rgba(69, 191, 127, 0.24);
}

.embed-panel textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  color: #1f2937;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.embed-panel textarea:focus {
  outline: 3px solid rgba(69, 191, 127, 0.22);
  border-color: var(--green);
}

.embed-copy {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #0f5138;
  cursor: pointer;
  font-weight: 800;
}

.embed-copy:hover,
.embed-copy:focus-visible {
  outline: none;
  background: var(--green-dark);
}

.embed-feedback {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

body.is-embed .app-header,
body.is-embed .embed-toggle,
body.is-embed .embed-panel {
  display: none !important;
}

body.is-embed .page-shell {
  width: 100%;
  margin: 0;
}

body.is-embed .part-card {
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  box-shadow: none;
}

body.is-embed .part-card:first-child {
  border-top: 0;
}

body.is-embed .part-heading {
  padding: 12px 16px;
}

body.is-embed .image-frame {
  padding: 12px;
}

body.is-embed .part-separator {
  height: 20px;
  margin: 18px 0;
}

@media (max-width: 720px) {
  .header-inner {
    min-height: 150px;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 0;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .control-row button {
    width: 100%;
  }

  .page-shell {
    width: min(100% - 18px, 1040px);
    margin-top: 18px;
  }

  .part-heading {
    align-items: flex-start;
  }

  .image-frame {
    padding: 10px;
  }

  .embed-toggle {
    right: 10px;
    bottom: 10px;
  }

  .embed-panel {
    right: 10px;
    bottom: 50px;
    width: calc(100% - 20px);
  }
}
