/* 2plus1LinkShortner — dark switchboard */
:root {
  --bg: #0B1120;
  --bg-2: #0F1729;
  --bg-3: #141F35;
  --line: #22304A;
  --line-2: #2E3F5E;
  --ink: #E6EBF4;
  --ink-2: #AAB6CB;
  --muted: #7B89A3;
  --teal: #2DD4BF;
  --teal-2: #14B8A6;
  --teal-dim: rgba(45, 212, 191, .14);
  --amber: #F0A800;
  --amber-dim: rgba(240, 168, 0, .16);
  --red: #F87171;
  --red-dim: rgba(248, 113, 113, .14);
  --font: "Bricolage Grotesque", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 12px;
  --shadow: 0 20px 50px rgba(0, 0, 0, .45);
  --on-accent: #052E2B;
  --teal-hover: #4AE3D0;
  --teal-line: rgba(45, 212, 191, .35);
  --amber-line: rgba(240, 168, 0, .4);
  --red-line: rgba(248, 113, 113, .4);
  --red-ink: #FCA5A5;
  --bar: rgba(11, 17, 32, .8);
  --scrim: rgba(4, 8, 18, .55);
  --grain-opacity: .045;
  --cancel-filter: invert(.7);
  color-scheme: dark;
}
/* light theme. The inline script in _head.php sets data-theme to the stored
   choice, or to the system preference when nothing is stored. */
:root[data-theme="light"] {
  --bg: #F3F5F9;
  --bg-2: #FFFFFF;
  --bg-3: #EAEFF6;
  --line: #DCE3EE;
  --line-2: #C3CDDD;
  --ink: #0F172A;
  --ink-2: #364259;
  --muted: #66738C;
  --teal: #0F766E;
  --teal-2: #0D9488;
  --teal-dim: rgba(15, 118, 110, .10);
  --amber: #A66E00;
  --amber-dim: rgba(176, 122, 0, .12);
  --red: #B91C1C;
  --red-dim: rgba(185, 28, 28, .08);
  --shadow: 0 16px 40px rgba(15, 23, 42, .12);
  --on-accent: #FFFFFF;
  --teal-hover: #0D9488;
  --teal-line: rgba(15, 118, 110, .35);
  --amber-line: rgba(166, 110, 0, .4);
  --red-line: rgba(185, 28, 28, .35);
  --red-ink: #991B1B;
  --bar: rgba(243, 245, 249, .85);
  --scrim: rgba(15, 23, 42, .35);
  --grain-opacity: .035;
  --cancel-filter: none;
  color-scheme: light;
}
.theme-icon-sun, .theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }
:root:not([data-theme="light"]) .theme-icon-sun { display: block; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(45, 212, 191, .10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 168, 0, .07), transparent 55%);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--grain-opacity); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-2); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.center { text-align: center; }
.small { font-size: 13px; }
.right { text-align: right; }
.grow { flex: 1; }
.inline { display: inline; }
kbd {
  font: 600 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 5px; padding: 3px 5px; background: var(--bg-2);
}

/* reveal on load */
.reveal { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--d, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } * { transition: none !important; } }

/* ---- top bar --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 40px); background: var(--bar); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { display: block; flex: none; }
.brand .wordmark { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.auth-card .brand .wordmark { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.host { color: var(--muted); font-size: 12.5px; }
.linkbtn { background: none; border: 0; color: var(--ink-2); font: inherit; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.linkbtn:hover { color: var(--ink); background: var(--bg-3); }
.iconbtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { color: var(--teal); background: var(--teal-dim); border-color: var(--teal-line); text-decoration: none; }

/* ---- buttons & inputs ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--ink); font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--teal); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--on-accent); }
.btn.primary:hover { background: var(--teal-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-dim); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 8px; }
.btn[disabled] { opacity: .5; cursor: wait; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
label .hint { font-weight: 400; margin-left: 4px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); font: 14px var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
input[type=radio] { display: inline; width: auto; margin: 0 6px 0 0; }
input[type=file] { padding: 8px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-dim); }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%237B89A3' stroke-width='2'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.prefixed { display: flex; align-items: stretch; margin-top: 5px; }
.prefixed > span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-right: 0; border-radius: 9px 0 0 9px; background: var(--bg-3); color: var(--muted); font-size: 13px; }
.prefixed > input { margin: 0; border-radius: 0 9px 9px 0; }
.radio { display: flex; align-items: center; gap: 4px; font-weight: 500; margin-bottom: 8px; }
.alert { background: var(--red-dim); border: 1px solid var(--red-line); color: var(--red-ink); padding: 10px 12px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }

/* ---- auth pages ------------------------------------------------------------ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.auth-card { width: min(400px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.auth-card p { margin: 0 0 18px; }
.auth-card.center .brand { justify-content: center; }
.auth-card h1.mono { font-size: 30px; word-break: break-all; }

/* ---- main layout ------------------------------------------------------------ */
main#app, main.settings { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 22px clamp(16px, 4vw, 40px) 80px; }

