:root {
  color-scheme: light;
  --page: #fffafb;
  --surface: #ffffff;
  --surface-soft: #fff1f6;
  --surface-field: #fff5f8;
  --ink: #26232b;
  --muted: #655d69;
  --accent: #be2046;
  --accent-hover: #a7193a;
  --accent-ink: #bd2245;
  --border: #f0dce3;
  --border-strong: #e6b5c6;
  --focus: #bd2245;
  --error-bg: #fff0f0;
  --error-ink: #a52b39;
  --error-border: #f3c4cb;
  --shadow: 0 12px 32px rgba(91, 28, 52, 0.055);
  --decor-opacity: 0.06;
  --radius-card: 34px;
  --radius-panel: 24px;
  --radius-control: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #181419;
  --surface: #231d24;
  --surface-soft: #32232c;
  --surface-field: #1b171d;
  --ink: #fff6fa;
  --muted: #c5bfc9;
  --accent: #be2046;
  --accent-hover: #a7193a;
  --accent-ink: #ffa2b7;
  --border: #463440;
  --border-strong: #725060;
  --focus: #ff9ab2;
  --error-bg: #3b2029;
  --error-ink: #ffbcc8;
  --error-border: #6e3a4b;
  --shadow: 0 16px 40px rgba(12, 4, 10, 0.18);
  --decor-opacity: 0.045;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 8% 6%, rgb(255 182 206 / 12%), transparent 48%),
    radial-gradient(ellipse at 95% 90%, rgb(255 182 206 / 9%), transparent 46%),
    var(--page);
  font-family: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
input,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
}

button:disabled,
input:disabled {
  opacity: 0.7;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

svg {
  display: block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

::selection {
  color: var(--ink);
  background: var(--border-strong);
}

:where(button, a, summary, input):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.page-decorations {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.bg-sticker {
  position: absolute;
  width: clamp(130px, 19vw, 240px);
  opacity: var(--decor-opacity);
  animation: sticker-drift 20s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.bg-sticker-one {
  top: 17%;
  left: -3%;
  --sticker-angle: -14deg;
}

.bg-sticker-two {
  top: 6%;
  right: -2%;
  --sticker-angle: 11deg;
  animation-duration: 24s;
  animation-delay: -8s;
}

.bg-sticker-three {
  right: 6%;
  bottom: -4%;
  --sticker-angle: -9deg;
  animation-duration: 26s;
  animation-delay: -14s;
}

@keyframes sticker-drift {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(var(--sticker-angle, 0deg));
  }
  50% {
    transform: translate3d(0, -12px, 0) rotate(calc(var(--sticker-angle, 0deg) + 3deg));
  }
}

.site-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1080px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding: max(28px, env(safe-area-inset-top)) 40px max(24px, env(safe-area-inset-bottom));
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
}

.site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 13px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.site-link svg {
  width: 16px;
  height: 16px;
}

.icon-button {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface);
  transition: transform 150ms var(--ease-out);
}

.icon-button:active:not(:focus-visible) {
  transform: scale(0.97);
}

.theme-icon-dark {
  display: none;
}

:root[data-theme="dark"] .theme-icon-light {
  display: none;
}

:root[data-theme="dark"] .theme-icon-dark {
  display: block;
}

.shortener-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-block: 60px 48px;
}

.tool-card {
  width: min(720px, 100%);
  padding: 32px 36px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-heading {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 64px;
  margin-bottom: 28px;
  padding-right: 84px;
}

h1 {
  margin: 0;
  font-family: "Avenir Next", "SF Pro Display", "PingFang SC", ui-rounded, system-ui, sans-serif;
  font-size: clamp(28px, 3.8vw, 36px);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.heading-sticker {
  position: absolute;
  top: 0;
  right: 0;
  width: 64px;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  --float-lift: 4px;
  --float-tilt: 1.5deg;
  animation: main-sticker-float 6.6s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes main-sticker-float {
  0%, 100% {
    transform: translate3d(0, var(--float-lift), 0) rotate(calc(var(--float-tilt) * -1));
  }
  50% {
    transform: translate3d(0, calc(var(--float-lift) * -1), 0) rotate(var(--float-tilt));
  }
}

.field-label {
  display: block;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.url-entry {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.input-shell {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 56px;
  padding-inline: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-field);
}

.input-shell:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.input-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 20px;
  color: var(--muted);
}

.input-shell input,
.custom-input input,
.result-input {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
}

.input-shell input {
  flex: 1;
  padding: 10px 0;
}

.input-shell input:focus,
.custom-input input:focus {
  outline: none;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 150ms var(--ease-out);
}

.button:active:not(:disabled):not(:focus-visible) {
  transform: scale(0.97);
}

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

.button-secondary {
  border-color: var(--border);
  color: var(--ink);
  background: var(--surface-soft);
}

.button-icon,
.button svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.form-footnote {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.field-error {
  margin: 8px 0 0;
  color: var(--error-ink);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.input-shell:has(input[aria-invalid="true"]) {
  border-color: var(--error-ink);
}

.custom-link {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.custom-link summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 44px;
  padding: 8px 0;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.custom-link summary::-webkit-details-marker {
  display: none;
}

.custom-link summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--accent-ink);
  font-size: 19px;
  line-height: 1;
}

.custom-link[open] summary::before {
  content: "−";
}

.custom-link .field-label {
  margin-top: 12px;
}

.custom-input {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding-inline: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface-field);
}

.custom-input:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.domain-prefix {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 14px;
}

.custom-input input {
  padding: 10px 0;
}

.error-panel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 24px;
  padding: 15px 18px;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-control);
  color: var(--error-ink);
  background: var(--error-bg);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.error-panel p {
  margin: 0;
}

.error-panel svg {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.result-panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface-soft);
}

.result-heading {
  margin-bottom: 16px;
}

.result-heading h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.4;
}

