:root {
  color-scheme: light;
  --paper: #f5f5f2;
  --surface: #ffffff;
  --ink: #17191d;
  --muted: #767b84;
  --line: #c8ccd2;
  --accent: #3157e8;
  --accent-dark: #2445be;
  --error: #b83838;
  --shadow: 0 18px 50px rgba(24, 28, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 25, 29, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 29, 0.028) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
}

.shortener {
  width: min(100%, 720px);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.title-mark {
  width: 9px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--accent);
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 6vw, 3.35rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.shortener-form,
.result {
  position: relative;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
.result-box {
  width: 100%;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

input {
  min-width: 0;
  padding: 0 18px;
  color: var(--ink);
  font-size: 1rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder {
  color: #979ba3;
}

input:hover {
  border-color: #9da2ab;
}

input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 87, 232, 0.14), var(--shadow);
}

button {
  height: 58px;
  padding: 0 25px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: #ffffff;
  background: var(--accent);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 9px 22px rgba(49, 87, 232, 0.2);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(49, 87, 232, 0.25);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(49, 87, 232, 0.24);
  outline-offset: 3px;
}

.form-message {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--error);
  font-size: 0.875rem;
}

.result {
  margin-top: 29px;
}

.result[hidden] {
  display: none;
}

.result-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-box {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 18px;
  box-shadow: 0 14px 38px rgba(24, 28, 38, 0.065);
  --press-contact: 18px;
  --press-one: 29%;
  --press-one-release: 25%;
  --press-two: 34%;
  --press-two-release: 30%;
  --press-three: 42%;
  --press-settle: 40%;
}

.result-text {
  display: block;
  max-width: calc(100% - 6px);
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform-origin: left center;
}

.press-bar {
  position: absolute;
  top: 9px;
  right: -13px;
  width: 7px;
  height: 40px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: -2px 0 8px rgba(49, 87, 232, 0.22);
  opacity: 0;
}

.result.is-animating .result-text {
  animation: squeeze-text 4.25s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.result.is-animating .press-bar {
  animation: press-in 4.25s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

.success-note {
  margin: 10px 0 0;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-style: italic;
  opacity: 0;
  transform: translateY(5px);
}

.result.is-complete .success-note {
  animation: note-in 380ms ease forwards;
}

@keyframes squeeze-text {
  0%, 22% { transform: scaleX(1) translateX(0); }
  31% { transform: scaleX(0.86) translateX(-2px); }
  38% { transform: scaleX(0.92) translateX(-1px); }
  47% { transform: scaleX(0.82) translateX(-3px); }
  54%, 76% { transform: scaleX(0.88) translateX(-2px); }
  86% { transform: scaleX(0.72) translateX(-5px); }
  93% { transform: scaleX(0.77) translateX(-4px); }
  100% { transform: scaleX(0.74) translateX(-5px); }
}

@keyframes press-in {
  0% { right: -13px; opacity: 0; }
  5% { opacity: 1; }
  22% { right: var(--press-contact); opacity: 1; }
  31% { right: var(--press-one); }
  38% { right: var(--press-one-release); }
  47% { right: var(--press-two); }
  54%, 76% { right: var(--press-two-release); }
  86% { right: var(--press-three); }
  93% { right: var(--press-settle); }
  100% { right: var(--press-settle); opacity: 1; }
}

@keyframes note-in {
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 560px) {
  .page-shell {
    place-items: start center;
    padding: 18vh 18px 40px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .result {
    margin-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
