:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-muted: #f1f5f7;
  --ink: #14201d;
  --muted: #66747f;
  --line: #d9e2e6;
  --line-strong: #bdcbd3;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --accent-soft: #dff3ef;
  --amber: #9a5a06;
  --blue: #24577a;
  --code: #101820;
  --code-line: #273443;
  --shadow: 0 18px 42px rgba(20, 32, 29, 0.08);
  --shadow-soft: 0 8px 22px rgba(20, 32, 29, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #edf3f4 0, rgba(245, 247, 248, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 56px;
  padding: 0 max(20px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(189, 203, 211, 0.72);
  background: rgba(245, 247, 248, 0.92);
  backdrop-filter: blur(16px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0;
}

.nav {
  gap: 4px;
  font-size: 13px;
}

.nav a {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: #e8eef1;
  color: var(--ink);
  text-decoration: none;
}

.app-shell,
.docs-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 88px;
}

.control-panel,
.content-grid,
.api-strip,
.friend-links,
.docs-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 440px);
  align-items: end;
  gap: 24px;
  padding: 22px;
}

.console-heading {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.06;
}

h2 {
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.28;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-muted);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  color: var(--ink);
  font-size: 15px;
}

.quick-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

select,
button {
  min-height: 42px;
  border-radius: 7px;
}

select {
  width: 100%;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 18px top 18px / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 13px top 18px / 7px 7px no-repeat,
    #fff;
  color: var(--ink);
  appearance: none;
}

button {
  padding: 0 15px;
  font-weight: 850;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  min-width: 108px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.16);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--accent-strong);
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat-card {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.stat-card strong {
  display: block;
  margin-bottom: 7px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.stat-card:hover:not(:disabled) {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.stat-card.active {
  border-color: rgba(15, 118, 110, 0.6);
  background: var(--accent-soft);
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.12);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(430px, 1.1fr);
  overflow: hidden;
}

.image-card,
.prompt-card {
  padding: 20px;
}

.image-card {
  border-right: 1px solid var(--line);
  background: var(--panel-muted);
}

.card-header,
.result-meta,
.prompt-toolbar,
.prompt-actions,
.link-row,
.statusbar,
.api-strip {
  display: flex;
  align-items: center;
}

.card-header,
.result-meta,
.prompt-toolbar,
.statusbar,
.api-strip {
  justify-content: space-between;
  gap: 14px;
}

.card-header,
.prompt-toolbar {
  margin-bottom: 12px;
  font-weight: 900;
}

.card-header > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-link {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 13px;
}

.muted,
.statusbar,
.detail-row {
  color: var(--muted);
}

.image-frame {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 480px;
  max-height: 680px;
  aspect-ratio: 4 / 5;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(20, 32, 29, 0.045) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(0deg, rgba(20, 32, 29, 0.045) 1px, transparent 1px) 0 0 / 18px 18px,
    #e8eef1;
}

.image-frame::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.68);
}

.image-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.image-frame.has-image img {
  display: block;
}

.image-frame.has-image .empty-state {
  display: none;
}

.empty-state {
  max-width: 220px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.result-meta {
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #075e54;
  font-size: 13px;
  font-weight: 850;
}

.link-row,
.prompt-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -6px;
  font-size: 12px;
  font-weight: 750;
}

.detail-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-muted);
}

#promptBox,
.code-block {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--code-line);
  border-radius: 8px;
  background: var(--code);
  color: #eef6f3;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

#promptBox {
  flex: 1;
  min-height: 380px;
  max-height: 560px;
  padding: 16px;
}

.api-strip {
  margin-top: 12px;
  padding: 14px 16px;
}

.api-strip h2 {
  font-size: 18px;
}

.api-strip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.api-strip code {
  display: block;
  max-width: 100%;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-muted);
  color: var(--ink);
  font-weight: 800;
}

