/* ==========================================================================
   HSC Crackers Links
   Mobile-first, modern dark palette with clean typography & clear layout.
   ========================================================================== */

:root {
  --ink: #090a0d;
  --panel: #13141a;
  --panel-hi: #1b1d24;
  --field: #0d0e12;
  --line: #222530;
  --line-hi: #343846;
  --text: #f4f4f7;
  --muted: #8b8f9e;
  --lime: #c7fe3b;
  --lime-hi: #d7ff6b;
  --on-lime: #090b01;
  --danger: #ff5c5c;

  --font: "Lexend", system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --header-h: 60px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--ink);
  background-image: radial-gradient(circle at 50% 0%, #161824 0%, var(--ink) 80%);
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
code { 
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em; 
  background: #1c1d26; 
  padding: 0.15em 0.45em; 
  border-radius: var(--radius-sm);
  color: var(--lime);
}

.container { 
  width: min(1080px, calc(100% - 1.5rem)); 
  margin-inline: auto; 
}
.container.narrow { width: min(580px, calc(100% - 1.5rem)); padding-block: 2rem; }
.muted { color: var(--muted); }
.small { font-size: 0.825rem; }
.h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.h3 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }

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

/* ---------- Subtle Chamfer Clip ---------- */
.chamfer {
  --cut: 14px;
  --edge: var(--line);
  --fill: var(--panel);
  position: relative;
  background: var(--edge);
  border-radius: var(--radius);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}
