:root {
  --page: #f5f6f8;
  --card: #ffffff;
  --ink: #242933;
  --muted: #8b929e;
  --line: #dfe3e9;
  --primary: #4968d8;
  --primary-dark: #3d59c2;
  --soft-blue: #f4f6ff;
  --danger: #de665e;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

.main-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  width: min(100% - 32px, 680px);
  margin: 0 auto;
  padding: clamp(76px, 13vh, 132px) 0 70px;
  text-align: center;
}

.tool-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 22px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  box-shadow: 0 7px 18px rgba(73, 104, 216, .2);
  animation: fade-up .45s both ease-out;
}

h1 {
  margin: 0;
  font-size: clamp(29px, 4vw, 38px);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: 1.2;
  animation: fade-up .45s .06s both ease-out;
}

h1 span { color: var(--primary); }

.subtitle {
  margin: 12px 0 36px;
  color: var(--muted);
  font-size: 14px;
  animation: fade-up .45s .12s both ease-out;
}

.shortener {
  width: 100%;
  padding: 30px 32px 31px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 35px rgba(38, 47, 66, .055);
  text-align: left;
  animation: fade-up .5s .18s both ease-out;
}

label {
  display: block;
  margin-bottom: 10px;
  color: #555e6b;
  font-size: 13px;
  font-weight: 600;
}

.input-row, .result-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-row {
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}

.input-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(73, 104, 216, .1); }
.input-row.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(222, 102, 94, .1); }

#url-input, #short-link {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

#url-input::placeholder { color: #a9afb8; }

#generate-button, .copy-button {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 19px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background .2s, border-color .2s, transform .2s;
}

#generate-button:hover, .copy-button:hover { border-color: var(--primary-dark); background: var(--primary-dark); transform: translateY(-1px); }
#generate-button:active, .copy-button:active { transform: translateY(0); }
#generate-button.is-loading { pointer-events: none; opacity: .65; }

.field-hint {
  min-height: 16px;
  margin: 9px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.field-hint.is-error { color: var(--danger); }

.expiry-label { margin-top: 20px; }

#expires-in-days {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  transition: border-color .2s, box-shadow .2s;
}

#expires-in-days:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(73, 104, 216, .1); }
.expiry-hint { margin: 9px 0 0; color: var(--muted); font-family: var(--mono); font-size: 10px; }

.result-panel {
  margin-top: 25px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  animation: fade-up .3s both ease-out;
}

.result-title { margin-bottom: 10px; color: #555e6b; font-size: 13px; font-weight: 600; }
.result-row { padding: 5px; border: 1px solid #d7def7; border-radius: 7px; background: var(--soft-blue); }
#short-link { overflow: hidden; color: var(--primary); font-family: var(--mono); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.result-source { overflow: hidden; margin: 10px 4px 0; color: var(--muted); font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.site-footer {
  padding: 0 24px 28px;
  color: #a4aab4;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .05em;
  text-align: center;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: calc(100% - 40px);
  padding: 11px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}

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

@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 520px) {
  .main-content { padding-top: 58px; }
  .shortener { padding: 24px 18px 25px; }
  .input-row, .result-row { gap: 6px; }
  #generate-button, .copy-button { padding: 0 13px; }
  #url-input, #short-link { padding: 0 7px; font-size: 12px; }
}

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