:root{
  --bg: #f6f7fb;

  --card: rgba(255,255,255,.82);
  --card2: rgba(255,255,255,.66);
  --stroke: rgba(16,24,40,.12);

  --text: rgba(16,24,40,.92);
  --muted: rgba(16,24,40,.62);
  --muted2: rgba(16,24,40,.48);

  --shadow: 0 20px 60px rgba(16,24,40,.12);
  --radius: 18px;
  --radius2: 14px;

  --focus: 0 0 0 4px rgba(17, 110, 255, .18);

  --field-bg: rgba(255,255,255,.80);
  --field-bg-focus: rgba(255,255,255,.94);
  --field-border: rgba(16,24,40,.14);
  --field-border-focus: rgba(17,110,255,.45);

  --ghost-bg: rgba(255,255,255,.60);
  --chip-bg: rgba(255,255,255,.70);

  --surface-bg: rgba(255,255,255,.72);
  --surface-border: rgba(16,24,40,.10);
  --dash-border: rgba(16,24,40,.16);

  --toast-bg: rgba(255,255,255,.75);
  --toast-border: rgba(16,24,40,.12);

  --noise-blend: multiply;
  --noise-opacity: .10;
  --orb-opacity: .22;

  --g1: rgba(103, 70, 255,.16);
  --g2: rgba(0, 176, 255,.12);
  --g3: rgba(255, 90, 180,.10);

  color-scheme: light;
}


html[data-theme="dark"]{
  --bg: #0b0f18;

  --card: rgba(255,255,255,.06);
  --card2: rgba(255,255,255,.04);
  --stroke: rgba(255,255,255,.10);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.62);
  --muted2: rgba(255,255,255,.45);

  --shadow: 0 20px 60px rgba(0,0,0,.55);

  --focus: 0 0 0 4px rgba(255,255,255,.10);

  --field-bg: rgba(0,0,0,.18);
  --field-bg-focus: rgba(0,0,0,.24);
  --field-border: rgba(255,255,255,.14);
  --field-border-focus: rgba(255,255,255,.22);

  --ghost-bg: rgba(255,255,255,.04);
  --chip-bg: rgba(255,255,255,.06);

  --surface-bg: rgba(0,0,0,.16);
  --surface-border: rgba(255,255,255,.10);
  --dash-border: rgba(255,255,255,.18);

  --toast-bg: rgba(0,0,0,.40);
  --toast-border: rgba(255,255,255,.14);

  --noise-blend: overlay;
  --noise-opacity: .35;
  --orb-opacity: .30;

  --g1: rgba(127, 90, 240,.20);
  --g2: rgba(0, 209, 255,.16);
  --g3: rgba(255, 90, 180,.12);

  color-scheme: dark;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  overflow-x:hidden;
}

.bg{
  position:fixed; inset:0; z-index:-3;
  background:
    radial-gradient(1200px 800px at 18% 10%, var(--g1), transparent 55%),
    radial-gradient(1200px 800px at 82% 20%, var(--g2), transparent 55%),
    radial-gradient(1200px 800px at 55% 88%, var(--g3), transparent 60%),
    var(--bg);
}

.noise{
  position:fixed; inset:0; z-index:-2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
  mix-blend-mode: var(--noise-blend);
  opacity: var(--noise-opacity);
}

.orb{
  position:fixed; width:520px; height:520px; border-radius:999px;
  filter: blur(44px);
  z-index:-1;
  opacity: var(--orb-opacity);
  animation: float 10s ease-in-out infinite;
}
.orb1{ left:-140px; top:-160px; background: radial-gradient(circle at 30% 30%, rgba(127,90,240,.9), rgba(127,90,240,0) 65%); }
.orb2{ right:-160px; top:-80px; background: radial-gradient(circle at 30% 30%, rgba(0,209,255,.9), rgba(0,209,255,0) 65%); animation-delay: -3s; }
.orb3{ left:28%; bottom:-220px; background: radial-gradient(circle at 30% 30%, rgba(255,90,180,.7), rgba(255,90,180,0) 65%); animation-delay: -6s; }

@keyframes float{
  0%,100% { transform: translate3d(0,0,0) scale(1); }
  50%     { transform: translate3d(0,22px,0) scale(1.02); }
}

.wrap{
  width:min(980px, 92vw);
  margin: 40px auto 36px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 4px;
}

.logo{ display:flex; align-items:center; gap:12px; }
.logoMark{
  width:44px; height:44px; border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.06));
  border:1px solid var(--stroke);
  box-shadow: 0 10px 25px rgba(0,0,0,.14);
  font-weight:800;
}
.brand{ font-weight:800; letter-spacing:.2px; }
.tagline{ color: var(--muted2); font-size: 13px; margin-top:2px; }

.headerActions{ display:flex; align-items:center; gap:10px; }

.ghost{
  width:42px; height:42px;
  display:grid; place-items:center;
  border-radius:14px;
  border:1px solid var(--stroke);
  background: var(--ghost-bg);
  color: var(--text);
  text-decoration:none;
  transition: transform .12s ease, background .12s ease;
  cursor:pointer;
  padding:0;
  outline:none;
  -webkit-tap-highlight-color: transparent;
}
.ghost:hover{ transform: translateY(-1px); }
.ghost:focus-visible{ box-shadow: var(--focus); }
.ghost:active{ transform: translateY(0px); }

.icon{ display:block; }
html[data-theme="dark"] .iconSun{ display:none; }
html[data-theme="light"] .iconMoon{ display:none; }

