/* ============================================================
   Chhotify — design system
   Two colours only:  INK #0a0a0a  +  PAPER #ffffff
   Layout: rules and typography — no cards, no boxes.
   ============================================================ */
:root {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --line: rgba(10, 10, 10, 0.15);
  --line-2: rgba(10, 10, 10, 0.34);
  --muted: rgba(10, 10, 10, 0.62);
  --faint: rgba(10, 10, 10, 0.44);
  --on-ink-line: rgba(255, 255, 255, 0.26);
  --on-ink-muted: rgba(255, 255, 255, 0.68);
  --r: 8px;
  --maxw: 1040px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.hide { display: none !important; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.center { text-align: center; }
.hint { font-size: 13px; color: var(--faint); }
.note { margin: 22px 0 0; font-size: 14px; color: var(--faint); }

/* ------------------------------- nav ------------------------------- */
.nav { position: sticky; top: 0; z-index: 50; background: var(--paper); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; gap: 34px; height: 66px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.03em; font-size: 17px; }
.brand .logo { width: 22px; height: 22px; border-radius: 6px; }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { font-size: 14.5px; color: var(--muted); padding: 4px 0; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.nav-links a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
@media (max-width: 780px) { .nav-links { display: none; } }

/* ------------------------------ buttons ---------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r); border: 1px solid var(--ink);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, opacity .15s, transform .06s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--paper); color: var(--ink); }
.btn-ghost { border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ink (inverted) sections */
.ink { background: var(--ink); color: var(--paper); }
.ink .btn { border-color: var(--on-ink-line); color: var(--paper); background: transparent; }
.ink .btn:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.ink .btn-primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.ink .btn-primary:hover { background: transparent; color: var(--paper); }

/* ------------------------------- hero ------------------------------ */
.hero { padding: 96px 0 64px; border-bottom: 1px solid var(--line); }
.kicker {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 28px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint);
}
.kicker::before { content: ""; width: 26px; height: 1px; background: var(--ink); }
.hero h1 { font-size: clamp(38px, 7.4vw, 78px); line-height: 0.98; letter-spacing: -0.05em; font-weight: 900; margin: 0 0 26px; max-width: 16ch; }
.lede { font-size: clamp(16px, 2vw, 18.5px); color: var(--muted); max-width: 56ch; margin: 0 0 46px; }

/* underline-style shorten bar (no box) */
.shorten { max-width: 680px; }
.shorten-form { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.shorten-form .input { flex: 1; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: clamp(16px, 2.4vw, 19px); padding: 10px 0; }
.shorten-form .input::placeholder { color: var(--faint); }
.shorten-form .input:focus { outline: none; }
@media (max-width: 560px) {
  .shorten-form { flex-direction: column; align-items: stretch; border-bottom: 0; gap: 14px; }
  .shorten-form .input { border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
}

.shorten-result { display: flex; align-items: center; gap: 14px; margin-top: 24px; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.shorten-result .short-url { font-family: var(--mono); font-size: 15px; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------ sections --------------------------- */
.section { padding: 82px 0; border-bottom: 1px solid var(--line); }
.section-head { max-width: 58ch; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(26px, 4vw, 40px); line-height: 1.06; letter-spacing: -0.04em; font-weight: 800; margin: 0 0 14px; }
.section-head p { margin: 0; color: var(--muted); font-size: 16.5px; }

/* features — numbered, rule-separated */
.feature-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 52px; }
@media (max-width: 780px) { .feature-list { grid-template-columns: 1fr; } }
.feature { display: flex; gap: 18px; padding: 27px 0; border-top: 1px solid var(--line); }
.feature .n { font-family: var(--mono); font-size: 12.5px; color: var(--faint); padding-top: 5px; min-width: 30px; }
.feature h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.015em; }
.feature p { margin: 0; color: var(--muted); font-size: 14.8px; }

/* steps — big numerals */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 52px; }
@media (max-width: 840px) { .steps { grid-template-columns: 1fr; } }
.step { padding: 30px 0; border-top: 1px solid var(--line); }
.step .num { font-family: var(--mono); font-size: 46px; font-weight: 700; letter-spacing: -0.05em; line-height: 1; margin-bottom: 16px; }
.step h3 { margin: 0 0 6px; font-size: 17px; }
.step p { margin: 0; color: var(--muted); font-size: 14.8px; }

/* faq — rule separated */
.faq { max-width: 800px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { list-style: none; cursor: pointer; padding: 22px 0; font-weight: 600; font-size: 16.5px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "\2013"; }
.faq p { margin: 0 0 22px; color: var(--muted); font-size: 15px; max-width: 72ch; }

/* cta — full-width ink band */
.cta { padding: 92px 0; }
.cta h2 { font-size: clamp(30px, 5.2vw, 54px); letter-spacing: -0.045em; line-height: 1.02; font-weight: 800; margin: 0 0 18px; max-width: 22ch; }
.cta p { color: var(--on-ink-muted); margin: 0 0 32px; font-size: 17px; }
.cta .row { gap: 12px; flex-wrap: wrap; }

/* ------------------------------ footer ----------------------------- */
.footer { padding: 34px 0; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.footer a:hover { color: var(--ink); }

/* ------------------------------ fields ----------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line-2); background: transparent;
  color: var(--ink); font: inherit; font-size: 16px; padding: 9px 0; border-radius: 0; transition: border-color .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-bottom-color: var(--ink); }

/* ------------------------------- auth ------------------------------ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 48px 24px; }
.auth { width: 100%; max-width: 396px; }
.auth .brand { margin-bottom: 42px; }
.auth h1 { font-size: 30px; letter-spacing: -0.035em; font-weight: 800; margin: 0 0 8px; }
.auth .sub { color: var(--muted); margin: 0 0 36px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 24px; }
.auth-alt { margin: 28px 0 0; color: var(--muted); font-size: 14.5px; }
.auth-alt a { text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

.alert { margin-bottom: 24px; padding: 13px 16px; font-size: 14px; font-weight: 600; background: var(--ink); color: var(--paper); border-radius: var(--r); }
.alert-error { background: var(--ink); color: var(--paper); }

/* ---------------------------- dashboard ---------------------------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app-head { position: sticky; top: 0; z-index: 40; background: var(--paper); border-bottom: 1px solid var(--line); }
.app-head-inner { display: flex; align-items: center; gap: 14px; height: 66px; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.user-chip .mail { font-size: 13.5px; color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-chip .mail { display: none; } }

.app-main { flex: 1; padding: 54px 0 96px; }
.page-title { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.04em; font-weight: 800; margin: 0 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 48px; font-size: 15px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 32px; margin-bottom: 52px; }
@media (max-width: 880px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 22px 0; border-top: 1px solid var(--line); }
.stat .k { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.stat .v { font-size: clamp(30px, 4.2vw, 44px); font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
.stat .v.accent { font-family: var(--mono); font-weight: 700; }

.panel { border-top: 1px solid var(--line); padding: 38px 0; }
.panel h2 { font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 0 0 30px; }

.create-grid { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 24px; align-items: end; }
@media (max-width: 920px) { .create-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 580px) { .create-grid { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table.links { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 660px; }
table.links th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: 0 16px 12px 0; border-bottom: 1px solid var(--line-2); }
table.links td { padding: 16px 16px 16px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.links tr:hover td { background: rgba(10, 10, 10, 0.025); }
.link-url { font-family: var(--mono); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link-dest { display: block; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.badge.on { color: var(--ink); }
.badge.off { color: var(--faint); }
.cell-actions { display: flex; gap: 8px; justify-content: flex-end; }

.empty { padding: 68px 0; text-align: center; border-top: 1px solid var(--line); }
.empty .big { font-size: 30px; font-weight: 800; letter-spacing: -0.035em; margin-bottom: 10px; }

/* toast — inverted bar */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--r); font-size: 14px; max-width: 340px; animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* modal — the one place a container is expected */
.modal-back { position: fixed; inset: 0; z-index: 90; background: rgba(10, 10, 10, 0.55); display: grid; place-items: center; padding: 24px; }
.modal { width: 100%; max-width: 470px; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--r); padding: 30px; }
.modal h3 { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 6px; }
.modal .sub { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; }
.modal .field { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 28px; }

/* chart bars */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin-top: 16px; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1; background: var(--ink); min-height: 3px; }

.skeleton { background: rgba(10, 10, 10, 0.08); border-radius: 4px; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } * { animation: none !important; } }

/* ------------------------- dashboard filters ----------------------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; margin-bottom: 30px; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr; } }

/* ------------------------------ QR code ---------------------------- */
.qr-box { display: grid; place-items: center; padding: 20px 0 4px; }
.qr-box svg { width: 216px; height: 216px; }

/* -------------------------- analytics blocks ----------------------- */
.break-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; margin-top: 26px; }
@media (max-width: 560px) { .break-grid { grid-template-columns: 1fr; } }
.break-title { margin: 18px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.break-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.break-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==================================================================
   Responsive & overflow fixes
   ================================================================== */

/* Flex children must be allowed to shrink, otherwise long URLs push the
   whole layout (and dialogs) wider than the screen. */
.shorten-result { flex-wrap: wrap; row-gap: 10px; }
.shorten-result .short-url { min-width: 0; }

/* Dialogs: always centred, never taller than the viewport. */
.modal-back { overflow-y: auto; }
.modal { max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; }

.table-wrap { -webkit-overflow-scrolling: touch; }
.cell-actions { flex-wrap: wrap; }

@media (max-width: 900px) {
  .hero { padding: 78px 0 52px; }
  .section { padding: 68px 0; }
}

@media (max-width: 640px) {
  .container { padding: 0 18px; }
  .hero { padding: 62px 0 42px; }
  .section { padding: 56px 0; }
  .cta { padding: 64px 0; }
  .app-main { padding: 36px 0 72px; }
  .page-sub { margin-bottom: 36px; }
  .stat-grid { gap: 0 22px; margin-bottom: 38px; }
  .panel { padding: 30px 0; }
}

@media (max-width: 560px) {
  .modal-back { padding: 14px; }
  .modal { padding: 22px; }
  .nav-inner { gap: 12px; }
  .footer-inner { gap: 14px; }
}

/* The dashboard table becomes a stacked list on small screens. */
@media (max-width: 700px) {
  table.links { min-width: 0; }
  table.links thead { display: none; }
  table.links tbody, table.links tr, table.links td { display: block; width: 100%; }
  table.links tr { padding: 18px 0; border-bottom: 1px solid var(--line); }
  table.links tr:hover td { background: transparent; }
  table.links td { border: 0; padding: 4px 0; }
  table.links td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--faint); margin-bottom: 3px;
  }
  table.links td[data-label="Actions"]::before { margin-bottom: 9px; }
  .link-dest { max-width: 100%; }
  .cell-actions { justify-content: flex-start; }
}