.friend-links {
  margin-top: 12px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

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

.friend-link-card {
  display: grid;
  gap: 6px;
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.friend-link-card:hover {
  border-color: var(--line-strong);
  text-decoration: none;
  transform: translateY(-1px);
}

.friend-link-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-link-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
}

.statusbar {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: 18px;
  min-height: 46px;
  width: min(720px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(20, 32, 29, 0.13);
  font-size: 13px;
  font-weight: 760;
}

.docs-shell {
  display: grid;
  gap: 14px;
}

.docs-card {
  padding: 24px;
}

.docs-hero p {
  max-width: 820px;
}

.docs-card p,
.docs-card li {
  color: var(--muted);
  line-height: 1.65;
}

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

.endpoint {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin-bottom: 12px;
}

.method {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
}

.endpoint-head code,
.inline-code {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--panel-muted);
  color: var(--ink);
}

.endpoint-head code {
  min-width: 0;
  overflow-wrap: anywhere;
}

.code-block {
  padding: 16px;
}

@media (max-width: 1060px) {
  .control-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .image-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .image-frame {
    min-height: 420px;
  }
}

@media (max-width: 740px) {
  body {
    background: var(--bg);
  }

  .topbar,
  .nav,
  .quick-actions,
  .api-strip,
  .section-heading,
  .statusbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    gap: 12px;
    padding: 12px;
  }

  .brand {
    width: 100%;
    min-width: 0;
  }

  .brand span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }

  .nav a {
    display: grid;
    width: auto;
    min-height: 38px;
    place-items: center;
    padding: 8px 6px;
    font-size: 12px;
    text-align: center;
  }

  .app-shell,
  .docs-shell {
    width: calc(100vw - 16px);
    padding: 8px 0 16px;
  }

  .control-panel,
  .image-card,
  .prompt-card,
  .docs-card,
  .friend-links {
    padding: 14px;
  }

  .control-panel {
    gap: 16px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.12;
  }

  h2 {
    font-size: 19px;
  }

  .metric-row {
    gap: 7px;
    margin-top: 12px;
  }

  .metric {
    flex: 1 1 130px;
    justify-content: center;
  }

  .quick-actions {
    gap: 9px;
  }

  .primary-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0;
  }

  .stat-card {
    min-height: 64px;
    padding: 10px;
  }

  .stat-card strong {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .friend-link-grid,
  .endpoint-grid {
    grid-template-columns: 1fr;
  }

  .result-meta,
  .prompt-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .link-row,
  .prompt-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .prompt-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .ghost-button {
    width: 100%;
  }

  .content-grid,
  .api-strip,
  .friend-links {
    margin-top: 10px;
  }

  .image-card,
  .prompt-card {
    padding: 14px;
  }

  .card-header {
    gap: 8px;
  }

  .image-frame {
    min-height: 240px;
    max-height: 420px;
    aspect-ratio: 1 / 1;
  }

  .detail-row {
    gap: 6px;
  }

  .detail-row span {
    min-height: 26px;
  }

  #promptBox {
    min-height: 260px;
    max-height: 430px;
    padding: 13px;
    font-size: 13px;
    line-height: 1.58;
  }

  .api-strip {
    gap: 10px;
    padding: 14px;
  }

  .api-strip code {
    width: 100%;
    font-size: 12px;
  }

  .section-heading {
    gap: 6px;
    margin-bottom: 10px;
  }

  .friend-link-card {
    min-height: 72px;
    padding: 12px;
  }

  .statusbar {
    position: static;
    width: calc(100vw - 16px);
    min-height: auto;
    margin: 0 auto 10px;
    padding: 12px 14px;
    border-radius: 8px;
  }
}

@media (max-width: 440px) {
  .stats-grid,
  .friend-link-grid,
  .endpoint-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .prompt-actions {
    grid-template-columns: 1fr;
  }

  .image-frame {
    min-height: 220px;
  }

  #promptBox {
    min-height: 240px;
  }
}
