:root {
  color-scheme: light;
  --bg: #f7fbff;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #657083;
  --line: #dce6f2;
  --accent: #2f6fed;
  --accent-strong: #1f55bd;
  --soft: #fff5d8;
  --danger: #d33a2c;
  --shadow: 0 18px 46px rgba(27, 49, 89, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: linear-gradient(135deg, #f7fbff 0%, #fffaf0 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 44px);
  background: rgba(247, 251, 255, 0.82);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  letter-spacing: 0;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, var(--ink) 7px, transparent 7px 10px, var(--ink) 10px 17px, transparent 17px),
    linear-gradient(var(--ink) 7px, transparent 7px 10px, var(--ink) 10px 17px, transparent 17px);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.top-status {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  flex: 1;
  display: grid;
  align-items: start;
  padding: 24px 0 56px;
}

.home-layout,
.creator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.58fr);
  gap: clamp(22px, 5vw, 56px);
  align-items: start;
  width: 100%;
}

.creator-head {
  position: sticky;
  top: 88px;
}

.flow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.flow-steps span,
.reader-summary span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 720;
}

.intro,
.section-head,
.empty-state,
.reader-head {
  animation: rise-in 520ms ease both;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 760;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 1.02;
  letter-spacing: 0;
}

.content-layout h1,
.empty-state h1 {
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.02;
}

.lede {
  max-width: 590px;
  margin: 22px 0 30px;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.7;
}

.lede.compact {
  margin: 14px 0 22px;
  font-size: 15px;
}

.primary-action,
.secondary-action {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  text-decoration: none;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.primary-action {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(47, 111, 237, 0.22);
  font-weight: 730;
}

.secondary-action {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 680;
}

.primary-action:hover,
.secondary-action:hover,
.icon-button:hover,
.record-button:hover {
  transform: translateY(-1px);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.button-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.qr-stage {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  animation: scale-in 360ms ease both;
}

.qr-result {
  border: 1px solid rgba(91, 111, 138, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(27, 49, 89, 0.06);
  padding: 18px;
}

.qr-frame {
  width: min(100%, 420px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 34px);
  position: relative;
  overflow: hidden;
}

.qr-frame img {
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 180ms ease;
}

.qr-frame.is-loading img {
  opacity: 0.18;
}

.qr-frame.is-loading::after {
  content: "加载中";
  position: absolute;
  inset: auto 24px 24px;
  border-radius: 8px;
  background: rgba(23, 23, 23, 0.86);
  color: #ffffff;
  padding: 10px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.qr-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.qr-meta a {
  color: var(--ink);
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.action-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action-row.left {
  justify-content: flex-start;
}

.content-layout,
.reader-layout {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px 0;
}

.editor,
.viewer,
.creator-form {
  display: grid;
  gap: 18px;
  animation: rise-in 520ms 80ms ease both;
}

.start-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.start-panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.start-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.field,
.upload-zone,
.media-editor,
.pending-panel,
.text-output,
.media-card,
.file-drop {
  border: 1px solid rgba(91, 111, 138, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(27, 49, 89, 0.06);
}

.app-panel {
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.app-panel:focus-within {
  border-color: rgba(47, 111, 237, 0.42);
  box-shadow: 0 14px 34px rgba(47, 111, 237, 0.12);
}

.field {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.field span,
.file-drop span {
  font-weight: 730;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field-head span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

textarea {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.65;
}

.upload-zone,
.media-editor,
.pending-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.zone-head h2 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.2;
}

.zone-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  transition: transform 160ms ease, background-color 160ms ease;
}

.record-button {
  min-width: 132px;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 760;
  transition: transform 160ms ease, background-color 160ms ease;
}

.record-button.recording {
  background: var(--danger);
}

.inline-upload {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.inline-upload input[type="file"] {
  min-height: 36px;
}

.icon-button.recording {
  background: var(--danger);
}

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

.file-drop {
  min-height: 128px;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 18px;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.file-drop:hover {
  border-color: rgba(47, 111, 237, 0.38);
  background: rgba(255, 255, 255, 0.96);
}

.file-drop p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.file-drop.is-dragging {
  border-color: var(--accent);
  background: rgba(47, 111, 237, 0.08);
  transform: translateY(-1px);
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.media-list,
.media-output,
.pending-list {
  display: grid;
  gap: 14px;
}

.pending-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 14px;
}

.pending-item.audio {
  grid-template-columns: 1fr;
}

.pending-detail {
  display: grid;
  gap: 5px;
}

.pending-detail strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pending-detail span {
  color: var(--muted);
}

.pending-preview {
  width: 92px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef4ff;
  overflow: hidden;
}

.pending-item.audio .pending-preview {
  width: 100%;
  aspect-ratio: auto;
  justify-content: stretch;
  background: transparent;
}

.pending-preview img,
.pending-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pending-preview audio {
  width: 100%;
}

.media-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  overflow: hidden;
}

.media-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.media-card h2,
.text-output h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  color: var(--accent-strong);
}

.media-card strong {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.media-card img,
.media-card video {
  width: 100%;
  max-height: 72vh;
  border-radius: 8px;
  object-fit: contain;
  background: #111827;
}

.media-card audio {
  width: 100%;
}

.remove-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 690;
}

.text-output {
  padding: 20px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.kid-view {
  gap: 16px;
}

.reader-card {
  background: rgba(255, 255, 255, 0.9);
}

.reader-text {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: clamp(20px, 5vw, 30px);
  line-height: 1.65;
}

.reader-head {
  margin-bottom: 18px;
  border: 1px solid rgba(91, 111, 138, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(27, 49, 89, 0.06);
  padding: 20px;
}

.reader-head h1 {
  font-size: clamp(42px, 13vw, 82px);
}

.reader-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}

.empty-line {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.empty-state {
  width: min(720px, 100%);
}

.mini-status {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.link-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.link-line .lede {
  min-width: 0;
  flex: 1 1 auto;
}

.compact-action {
  min-height: 38px;
  flex: 0 0 auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(calc(100% - 32px), 520px);
  transform: translateX(-50%);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  padding: 12px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in 220ms ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 760px) {
  .topbar {
    height: 58px;
  }

  .workspace {
    width: min(100% - 24px, 640px);
    align-items: start;
    padding: 28px 0 40px;
  }

  .home-layout,
  .creator-layout {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .creator-head {
    position: static;
  }

  h1 {
    font-size: clamp(36px, 12vw, 58px);
  }

  .lede {
    margin: 18px 0 24px;
  }

  .qr-frame {
    width: min(100%, 360px);
  }

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

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .action-row,
  .form-actions {
    width: 100%;
  }

  .form-actions {
    position: sticky;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 4;
    border: 1px solid rgba(91, 111, 138, 0.16);
    border-radius: 8px;
    background: rgba(247, 251, 255, 0.9);
    padding: 10px;
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 40px rgba(27, 49, 89, 0.14);
  }

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

  .compact-action {
    width: 100%;
  }

  .zone-head {
    align-items: flex-start;
  }

  .record-button {
    width: 128px;
  }

  .pending-item {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .pending-preview {
    width: 78px;
  }
}
