/* URL Shortener — feuille de style unique.
   Accent : #7552CC. Deux familles : Space Grotesk (texte), JetBrains Mono (adresses). */

:root {
  --violet-50:  #F7F4FE;
  --violet-100: #EEE8FB;
  --violet-200: #DBD0F5;
  --violet-500: #7552CC;
  --violet-600: #6444B4;
  --violet-700: #4F3596;

  --canvas:   #FAF9FD;
  --surface:  #FFFFFF;
  --ink:      #1A1526;
  --ink-soft: #423A57;
  --muted:    #5F5779;
  --faint:    #948DA8;
  --line:     #E4DFEF;
  --line-soft:#F0ECF7;

  --ok:      #0F6B4A;
  --ok-bg:   #E7F5EF;
  --ok-line: #BFE4D4;
  --danger:  #A82F26;

  --r-sm: 9px;
  --r-md: 11px;
  --r-lg: 14px;
  --r-xl: 18px;

  --font-ui: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;

  --shadow-1: 0 1px 2px rgba(26, 21, 38, .05);
  --shadow-2: 0 14px 34px -16px rgba(58, 34, 110, .28);
  --ring: 0 0 0 4px var(--violet-100);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, .mono { font-family: var(--font-mono); }

::selection { background: var(--violet-200); color: var(--violet-700); }

:focus-visible { outline: 2px solid var(--violet-500); outline-offset: 2px; }

/* ---------- barre haute ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
  padding: 0 clamp(18px, 4vw, 36px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark { display: flex; color: var(--violet-500); }

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.012em;
  white-space: nowrap;
}

.host-tag {
  flex: none;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--violet-50);
  color: var(--violet-700);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -.01em;
  white-space: nowrap;
}

/* ---------- coquille ---------- */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(32px, 4.5vw, 56px) clamp(18px, 4vw, 36px) 80px;
}

.page-head {
  margin-bottom: clamp(24px, 3vw, 32px);
  max-width: 60ch;
}

h1 {
  margin: 0 0 9px;
  font-size: clamp(25px, 3.2vw, 32px);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -.026em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
  text-wrap: pretty;
}

/* ---------- les deux panneaux ---------- */

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr);
  align-items: stretch;
  gap: 20px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: #FCFBFE;
}

.panel-title {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.list-count {
  color: var(--violet-700);
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.panel-body { flex: 1 1 auto; padding: 20px 20px 22px; }
.panel-body-flush {
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* ---------- formulaire ---------- */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

input[type="text"] {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  transition: border-color .16s ease, box-shadow .16s ease;
}

input[type="text"]::placeholder { color: var(--faint); }

input[type="text"]:focus {
  outline: none;
  border-color: var(--violet-500);
  box-shadow: var(--ring);
}

input[type="text"][aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(168, 47, 38, .1);
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.hint code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--violet-50);
  color: var(--violet-700);
  font-size: 11.5px;
}

/* champ lien court : préfixe figé + saisie + relance */

.slug-wrap {
  display: flex;
  align-items: stretch;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.slug-wrap:focus-within {
  border-color: var(--violet-500);
  box-shadow: var(--ring);
}

.slug-wrap.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(168, 47, 38, .1);
}

.slug-host {
  display: flex;
  align-items: center;
  padding: 0 2px 0 14px;
  background: var(--violet-50);
  border-right: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
}

.slug-wrap input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 10px 0 12px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: -.01em;
}

.slug-wrap input:focus { outline: none; box-shadow: none; }

.slug-shuffle {
  flex: none;
  width: 46px;
  border: none;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .16s ease, color .16s ease;
}

.slug-shuffle:hover { background: var(--violet-50); color: var(--violet-600); }
.slug-shuffle:active { background: var(--violet-100); }
.slug-shuffle:focus-visible { outline: 2px solid var(--violet-500); outline-offset: -3px; }

/* ---------- boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -.005em;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .08s ease;
  white-space: nowrap;
}

.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: var(--violet-500);
  color: #fff;
  box-shadow: 0 1px 2px rgba(82, 55, 154, .3), inset 0 1px 0 rgba(255, 255, 255, .16);
}

.btn-primary:hover { background: var(--violet-600); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover { border-color: var(--violet-200); color: var(--violet-700); background: var(--violet-50); }
.btn-ghost:active { transform: translateY(1px); }

.btn-block { display: flex; width: 100%; margin-top: 22px; }

.form-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.form-error:empty { display: none; }

/* ---------- panneau de résultat ---------- */

.result { animation: rise .32s cubic-bezier(.2, .7, .3, 1) both; }

.result[hidden] { display: none; }

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}

.result-url {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: clamp(17px, 2.4vw, 20px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -.02em;
  color: var(--violet-700);
  overflow-wrap: anywhere;
}

.result-target {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn.is-copied {
  background: var(--ok);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 107, 74, .3);
}

/* ---------- liste des liens ---------- */

.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list:empty { display: none; }

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px 13px 20px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .14s ease;
  animation: rise .28s cubic-bezier(.2, .7, .3, 1) both;
}

.link-row:last-child { border-bottom: none; }
.link-row:hover { background: var(--violet-50); }

.link-main { flex: 1 1 auto; min-width: 0; }

.link-slug {
  display: block;
  max-width: 100%;
  margin: 0 0 2px;
  padding: 0;
  border: none;
  background: none;
  color: var(--violet-700);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.012em;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-slug:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-slug:focus-visible { outline: 2px solid var(--violet-500); outline-offset: 3px; border-radius: 4px; }

.link-target {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.icon-btn:hover { border-color: var(--violet-200); background: var(--violet-50); color: var(--violet-700); }
.icon-btn:focus-visible { outline: 2px solid var(--violet-500); outline-offset: 2px; }
.icon-btn.is-copied { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }

.icon-btn.danger { border-color: transparent; background: transparent; color: var(--muted); padding: 0; width: 38px; }
.icon-btn.danger:hover { background: #FCEDEB; color: var(--danger); }

/* ---------- état vide ---------- */

.empty {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  margin: 16px;
  padding: 22px 20px;
  border: 1px dashed var(--violet-200);
  border-radius: var(--r-lg);
  background: var(--violet-50);
}

.empty[hidden] { display: none; }

.empty-title {
  margin: 0 0 5px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
}

.empty-body {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- notification ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px -8px rgba(26, 21, 38, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- animation ---------- */

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

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

/* ---------- adaptatif ---------- */

@media (max-width: 880px) {
  .panels {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
}

@media (max-width: 560px) {
  input[type="text"], .slug-wrap input { font-size: 16px; }
  .slug-host { font-size: 13px; padding-left: 12px; }
  .result-actions .btn { flex: 1 1 auto; }
  .link-row { flex-wrap: wrap; padding: 12px 14px 12px 16px; }
  .link-actions { margin-left: auto; }
  .toast { left: 16px; right: 16px; transform: translateY(12px); text-align: center; }
  .toast.is-visible { transform: none; }
}