.result-field {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.result-input {
  flex: 1;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 16px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.result-actions > a:not(.button) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 3px;
  font-size: 13px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(720px, 100%);
  margin-inline: auto;
  padding-top: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

.footer-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 12px;
}

.footer-identity a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
}

.footer-sticker {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  --float-lift: 1px;
  --float-tilt: 1deg;
  animation: main-sticker-float 7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  animation-delay: -2s;
}

.feedback-toast {
  position: fixed;
  z-index: 5;
  right: 20px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 20px;
  width: fit-content;
  max-width: min(440px, calc(100% - 40px));
  margin-inline: auto;
  padding: 13px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.feedback-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
  .site-link:hover,
  .footer-identity a:hover,
  .custom-link summary:hover {
    color: var(--accent-ink);
  }

  .site-link:hover {
    background: var(--surface-soft);
  }

  .icon-button:hover {
    border-color: var(--border-strong);
    color: var(--accent-ink);
  }

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

  .button-secondary:hover {
    border-color: var(--border-strong);
  }
}

@media (max-width: 640px) {
  .site-shell {
    padding: max(18px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 12px;
  }

  .brand {
    flex: 1;
    gap: 9px;
  }

  .brand-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .brand-copy {
    font-size: 14px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .site-link {
    gap: 5px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .site-link svg {
    width: 14px;
    height: 14px;
  }

  .shortener-main {
    padding-block: 40px 32px;
  }

  .tool-card {
    padding: 25px 24px 28px;
  }

  .card-heading {
    min-height: 48px;
    margin-bottom: 24px;
    padding-right: 60px;
  }

  h1 {
    font-size: clamp(24px, 6.5vw, 32px);
  }

  .heading-sticker {
    width: 48px;
    height: 48px;
    --float-lift: 2px;
  }

  .url-entry,
  .result-field {
    flex-direction: column;
    gap: 12px;
  }

  .input-shell {
    min-height: 54px;
    padding-inline: 14px;
  }

  .url-entry > .button,
  .result-field > .button {
    width: 100%;
    min-height: 50px;
  }

  .result-panel {
    padding: 18px;
  }

  .result-heading {
    margin-bottom: 14px;
  }

  .result-heading h2 {
    font-size: 20px;
  }

  .result-actions {
    gap: 8px;
  }

  .result-actions .button {
    flex: 1 1 100%;
    min-height: 48px;
    padding-inline: 13px;
    font-size: 13px;
  }

  .site-footer {
    align-items: flex-start;
    gap: 12px;
  }

  .footer-identity {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .bg-sticker-three {
    right: -8%;
    bottom: 9%;
  }
}

@media (max-width: 380px) {
  .site-shell {
    padding-inline: 16px;
  }

  .tool-card {
    padding-inline: 20px;
    border-radius: 28px;
  }

  .topbar {
    gap: 8px;
  }

  .brand-copy {
    font-size: 13px;
  }

  .site-link {
    padding-inline: 5px;
    font-size: 11px;
  }

  .site-link svg {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-sticker {
    animation: none;
    transform: rotate(var(--sticker-angle, 0deg));
  }

  .heading-sticker,
  .footer-sticker {
    animation: none;
    transform: none;
  }

  .button,
  .icon-button,
  .feedback-toast {
    transition: none;
  }

  .button:active:not(:disabled):not(:focus-visible),
  .icon-button:active:not(:focus-visible),
  .feedback-toast {
    transform: none;
  }
}

@media (forced-colors: active) {
  .page-decorations,
  .heading-sticker,
  .footer-sticker {
    display: none;
  }

  .tool-card,
  .input-shell,
  .input-shell:has(input[aria-invalid="true"]),
  .custom-input,
  .result-panel,
  .result-input,
  .button,
  .icon-button,
  .feedback-toast {
    border-color: CanvasText;
    box-shadow: none;
  }

  .button-primary {
    color: ButtonText;
    background: ButtonFace;
  }
}