.chamfer::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: var(--fill);
  border-radius: calc(var(--radius) - 1px);
  clip-path: polygon(0 0, calc(100% - var(--cut) + 0.4px) 0, 100% calc(var(--cut) - 0.4px), 100% 100%, 0 100%);
  pointer-events: none;
}
.chamfer > * { position: relative; z-index: 1; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; 
  top: 0; 
  z-index: 40;
  background: rgba(9, 10, 13, 0.85);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.header-inner { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 0.75rem; 
  height: var(--header-h); 
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand-mark { height: 22px; width: auto; flex-shrink: 0; }
.brand-word { height: 13px; width: auto; flex-shrink: 0; }
.header-user { display: flex; align-items: center; gap: 0.65rem; }
.avatar { 
  width: 32px; 
  height: 32px; 
  border-radius: 50%; 
  object-fit: cover; 
  border: 1px solid var(--line-hi);
  background: var(--panel-hi);
}
.user-name { 
  display: none; 
  font-size: 0.85rem; 
  color: var(--text); 
  max-width: 140px; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 0.6rem;
  min-height: 46px; 
  padding: 0.65rem 1.25rem;
  font: inherit; 
  font-size: 0.92rem;
  font-weight: 600; 
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-lg { min-height: 52px; font-size: 0.98rem; font-weight: 700; }
.btn-sm { min-height: 34px; padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-primary { background: var(--lime); color: var(--on-lime); }
.btn-primary:hover:not(:disabled) { background: var(--lime-hi); }
.btn-google { background: #fff; color: #161616; width: 100%; }
.btn-google:hover:not(:disabled) { background: #ececec; }
.btn-ghost { background: var(--panel-hi); color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-hi); background: #232630; }
.btn-danger { background: rgba(255, 92, 92, 0.12); color: var(--danger); border-color: rgba(255, 92, 92, 0.3); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > label { font-size: 0.875rem; font-weight: 500; color: #d4d4d8; }
.optional { color: var(--muted); font-size: 0.8rem; }

.input {
  width: 100%; 
  min-height: 46px; 
  padding: 0.65rem 0.85rem;
  font: inherit; 
  font-size: 0.9rem;
  color: var(--text);
  background: var(--field); 
  border: 1px solid var(--line); 
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
}
.input::placeholder { color: #525668; }
.input:focus { outline: none; border-color: var(--lime); }

.slug-field {
  display: flex; 
  align-items: stretch;
  background: var(--field); 
  border: 1px solid var(--line); 
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease;
}
.slug-field:focus-within { border-color: var(--lime); }
.slug-prefix {
  display: flex; 
  align-items: center; 
  padding-left: 0.85rem; 
  color: var(--muted); 
  font-size: 0.85rem; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis;
  max-width: 45%;
}
.slug-field .input { border: 0; background: transparent; padding-inline: 0.35rem; flex: 1 1 auto; }
.slug-field .input:focus { outline: none; }
.icon-btn {
  display: inline-grid; 
  place-items: center; 
  width: 44px; 
  min-height: 44px;
  color: var(--muted); 
  background: transparent; 
  border: 0; 
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.icon-btn:hover { color: var(--lime); }

.hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.hint:empty { display: none; }
.hint[data-state="ok"] { color: var(--lime); }
.hint[data-state="error"] { color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.875rem; margin-top: 0.5rem; }

/* ---------- Loader ---------- */
.loader { display: inline-flex; align-items: center; gap: 5px; height: 26px; }
.loader i { display: block; width: 6px; height: 100%; background: #fff; transform-origin: 50% 50%; animation: bars 1s ease-in-out infinite; border-radius: 1px; }
.loader i:nth-child(2) { height: 60%; background: var(--lime); animation-delay: 0.15s; }
.loader i:nth-child(3) { animation-delay: 0.3s; }
.loader-still i { animation: none; opacity: 0.6; }
@keyframes bars { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

.view-center { display: grid; place-items: center; min-height: calc(80dvh - var(--header-h)); }

/* ==========================================================================
   Login / Hero Page (Clean Mobile Layout)
   ========================================================================== */
.hero {
  min-height: calc(85dvh - var(--header-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 0 3rem;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 460px;
}

.hero-badge-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }

.badge-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lime);
  background: rgba(199, 254, 59, 0.08);
  border: 1px solid rgba(199, 254, 59, 0.25);
  border-radius: 99px;
}

.hero h1 {
  font-size: clamp(2.1rem, 7vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.hero-subtitle {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  text-wrap: pretty;
}
.hero-subtitle strong { color: var(--lime); }

.hero-action-box {
  margin-top: 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 320px;
}

.login-note { text-align: center; }

/* Hide the giant, disruptive graphic on phones */
.stage { display: none; }

/* ---------- Dashboard ---------- */
.dashboard { padding-block: 1.5rem 3rem; display: grid; gap: 1.5rem; }
.dash-head h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); font-weight: 800; letter-spacing: -0.03em; }
.panel { padding: 1.25rem; }
.panel-header { margin-bottom: 1rem; }
.create-form { display: grid; gap: 1rem; }
.form-actions { margin-top: 0.25rem; }
.form-actions .btn { width: 100%; }

/* Stats */
.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.summary-card {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.summary-num {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.summary-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Links Section */
.links-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.search-wrapper { flex: 1 1 200px; max-width: 280px; }
.search { min-height: 40px; font-size: 0.85rem; }

.links-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

/* Link Card */
.link-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  padding: 1.15rem;
  align-items: center;
  background: var(--line);
}
.card-short {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}
.short-url {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.short-host { color: var(--muted); font-weight: 500; }
.short-slug { color: var(--lime); }
.pill {
  flex-shrink: 0;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  color: var(--lime);
  background: rgba(199, 254, 59, 0.08);
  border: 1px solid rgba(199, 254, 59, 0.3);
  border-radius: 99px;
}

.card-info { min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.long-url {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clicks { display: flex; align-items: baseline; gap: 0.35rem; }
.clicks-num {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1;
}
.clicks-label { font-size: 0.75rem; color: var(--muted); }
.meta { font-size: 0.75rem; color: var(--muted); }

.qr-thumb {
  width: 64px;
  height: 64px;
  padding: 4px;
  background: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.qr-thumb svg { width: 100%; height: 100%; display: block; }
.qr-thumb:hover { outline: 2px solid var(--lime); }

.card-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line-hi);
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 48px;
  padding: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.chip:active { background: #262934; }
.chip-danger { color: var(--danger); }
.chip-danger:hover { border-color: var(--danger); }

.empty {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 2.25rem 1rem;
  text-align: center;
}
.empty-title { font-size: 1.05rem; font-weight: 600; }
.empty-search { text-align: center; padding: 2rem 0; }

/* ---------- Dialogs & Modals ---------- */
dialog {
  width: calc(100% - 2rem);
  max-width: 400px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(4px); }
.dialog-card { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.85rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.qr-big {
  width: 220px;
  margin: 0.5rem auto;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius-sm);
}
.qr-big svg { display: block; width: 100%; height: auto; }
.qr-url { text-align: center; font-weight: 700; font-size: 1rem; word-break: break-all; }
.dialog-actions { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
  padding-inline: 1rem;
}
.toast {
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  color: #fff;
  background: #1c1e28;
  border: 1px solid var(--line-hi);
  border-left: 3px solid var(--lime);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.toast[data-kind="error"] { border-left-color: var(--danger); }

/* ---------- Redirect View ---------- */
.link-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.25rem;
}
.link-panel {
  width: min(100%, 400px);
  padding: 1.75rem 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.link-actions { display: flex; gap: 0.5rem; width: 100%; }
.link-actions .btn { flex: 1; }

.steps { padding-left: 1.2rem; display: grid; gap: 0.35rem; margin: 0.8rem 0; font-size: 0.9rem; }
.site-footer { padding-block: 1.5rem; border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; }

/* Route Switcher */
html[data-route="link"] #app-root,
html[data-route="link"] dialog,
html[data-route="link"] #toasts { display: none !important; }
html[data-route="app"] #link-root { display: none; }

/* ==========================================================================
   Desktop / Tablet Adjustments
   ========================================================================== */
@media (min-width: 600px) {
  .create-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .create-form .field:first-child { grid-column: 1 / -1; }
  .form-actions .btn { width: auto; }
  .summary { grid-template-columns: 180px 180px; }
  .links-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .dialog-actions { grid-template-columns: repeat(3, 1fr); }
  .user-name { display: inline-block; }
}

@media (min-width: 900px) {
  /* Switch hero back to two-column split layout with SVG on desktop */
  .hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3.5rem;
    align-items: center;
    text-align: left;
    min-height: calc(85dvh - var(--header-h));
    padding-block: 3.5rem;
  }
  
  .hero-copy {
    align-items: flex-start;
    max-width: 100%;
  }

  .hero-badge-wrap { justify-content: flex-start; }

  .hero-subtitle {
    margin-inline: 0;
  }

  .hero-action-box {
    align-items: flex-start;
  }

  .login-note { text-align: left; }

  .stage {
    display: flex;
    justify-content: center;
    position: relative;
  }

  .stage-mark {
    width: 100%;
    max-width: 440px;
    height: auto;
  }
  .stage-mark .m-bar { fill: #1a1c24; }
  .stage-mark .m-chev { fill: var(--lime); opacity: 0.9; }
}