:root {
  --ink: #0b1c24;
  --ink-soft: #1d3a46;
  --paper: #f5fbfd;
  --accent: #0f9d8a;
  --accent-deep: #0b6f62;
  --warn: #d97706;
  --line: rgba(11, 28, 36, 0.12);
  --shadow: 0 20px 48px rgba(11, 28, 36, 0.12);
  --radius: 18px;
  --font-display: "Syne", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 157, 138, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(56, 189, 248, 0.16), transparent 55%),
    linear-gradient(180deg, #e8f4f7 0%, #f5fbfd 45%, #eef6f3 100%);
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.5;
  animation: drift 16s ease-in-out infinite alternate;
}

.orb-a {
  width: 40vw;
  height: 40vw;
  left: -10vw;
  top: -12vw;
  background: radial-gradient(circle at 30% 30%, #5eead4, transparent 70%);
}

.orb-b {
  width: 34vw;
  height: 34vw;
  right: -8vw;
  bottom: 8vh;
  background: radial-gradient(circle at 60% 40%, #7dd3fc, transparent 70%);
  animation-delay: -5s;
}

.grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(11, 28, 36, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 28, 36, 0.035) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 80%);
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2vw, 2vh, 0) scale(1.06);
  }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(8vh + var(--safe-top) + 8px) 0 calc(6vh + var(--safe-bottom));
}

.hero {
  animation: rise 0.7s ease both;
}

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

.brand {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 10vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.headline {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4.2vw, 1.75rem);
  font-weight: 700;
  color: var(--ink-soft);
}

.sub {
  margin: 0 0 28px;
  max-width: 34em;
  font-size: clamp(0.95rem, 3.4vw, 1.02rem);
  line-height: 1.55;
  color: rgba(11, 28, 36, 0.7);
}

.paste-form {
  display: grid;
  gap: 12px;
}

.paste-box {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.paste-box textarea {
  width: 100%;
  border: 0;
  outline: none;
  resize: vertical;
  min-height: 88px;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  padding: 8px 4px;
  color: var(--ink);
}

.paste-box textarea::placeholder {
  color: rgba(11, 28, 36, 0.38);
}

.paste-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.paste-actions .ghost,
.paste-actions .primary {
  width: 100%;
  min-height: 48px;
  font-size: 1.02rem;
}

button,
.linkish {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 44px;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:hover,
.linkish:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary {
  background: var(--accent);
  color: #f3fffc;
}

.primary:hover {
  background: var(--accent-deep);
}

.ghost {
  background: rgba(11, 28, 36, 0.06);
  color: var(--ink);
}

.hint {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(11, 28, 36, 0.52);
  line-height: 1.45;
  word-break: break-word;
}

.status,
.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  bottom: auto;
  transform: translateX(-50%);
  z-index: 50;
  width: min(920px, calc(100% - 24px));
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(11, 28, 36, 0.18);
  font-size: 0.95rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: toast-in 0.28s ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.status.error,
.toast.error {
  border-color: rgba(217, 119, 6, 0.45);
  color: #92400e;
  background: rgba(255, 247, 237, 0.98);
}

.status.ok,
.toast.ok {
  border-color: rgba(15, 157, 138, 0.4);
  color: #0b6f62;
  background: rgba(240, 253, 250, 0.98);
}

.result {
  margin-top: 28px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

.result-head {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.cover {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 14px;
  background: #d9ebe8;
}

.result h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4vw, 1.3rem);
  line-height: 1.3;
  word-break: break-word;
}

.meta {
  margin: 0;
  color: rgba(11, 28, 36, 0.6);
  font-size: 0.95rem;
  word-break: break-word;
}

.caption-block {
  margin: 0 0 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(245, 251, 253, 0.75);
}

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

.caption-head .quality-label {
  margin: 0;
}

.caption-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  color: rgba(11, 28, 36, 0.82);
  font-size: 0.95rem;
  max-height: 9.5em;
  overflow: auto;
}

button.sm,
.ghost.sm {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.paste-box.paste-target,
.paste-box:has(textarea.paste-target) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 157, 138, 0.25), var(--shadow);
}

textarea.paste-target {
  caret-color: var(--accent);
}

.share-hint {
  margin-top: 10px;
}

.quality-label {
  margin: 0 0 10px;
  font-weight: 700;
}

.quality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quality-item {
  border: 1px solid var(--line);
  background: rgba(245, 251, 253, 0.9);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  min-height: 44px;
}

.quality-item.active {
  background: var(--accent);
  border-color: transparent;
  color: #f3fffc;
}

.quality-item .size {
  margin-left: 6px;
  opacity: 0.75;
  font-weight: 500;
  font-size: 0.86em;
}

.actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.linkish {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.foot {
  margin-top: 48px;
  color: rgba(11, 28, 36, 0.52);
  font-size: 0.9rem;
  line-height: 1.5;
}

.foot a {
  color: var(--accent-deep);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 720px) {
  .shell {
    width: calc(100% - 24px);
    padding: calc(4.5vh + var(--safe-top) + 8px) 0 calc(4vh + var(--safe-bottom));
  }

  .sub {
    margin-bottom: 20px;
  }

  .paste-box {
    padding: 12px;
    border-radius: 16px;
  }

  .paste-box textarea {
    min-height: 96px;
  }

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

  .result {
    margin-top: 18px;
    padding: 16px;
  }

  .result-head {
    grid-template-columns: 88px 1fr;
    gap: 12px;
    align-items: start;
  }

  .cover {
    width: 88px;
    height: 88px;
    border-radius: 12px;
  }

  .quality-list {
    gap: 8px;
  }

  .quality-item {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
    justify-content: center;
  }

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

  .actions .primary,
  .actions .linkish,
  .actions #shareXBtn {
    width: 100%;
  }

  .foot {
    margin-top: 32px;
    font-size: 0.84rem;
  }

  .orb {
    opacity: 0.35;
    filter: blur(36px);
  }
}

@media (max-width: 420px) {
  .shell {
    width: calc(100% - 16px);
  }

  .brand {
    font-size: clamp(2.1rem, 12vw, 2.8rem);
  }

  .result-head {
    grid-template-columns: 1fr;
  }

  .cover {
    width: 100%;
    height: min(42vw, 180px);
  }

  .quality-item {
    flex: 1 1 100%;
  }
}

@media (hover: none) {
  button:hover,
  .linkish:hover {
    transform: none;
  }

  .primary:active {
    background: var(--accent-deep);
  }

  .ghost:active,
  .quality-item:active {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .hero,
  .status,
  .toast,
  .result {
    animation: none !important;
  }
}