.card{
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  backdrop-filter: blur(10px);
}

.cardSecondary{
  background: var(--card2);
  box-shadow: 0 18px 50px rgba(0,0,0,.10);
}

h1{ margin:0; font-size: 22px; letter-spacing:.2px; }
h2{ margin:0; font-size: 16px; letter-spacing:.2px; }
.muted{ margin:8px 0 0; color: var(--muted); font-size: 14px; line-height:1.45; }

.form{ margin-top: 14px; }
.field{ display:flex; flex-direction:column; gap:8px; }
.label{ font-size: 13px; color: var(--muted); }
.control{ display:flex; gap:10px; align-items:stretch; }

input{
  width:100%;
  padding: 12px 14px;
  border-radius: var(--radius2);
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text);
  outline:none;
  transition: border .12s ease, box-shadow .12s ease, background .12s ease;
}
input::placeholder{ color: rgba(127,127,127,.55); }
html[data-theme="dark"] input::placeholder{ color: rgba(255,255,255,.35); }
input:focus{
  border-color: var(--field-border-focus);
  box-shadow: var(--focus);
  background: var(--field-bg-focus);
}

.btn{
  min-width: 150px;
  padding: 0 14px;
  border-radius: var(--radius2);
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover{ transform: translateY(-1px); filter: brightness(1.03); }
.btn:active{ transform: translateY(0px); }
.btn[disabled]{ opacity:.65; cursor:not-allowed; transform:none; }

.spinner{
  width:16px; height:16px;
  border-radius:999px;
  border:2px solid rgba(127,127,127,.45);
  border-top-color: rgba(127,127,127,0);
  display:none;
  animation: spin .8s linear infinite;
}
html[data-theme="dark"] .spinner{
  border-color: rgba(255,255,255,.35);
  border-top-color: rgba(255,255,255,0);
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.hint{ font-size:12px; color: var(--muted2); }

.result{
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius2);
  border: 1px dashed var(--dash-border);
  background: var(--surface-bg);
}
.resultRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
}
.resultLabel{ color: var(--muted); font-size: 13px; }
.resultActions{ display:flex; gap:8px; }

.chip{
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--chip-bg);
  color: var(--text);
  padding: 8px 10px;
  font-weight: 650;
  font-size: 13px;
  cursor:pointer;
  text-decoration:none;
  transition: transform .12s ease, background .12s ease;
}
.chip:hover{ transform: translateY(-1px); }
.chip:focus-visible{ box-shadow: var(--focus); }

.shortLink{
  display:block;
  font-size: 18px;
  font-weight: 800;
  text-decoration:none;
  color: var(--text);
  word-break: break-all;
}
.shortLink:hover{ text-decoration: underline; text-underline-offset: 3px; }

.origLine{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted2);
  word-break: break-all;
}

.qrWrap{
  margin-top: 12px;
  display:flex;
  justify-content:center;
}

.qrImg{
  width: 200px;
  height: 200px;
  display:block;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: #fff;
}

.qrWrap{
  margin-top: 12px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
}

.qrActions{
  display:flex;
  justify-content:center;
}

.error{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius2);
  border: 1px solid rgba(255,90,180,.35);
  background: rgba(255,90,180,.10);
  color: var(--text);
  font-size: 13px;
}

.hidden{ display:none; }

.cardHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 12px;
}
.ghostSmall{
  border-radius: 999px;
  border:1px solid var(--stroke);
  background: var(--ghost-bg);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  cursor:pointer;
}
.ghostSmall:hover{ transform: translateY(-1px); }

.history{ display:flex; flex-direction:column; gap:10px; }
.history.empty{ padding: 10px 0 4px; }

.item{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding: 12px;
  border-radius: var(--radius2);
  border:1px solid var(--surface-border);
  background: var(--surface-bg);
}
.item a{ color: var(--text); text-decoration:none; }
.item a:hover{ text-decoration: underline; text-underline-offset: 3px; }
.itemMeta{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}
.itemTop{ font-weight: 800; word-break: break-all; }
.itemBottom{ font-size: 12px; color: var(--muted2); word-break: break-all; }
.itemBtns{ display:flex; gap:8px; flex-shrink:0; }
.small{ padding: 8px 10px; font-size: 13px; }

.emptyState{
  border-radius: var(--radius2);
  border:1px dashed var(--dash-border);
  background: var(--surface-bg);
  padding: 14px;
}
.emptyTitle{ font-weight: 800; }
.emptyText{ margin-top:6px; color: var(--muted2); font-size: 13px; }

.footer{
  display:flex;
  justify-content:center;
  padding: 8px 2px 0;
}

.contactsRow{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.footerLinks{ display:flex; gap:8px; flex-wrap:wrap; }
.linkChip{ padding: 8px 12px; }

.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--toast-border);
  background: var(--toast-bg);
  backdrop-filter: blur(10px);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
  font-size: 13px;
  z-index: 100;
}

@media (max-width: 640px){
  .control{ flex-direction:column; }
  .btn{ min-width: 100%; height: 44px; }
  .wrap{ margin-top: 24px; }
}
@media (min-width: 900px){
  .wrap{
    display:grid;
    grid-template-columns: 1.1fr .9fr;
    grid-template-areas:
      "header header"
      "main   side"
      "footer footer";
    gap:16px;
    align-items:start;
  }

  .header{ grid-area: header; }
  .card{ grid-area: main; }
  .cardSecondary{ grid-area: side; }
  .footer{ grid-area: footer; }
}