:root {
  --ink: #111315;
  --muted: #666d73;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --line: #d7d8d2;
  --accent: #0f766e;
  --accent-dark: #0b4f49;
  --warning: #b45309;
  --shadow: 0 18px 60px rgba(17, 19, 21, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button,
a {
  font: inherit;
}

.shell {
  width: min(1120px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 28px) 28px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(14px, 2.5vw, 22px);
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
}

.brand img {
  flex: 0 0 auto;
  display: block;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  min-height: 28px;
  max-width: 48%;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status.error {
  border-color: rgba(180, 83, 9, 0.35);
  color: var(--warning);
}

.viewer {
  min-width: 0;
  display: grid;
  align-items: center;
}

.preview-frame {
  position: relative;
  height: clamp(280px, 62svh, 680px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.18), transparent 38%),
    linear-gradient(315deg, rgba(189, 146, 62, 0.18), transparent 42%),
    #e5e7e2;
  box-shadow: var(--shadow);
}

.preview-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.25s ease, transform 0.35s ease;
}

.preview-frame.loading img {
  opacity: 0.38;
  transform: scale(1.01);
}

.loading {
  position: absolute;
  left: 16px;
  bottom: 16px;
  min-width: 92px;
  min-height: 32px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(17, 19, 21, 0.76);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.preview-frame.loading .loading {
  opacity: 1;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(18px, 3vw, 32px);
  align-items: end;
  padding-bottom: 2px;
}

.summary {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.04;
  font-weight: 780;
}

.summary p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.segment {
  width: 190px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segment-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.segment-button.active {
  background: var(--ink);
  color: #fff;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.action-link {
  min-height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.action-link.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-link:hover {
  border-color: var(--ink);
}

.action-link.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.action-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.noscript {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 8px;
  color: var(--warning);
  background: #fff;
}

@media (max-width: 760px) {
  .shell {
    grid-template-rows: auto auto auto;
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .status {
    max-width: 100%;
  }

  .preview-frame {
    height: clamp(300px, 58svh, 560px);
  }

  .control-band {
    grid-template-columns: 1fr;
    align-items: start;
  }

  h1 {
    font-size: clamp(32px, 12vw, 48px);
  }

  .controls {
    justify-items: stretch;
    width: 100%;
  }

  .segment {
    width: 100%;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .action-link {
    min-width: 0;
    padding: 0 10px;
  }
}

@media (max-width: 420px) {
  .actions {
    grid-template-columns: 1fr;
  }
}
