:root {
  --page: #fffaf4;
  --page-deep: #f8eadb;
  --paper: #ffffff;
  --ink: #35180b;
  --ink-soft: #584033;
  --muted: #7a6d64;
  --line: #eedfce;
  --orange: #ff8a22;
  --orange-deep: #ad480c;
  --gold: #ffb914;
  --cream: #fff2df;
  --shadow-soft: 0 10px 24px rgba(104, 68, 33, 0.09);
  --shadow-card: 0 16px 34px rgba(103, 65, 29, 0.12);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "HarmonyOS Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 100% 12%, rgba(255, 196, 78, 0.16), transparent 26%),
    linear-gradient(180deg, var(--page) 0%, #fff6eb 55%, var(--page-deep) 100%);
}
button, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(255, 138, 34, 0.28); outline-offset: 3px; }

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(28px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 4px;
}
.page-title { min-width: 0; text-align: center; }
.page-title span { display: block; color: #a45b28; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.page-title h1 { margin: 4px 0 0; color: var(--ink); font-size: 20px; font-weight: 800; line-height: 1.2; }
.back-button, .history-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #f0dfca;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #4b3020;
  background: #fffaf2;
  box-shadow: 0 8px 18px rgba(103, 69, 36, 0.09);
  cursor: pointer;
}
.back-button { text-decoration: none; }
.history-button { justify-self: end; }
.back-button svg, .history-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.intro {
  position: relative;
  min-height: 190px;
  margin-top: 4px;
  padding: 20px 16px 15px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  grid-template-rows: 1fr auto;
  gap: 12px 8px;
  background:
    radial-gradient(circle at 86% 15%, rgba(255,255,255,.5), transparent 20%),
    linear-gradient(135deg, #ffe28a 0%, #ffca45 52%, #ffad19 100%);
  border: 2px solid rgba(255,255,255,.96);
  border-radius: 28px;
  box-shadow: 0 14px 28px rgba(187, 112, 16, 0.16), inset 0 0 0 1px rgba(255,255,255,.36);
}
.intro::after {
  position: absolute;
  right: -36px;
  bottom: -68px;
  width: 150px;
  height: 150px;
  border: 24px solid rgba(255,255,255,.11);
  border-radius: 50%;
  content: "";
}
.intro-copy { position: relative; z-index: 2; min-width: 0; }
.eyebrow { margin: 0 0 6px; color: #a74710; font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.intro h2 { margin: 0; color: #3e1b0c; font-size: 27px; font-weight: 800; line-height: 1.16; letter-spacing: -.5px; }
.intro h2 span { color: #f26700; }
.intro-copy > p:last-child { max-width: 205px; margin: 8px 0 0; color: #714721; font-size: 12px; font-weight: 600; line-height: 1.5; }
.intro-robot {
  position: relative;
  z-index: 2;
  width: 118px;
  height: 118px;
  align-self: center;
  object-fit: cover;
  border: 5px solid rgba(255,255,255,.92);
  border-radius: 34px;
  box-shadow: 0 14px 24px rgba(133, 75, 11, .2);
  transform: rotate(2deg);
}
.platforms { position: relative; z-index: 2; grid-column: 1 / -1; display: flex; gap: 7px; flex-wrap: wrap; }
.platform {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 9px 4px 5px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 999px;
  color: #4c2c17;
  background: rgba(255,255,255,.82);
  box-shadow: 0 5px 12px rgba(126,75,20,.08);
  font-size: 11px;
  font-weight: 700;
}
.platform i { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 7px; color: white; font-style: normal; font-weight: 900; }
.douyin i { background: #17191f; text-shadow: 2px 0 #24e0d5, -2px 0 #ff3157; }
.kuaishou i { background: #ff6b35; }
.rednote i { background: #ff3157; }

.input-card, .result-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-card);
}
.input-card { position: relative; margin-top: 14px; padding: 18px; }
.card-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-label-row label { color: #3d2619; font-size: 15px; font-weight: 800; }
.clear-button { padding: 4px; border: 0; color: #a56d48; background: transparent; font-size: 12px; cursor: pointer; }
.input-wrap { position: relative; }
textarea {
  width: 100%;
  resize: none;
  border: 1.5px solid #ead9c5;
  border-radius: 18px;
  color: #3e2c20;
  background: #fffaf3;
  line-height: 1.65;
  transition: border-color .2s, box-shadow .2s;
}
#shareText { min-height: 128px; padding: 14px 118px 40px 15px; font-size: 14px; }
textarea::placeholder { color: #aa9d92; }
textarea:focus { border-color: #ee9a48; box-shadow: 0 0 0 4px rgba(255,138,34,.1); outline: 0; }
.platform-detected { position: absolute; left: 11px; bottom: 10px; padding: 4px 8px; border-radius: 9px; color: #a64a11; background: #fff0da; font-size: 11px; font-weight: 800; }
.paste-button {
  position: absolute;
  right: 27px;
  top: 61px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #a74710;
  background: #fff0d7;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.paste-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.extract-button {
  width: 100%;
  min-height: 52px;
  margin-top: 13px;
  padding: 0 17px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: white;
  background: linear-gradient(135deg, #ff8d24, #df670d);
  box-shadow: 0 10px 20px rgba(213, 93, 8, .22);
  font-weight: 800;
  cursor: pointer;
  transition: transform .2s, opacity .2s;
}
.extract-button:not(:disabled):active { transform: scale(.985); }
.extract-button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.extract-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.privacy-note { margin: 11px 0 0; display: flex; justify-content: center; align-items: flex-start; gap: 6px; color: #84776d; font-size: 11px; line-height: 1.55; text-align: left; }
.privacy-note svg { flex: 0 0 14px; width: 14px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.example-link { display: block; margin: 15px auto 4px; padding: 7px; border: 0; color: #b85619; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }

.status-card {
  margin-top: 14px;
  padding: 16px 17px;
  border: 1px solid #f0d4a8;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 13px;
  background: #fff8e8;
  box-shadow: var(--shadow-soft);
}
.status-card strong { color: #4b2c18; font-size: 14px; }
.status-card p { margin: 4px 0 0; color: #8b735f; font-size: 12px; }
.status-orbit { width: 36px; height: 36px; flex: 0 0 auto; border: 3px solid #ffe1a6; border-top-color: var(--orange); border-radius: 50%; animation: spin 1s linear infinite; }
.status-orbit span { display: block; width: 7px; height: 7px; margin: 0 0 0 23px; border-radius: 50%; background: var(--gold); }
@keyframes spin { to { transform: rotate(360deg); } }

.result-card { margin-top: 14px; padding: 20px 18px 18px; animation: rise .42s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.result-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.result-heading h2 { margin: 0; color: #3c2417; font-size: 24px; font-weight: 800; }
.result-platform { padding: 6px 10px; border: 1px solid #f3dcc0; border-radius: 999px; color: #a64a11; background: #fff2df; font-size: 11px; font-weight: 800; }
.source-meta { display: flex; gap: 12px; margin: 9px 0 14px; color: #96877c; font-size: 11px; }
.source-meta span:empty { display: none; }
.copy-paper { position: relative; overflow: hidden; border: 1px solid #ead9c5; border-radius: 18px; background: #fffaf3; box-shadow: inset 0 1px 0 rgba(255,255,255,.9); }
.copy-paper label { display: block; padding: 13px 14px 0; color: #9a775b; font-size: 11px; font-weight: 800; }
#resultCopy { position: relative; z-index: 1; min-height: 175px; padding: 8px 14px 14px; border: 0; background: transparent; font-size: 14px; line-height: 28px; }
.paper-lines { position: absolute; inset: 39px 0 0; background: repeating-linear-gradient(transparent 0 27px, rgba(180,137,93,.13) 27px 28px); pointer-events: none; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.tags:empty { display: none; }
.tags span { padding: 6px 9px; border: 1px solid #f1dfc9; border-radius: 999px; color: #8b552e; background: #fff3e3; font-size: 11px; }
.result-actions { margin-top: 17px; display: grid; grid-template-columns: 1.35fr .85fr; gap: 9px; }
.result-actions button { min-height: 47px; border-radius: 15px; font-weight: 800; cursor: pointer; }
.copy-button { border: 0; display: flex; align-items: center; justify-content: center; gap: 7px; color: white; background: linear-gradient(135deg, #bc550f, #9e3e08); box-shadow: 0 9px 18px rgba(159,67,11,.18); }
.copy-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.again-button { border: 1px solid #eadac7; color: #6a4630; background: #fffaf4; }

footer { padding: 28px 0 4px; color: #9c8f85; text-align: center; font-size: 10px; }
footer span { color: #a64d19; font-weight: 800; }

.history-sheet {
  width: min(calc(100% - 16px), 430px);
  max-height: 72vh;
  margin: auto auto 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid #ecdcc9;
  border-radius: 28px 28px 0 0;
  color: var(--ink);
  background: #fffaf4;
  box-shadow: 0 -20px 60px rgba(79,49,23,.18);
}
.history-sheet::backdrop { background: rgba(74,45,22,.3); backdrop-filter: blur(3px); }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 16px; border-radius: 4px; background: #e4d6c7; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; }
.sheet-title h2 { margin: 0; color: #3d2416; font-size: 19px; }
.sheet-title button { width: 38px; height: 38px; border: 1px solid #edddca; border-radius: 50%; background: white; font-size: 22px; cursor: pointer; }
.history-list { margin: 14px 0; display: grid; gap: 8px; overflow: auto; }
.history-item { width: 100%; padding: 13px; border: 1px solid #ebdccb; border-radius: 15px; display: grid; gap: 5px; text-align: left; background: white; cursor: pointer; }
.history-item strong { overflow: hidden; color: #4a3021; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.history-item span, .history-empty { color: #94867b; font-size: 11px; }
.history-empty { padding: 32px 0; text-align: center; }
.clear-history { width: 100%; padding: 12px; border: 0; color: #c25522; background: transparent; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; max-width: calc(100% - 40px); padding: 11px 16px; border-radius: 999px; color: white; background: rgba(73,42,22,.94); box-shadow: 0 10px 24px rgba(73,42,22,.2); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .app-shell { padding-inline: 12px; }
  .intro { grid-template-columns: minmax(0, 1fr) 104px; padding-inline: 14px; }
  .intro h2 { font-size: 25px; }
  .intro-robot { width: 103px; height: 103px; border-radius: 30px; }
  .platform { padding-right: 7px; }
  .input-card { padding-inline: 15px; }
  .paste-button { right: 24px; }
}
@media (min-width: 700px) { body { background: radial-gradient(circle at 20% 8%, #fff0cf, transparent 32%), radial-gradient(circle at 80% 88%, #f6dfc8, transparent 29%), var(--page); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