/* composer */
.composer { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.composer-row { display: flex; gap: 10px; align-items: stretch; }
.urlbox { flex: 1; position: relative; display: flex; align-items: center; }
.urlbox-icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.urlbox input { margin: 0; padding: 14px 48px 14px 44px; font-size: 16px; font-family: var(--mono); background: var(--bg); }
.urlbox kbd { position: absolute; right: 12px; }
.composer-more { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.composer-more .span2 { grid-column: 1 / -1; }
.composer-more label { margin-bottom: 10px; }
.result { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--teal-dim); border: 1px solid var(--teal-line); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; animation: pop .35s cubic-bezier(.2, .8, .3, 1.3); }
.result.warn { background: var(--amber-dim); border-color: var(--amber-line); }
.result .big { font: 700 22px var(--mono); color: var(--teal); letter-spacing: -.01em; }
.result.warn .big { color: var(--amber); }
.result .btn { margin-left: auto; }
@keyframes pop { from { transform: scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* overview tiles */
.overview { display: grid; grid-template-columns: repeat(4, 1fr) 2fr; gap: 10px; margin: 18px 0; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile-n { font: 700 26px/1.1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tile.spark svg { width: 100%; height: 48px; display: block; }
.spark-line, .bigspark .line { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-area, .bigspark .area { fill: url(#sparkfill); }
.bigspark { width: 100%; height: 90px; display: block; margin: 8px 0; }
.bigspark .bar { fill: var(--teal); opacity: .85; }
.bigspark .bar:hover { fill: var(--amber); opacity: 1; }
.bigspark .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.searchbox { flex: 1; position: relative; display: flex; align-items: center; }
.searchbox svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.searchbox input { margin: 0; padding: 11px 44px 11px 38px; font-size: 15px; }
.searchbox input::-webkit-search-cancel-button { filter: invert(.7); }
.searchbox kbd { position: absolute; right: 10px; }
.toolbar select { width: auto; margin: 0; padding-top: 10px; padding-bottom: 10px; }
.count { color: var(--muted); font-size: 13px; min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; min-height: 0; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--ink-2); cursor: pointer; transition: .12s; }
.tag:hover { border-color: var(--teal); color: var(--teal); }
.tag.on { background: var(--teal); border-color: var(--teal); color: var(--on-accent); }
.tag i { font-style: normal; opacity: .6; font-weight: 400; }
.tag.mini { padding: 1px 7px; font-size: 11px; cursor: pointer; }

/* list */
.list { margin-top: 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(150px, 230px) minmax(0, 1fr) 96px 110px 130px; gap: 12px; align-items: center; padding: 11px 16px; border-top: 1px solid var(--line); }
.row.head { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; border-top: 0; background: var(--bg-3); padding: 9px 16px; }
.row.link { cursor: pointer; transition: background .12s; animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 18ms); }
.row.link:hover, .row.link:focus-within { background: var(--bg-3); }
.row.link.flash { background: var(--teal-dim); }
.kw { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kw .k { font: 700 15px var(--mono); color: var(--teal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw .k .h { color: var(--muted); font-weight: 400; }
.kw .copy { opacity: 0; transition: .12s; flex: none; width: 28px; height: 28px; }
.row.link:hover .kw .copy, .kw .copy:focus { opacity: 1; }
.dest { min-width: 0; }
.dest .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest .u { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-family: var(--mono); overflow: hidden; white-space: nowrap; }
.dest .u .host { color: var(--ink-2); background: var(--bg-3); padding: 0 6px; border-radius: 5px; font-size: 11.5px; flex: none; }
.dest .u .path { overflow: hidden; text-overflow: ellipsis; }
.dest .tags { margin: 4px 0 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.clicks .n { font-weight: 700; font-size: 16px; }
.clicks .w { display: block; font-size: 11px; color: var(--muted); }
.clicks .w b { color: var(--amber); font-weight: 600; }
.when { color: var(--ink-2); font-size: 13px; }
.when small { display: block; color: var(--muted); font-size: 11.5px; }
.acts { display: flex; justify-content: flex-end; gap: 2px; opacity: .35; transition: .12s; }
.row.link:hover .acts, .row.link:focus-within .acts { opacity: 1; }
.acts .iconbtn { width: 30px; height: 30px; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-2); }
mark { background: var(--amber-dim); color: var(--amber); border-radius: 3px; padding: 0 1px; }

/* drawer */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; backdrop-filter: blur(2px); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 21; background: var(--bg-2); border-left: 1px solid var(--line-2); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .28s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head > div:first-child { flex: 1; min-width: 0; }
.drawer-head .short { font-size: 20px; font-weight: 700; color: var(--teal); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 16px 18px 28px; overflow: auto; flex: 1; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg); border-radius: 10px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--ink-2); font: 600 13px var(--font); padding: 8px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--bg-3); color: var(--ink); box-shadow: 0 1px 0 var(--line-2); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.meta { margin: 4px 0 12px; }
.stat-head { display: flex; align-items: baseline; gap: 10px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 8px; }
.kv { list-style: none; padding: 0; margin: 0; }
.kv li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.kv li b { font-variant-numeric: tabular-nums; }
.visits { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.visits td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.visits td:first-child { white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.visits td.ua { color: var(--muted); }
.qr { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: 12px; }
.qr svg { width: min(300px, 100%); height: auto; display: block; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg-3); border: 1px solid var(--line-2); border-left: 3px solid var(--teal); color: var(--ink); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: rise .25s both; max-width: 380px; }
.toast.bad { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast .mono { color: var(--teal); }

/* settings */
.settings h2 { font-size: 18px; margin: 0 0 6px; letter-spacing: -.01em; }
.settings .card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.settings .card p.muted { margin: 0 0 14px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.banner { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 16px; margin: 0 0 12px; }
.banner.good { border-color: var(--teal-line); background: var(--teal-dim); }
.banner.bad { border-color: var(--red-line); background: var(--red-dim); }
.tokenbox { margin-top: 8px; padding: 10px 12px; background: var(--bg); border-radius: 8px; word-break: break-all; cursor: copy; border: 1px dashed var(--line-2); }
.tokenbox.copied { border-color: var(--teal); }
.tokenbox.copied::after { content: " · copied"; color: var(--teal); }
table.plain { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 14px; }
table.plain td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { margin: 0; }
.apidocs { margin-top: 14px; }
.apidocs summary { cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.apidocs pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12px; line-height: 1.5; color: var(--ink-2); }

/* responsive */
@media (max-width: 900px) {
  .overview { grid-template-columns: repeat(2, 1fr); }
  .tile.spark { grid-column: 1 / -1; }
  .row { grid-template-columns: 1fr 1fr; }
  .row.head { display: none; }
  .row.link .kw { grid-column: 1 / -1; }
  .row.link .dest { grid-column: 1 / -1; }
  .row.link .acts { justify-content: flex-start; opacity: 1; }
  .row.link .when { text-align: right; }
  .composer-row { flex-wrap: wrap; }
  .urlbox { flex-basis: 100%; }
  .composer-more { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .searchbox { flex-basis: 100%; }
  .host { display: none; }
}
