/* =========================================================================
   QuickKit — design tokens & base
   Signature: "workbench pegboard" texture on the sidebar + perforated-edge
   tool cards on the hub, tying the visual language to a physical toolkit.
   ========================================================================= */

:root{
  --accent: var(--cfg-accent, #e8622c);
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, white);

  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --ink: #211d1a;
  --ink-muted: #777063;
  --ink-faint: #a39c8e;
  --border: #e7e1d8;
  --border-strong: #d8d0c2;

  --success: #2f9e5b;
  --success-soft: #e6f6ec;
  --danger: #d64545;
  --danger-soft: #fdeaea;
  --warn: #b8791a;
  --warn-soft: #fbf0dd;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(33,29,26,.06);
  --shadow: 0 8px 24px -8px rgba(33,29,26,.16);
  --shadow-pop: 0 16px 48px -12px rgba(33,29,26,.28);

  --sidebar-w: 248px;
  --topbar-h: 64px;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --dur: .18s;
  --ease: cubic-bezier(.2,.7,.3,1);
}

[data-theme="dark"]{
  --accent-ink: #14161c;
  --accent-soft: color-mix(in srgb, var(--accent) 20%, #14161c);
  --bg: #14161c;
  --surface: #1b1e26;
  --surface-2: #1a1c22;
  --ink: #f2efea;
  --ink-muted: #a8a196;
  --ink-faint: #6d675c;
  --border: #2a2d36;
  --border-strong: #383c47;
  --success-soft: #16281f;
  --danger-soft: #2c1a1a;
  --warn-soft: #2c2313;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-pop: 0 16px 48px -12px rgba(0,0,0,.6);
}

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

[hidden]{ display:none !important; }

*{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:var(--font-body); font-size:15px; line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{ font-family:var(--font-display); font-weight:600; line-height:1.2; margin:0 0 .5em; letter-spacing:-.01em; }
p{ margin:0 0 1em; }
a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }
img{ max-width:100%; display:block; }
code, .mono{ font-family:var(--font-mono); }
::selection{ background:var(--accent-soft); }

button, input, textarea, select{ font-family:inherit; font-size:inherit; color:inherit; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:4px; }

.skip-link{ position:absolute; left:-999px; top:0; background:var(--accent); color:var(--accent-ink); padding:.6em 1em; z-index:999; border-radius:0 0 8px 0; }
.skip-link:focus{ left:0; }

/* =========================================================================
   App shell
   ========================================================================= */

.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width:var(--sidebar-w); flex-shrink:0; background:var(--surface-2);
  border-right:1px solid var(--border);
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1px);
  background-size: 14px 14px; background-position: -6px -6px;
  position:fixed; top:0; left:0; bottom:0; overflow-y:auto; z-index:40;
  transition: transform var(--dur) var(--ease);
}
.sidebar-inner{ background:linear-gradient(180deg, var(--surface-2) 0%, var(--surface-2) 60%, transparent 100%); min-height:100%; padding:18px 14px 24px; }
.brand{ display:flex; align-items:center; gap:10px; padding:8px 8px 18px; }
.brand-mark{ width:34px; height:34px; border-radius:10px; background:var(--accent); color:var(--accent-ink); display:flex; align-items:center; justify-content:center; font-family:var(--font-display); font-weight:700; flex-shrink:0; }
.brand-name{ font-family:var(--font-display); font-weight:700; font-size:17px; }
.brand-tag{ font-size:11px; color:var(--ink-muted); margin-top:-2px; }

.nav-group{ margin-bottom:14px; }
.nav-label{ font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-faint); padding:6px 10px; font-weight:600; }
.nav-link{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:var(--radius-sm);
  color:var(--ink); font-size:13.5px; font-weight:500; margin-bottom:2px; position:relative;
}
.nav-link svg{ width:18px; height:18px; flex-shrink:0; opacity:.8; }
.nav-link:hover{ background:var(--surface); text-decoration:none; }
.nav-link.active{ background:var(--surface); color:var(--accent); box-shadow:var(--shadow-sm); }
.nav-link.active svg{ opacity:1; }
.nav-count{ margin-left:auto; font-size:11px; color:var(--ink-faint); }

.sidebar-user{ display:flex; align-items:center; gap:8px; padding:10px 8px; border-top:1px solid var(--border); margin-top:10px; font-size:12.5px; color:var(--ink-muted); }
.sidebar-avatar{ width:28px; height:28px; border-radius:50%; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; flex-shrink:0; }

.main{ margin-left:var(--sidebar-w); flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{
  height:var(--topbar-h); border-bottom:1px solid var(--border); display:flex; align-items:center;
  gap:14px; padding:0 22px; position:sticky; top:0; background:color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); z-index:30;
}
.menu-btn{ display:none; }
.page-title{ font-family:var(--font-display); font-size:19px; font-weight:600; display:flex; align-items:center; gap:8px; }
.topbar-spacer{ flex:1; }
.theme-toggle{ width:38px; height:38px; border-radius:50%; border:1px solid var(--border); background:var(--surface); display:flex; align-items:center; justify-content:center; cursor:pointer; }
.theme-toggle svg{ width:18px; height:18px; }

.content{ padding:26px; max-width:1180px; width:100%; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:10px 16px; border-radius:10px; border:1px solid transparent; cursor:pointer;
  font-weight:600; font-size:13.5px; transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  white-space:nowrap;
}
.btn svg{ width:16px; height:16px; }
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--accent); color:var(--accent-ink); box-shadow:0 2px 0 rgba(0,0,0,.05); }
.btn-primary:hover{ filter:brightness(1.06); text-decoration:none; }
.btn-secondary{ background:var(--surface); border-color:var(--border-strong); color:var(--ink); }
.btn-secondary:hover{ border-color:var(--accent); color:var(--accent); text-decoration:none; }
.btn-ghost{ background:transparent; color:var(--ink-muted); }
.btn-ghost:hover{ background:var(--surface-2); text-decoration:none; }
.btn-danger{ background:var(--danger-soft); color:var(--danger); }
.btn-icon{ padding:9px; }
.btn-sm{ padding:7px 12px; font-size:12.5px; }
.btn-block{ width:100%; }
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

/* =========================================================================
   Cards / grid / hub
   ========================================================================= */
.grid{ display:grid; gap:16px; }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.grid-2{ grid-template-columns:repeat(2,1fr); }

.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow-sm); }

.stat-card{ display:flex; align-items:center; gap:12px; }
.stat-icon{ width:42px; height:42px; border-radius:12px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.stat-icon svg{ width:20px; height:20px; }
.stat-value{ font-family:var(--font-display); font-size:22px; font-weight:700; line-height:1.1; }
.stat-label{ font-size:12.5px; color:var(--ink-muted); }

.tool-card{
  position:relative; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:20px; display:flex; flex-direction:column; gap:10px; transition:transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
  overflow:hidden;
}
.tool-card::before{ /* perforated edge — the toolkit "punch card" signature */
  content:""; position:absolute; left:0; top:14px; bottom:14px; width:1px;
  background-image: radial-gradient(circle, var(--bg) 2.5px, transparent 2.6px);
  background-size: 1px 14px; background-repeat:repeat-y;
}
.tool-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow); border-color:var(--border-strong); text-decoration:none; color:inherit; }
.tool-card .tool-icon{ width:40px; height:40px; border-radius:11px; display:flex; align-items:center; justify-content:center; background:var(--accent-soft); color:var(--accent); }
.tool-card .tool-icon svg{ width:20px; height:20px; }
.tool-card h3{ font-size:15.5px; margin:0; }
.tool-card p{ font-size:12.5px; color:var(--ink-muted); margin:0; }
.tool-card .tool-badge{ position:absolute; top:14px; right:14px; font-size:10px; padding:3px 7px; border-radius:20px; background:var(--surface-2); color:var(--ink-muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }

.section-head{ display:flex; align-items:center; justify-content:space-between; margin:28px 0 14px; }
.section-head h2{ font-size:15px; color:var(--ink-muted); text-transform:uppercase; letter-spacing:.05em; }

/* =========================================================================
   Forms
   ========================================================================= */
.field{ margin-bottom:16px; }
.field label{ display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:var(--ink-muted); }
.field .hint{ font-size:11.5px; color:var(--ink-faint); margin-top:5px; }
input[type=text], input[type=url], input[type=email], input[type=search], input[type=tel], input[type=password], input[type=number], textarea, select{
  width:100%; padding:11px 13px; border-radius:10px; border:1px solid var(--border-strong); background:var(--surface); color:var(--ink);
  transition:border-color var(--dur), box-shadow var(--dur);
}
input:focus, textarea:focus, select:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); outline:none; }
textarea{ resize:vertical; min-height:90px; }
.input-group{ display:flex; }
.input-group > *:first-child{ border-top-right-radius:0; border-bottom-right-radius:0; }
.input-group > *:last-child{ border-top-left-radius:0; border-bottom-left-radius:0; border-left:0; }
.color-row{ display:flex; gap:8px; flex-wrap:wrap; }
.color-row input[type=color]{ width:40px; height:40px; padding:2px; border-radius:8px; }
.tabs{ display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:18px; flex-wrap:wrap; }
.tab{ padding:9px 14px; font-size:13px; font-weight:600; color:var(--ink-muted); border-bottom:2px solid transparent; cursor:pointer; }
.tab.active{ color:var(--accent); border-color:var(--accent); }
.segmented{ display:inline-flex; background:var(--surface-2); border-radius:10px; padding:3px; gap:2px; }
.segmented button{ border:0; background:transparent; padding:7px 12px; border-radius:8px; font-size:12.5px; font-weight:600; color:var(--ink-muted); cursor:pointer; }
.segmented button.active{ background:var(--surface); color:var(--ink); box-shadow:var(--shadow-sm); }

/* =========================================================================
   Tables / lists
   ========================================================================= */
table{ width:100%; border-collapse:collapse; font-size:13.5px; }
th{ text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-faint); font-weight:600; padding:10px 12px; border-bottom:1px solid var(--border); }
td{ padding:12px; border-bottom:1px solid var(--border); vertical-align:middle; }
tr:last-child td{ border-bottom:0; }
.table-wrap{ overflow-x:auto; }

.badge{ display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:20px; font-size:11px; font-weight:600; }
.badge-success{ background:var(--success-soft); color:var(--success); }
.badge-danger{ background:var(--danger-soft); color:var(--danger); }
.badge-warn{ background:var(--warn-soft); color:var(--warn); }
.badge-neutral{ background:var(--surface-2); color:var(--ink-muted); }

/* =========================================================================
   Empty states
   ========================================================================= */
.empty-state{ text-align:center; padding:52px 20px; color:var(--ink-muted); }
.empty-state svg{ width:110px; height:80px; margin:0 auto 16px; opacity:.85; }
.empty-state h3{ font-size:15px; color:var(--ink); margin-bottom:4px; }
.empty-state p{ font-size:13px; margin-bottom:16px; }

/* =========================================================================
   Skeletons
   ========================================================================= */
.skeleton{ background:linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size:400% 100%; animation:shimmer 1.4s ease infinite; border-radius:8px; }
@keyframes shimmer{ 0%{background-position:100% 0} 100%{background-position:0 0} }
.skeleton-card{ height:120px; border-radius:var(--radius); }
.skeleton-line{ height:12px; margin-bottom:8px; }

/* =========================================================================
   Modals
   ========================================================================= */
.modal-backdrop{ position:fixed; inset:0; background:rgba(20,17,14,.5); backdrop-filter:blur(2px); z-index:80; display:flex; align-items:flex-start; justify-content:center; padding:6vh 16px; overflow-y:auto; }
.modal{ background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:520px; box-shadow:var(--shadow-pop); animation:pop-in .18s var(--ease); }
.modal.modal-lg{ max-width:760px; }
@keyframes pop-in{ from{ opacity:0; transform:translateY(8px) scale(.98);} to{opacity:1; transform:none;} }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--border); }
.modal-head h3{ margin:0; font-size:16px; }
.modal-body{ padding:20px; max-height:70vh; overflow-y:auto; }
.modal-foot{ padding:16px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }
.modal-close{ width:32px; height:32px; border-radius:8px; border:0; background:var(--surface-2); cursor:pointer; display:flex; align-items:center; justify-content:center; }

/* =========================================================================
   Toasts
   ========================================================================= */
#toast-region{ position:fixed; bottom:20px; right:20px; z-index:100; display:flex; flex-direction:column; gap:8px; }
.toast{ background:var(--ink); color:var(--bg); padding:11px 16px; border-radius:10px; font-size:13px; box-shadow:var(--shadow-pop); animation:toast-in .2s var(--ease); display:flex; align-items:center; gap:8px; }
[data-theme="dark"] .toast{ background:var(--surface); color:var(--ink); border:1px solid var(--border); }
.toast.success{ border-left:3px solid var(--success); }
.toast.error{ border-left:3px solid var(--danger); }
@keyframes toast-in{ from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:none;} }

/* =========================================================================
   Animate-in (only for genuine new content, never background refresh)
   ========================================================================= */
.stagger-in > *{ animation:card-in .32s var(--ease) both; }
.stagger-in > *:nth-child(1){animation-delay:.02s} .stagger-in > *:nth-child(2){animation-delay:.06s}
.stagger-in > *:nth-child(3){animation-delay:.10s} .stagger-in > *:nth-child(4){animation-delay:.14s}
.stagger-in > *:nth-child(5){animation-delay:.18s} .stagger-in > *:nth-child(6){animation-delay:.22s}
.stagger-in > *:nth-child(n+7){animation-delay:.24s}
@keyframes card-in{ from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;} }

/* =========================================================================
   Misc utility
   ========================================================================= */
.flex{ display:flex; } .items-center{ align-items:center; } .justify-between{ justify-content:space-between; }
.gap-8{ gap:8px; } .gap-12{ gap:12px; } .gap-16{ gap:16px; }
.text-muted{ color:var(--ink-muted); } .text-sm{ font-size:12.5px; } .text-xs{ font-size:11px; }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}
.w-full{ width:100%; }
.divider{ height:1px; background:var(--border); margin:18px 0; }
.copy-row{ display:flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:10px 12px; font-family:var(--font-mono); font-size:13px; }
.copy-row span{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.qr-preview{ display:flex; align-items:center; justify-content:center; background:var(--surface-2); border-radius:var(--radius); padding:24px; }
.qr-preview canvas, .qr-preview svg{ max-width:220px; }
.color-swatch{ width:16px; height:16px; border-radius:4px; display:inline-block; border:1px solid var(--border-strong); vertical-align:-3px; }

/* =========================================================================
   Article / blog typography
   ========================================================================= */
.article{ max-width:720px; margin:0 auto; }
.article h1{ font-size:30px; }
.article-meta{ color:var(--ink-muted); font-size:13px; margin-bottom:24px; }
.article-body h2{ font-size:21px; margin-top:1.6em; }
.article-body h3{ font-size:17px; margin-top:1.4em; }
.article-body p, .article-body ul, .article-body ol{ font-size:15.5px; line-height:1.75; }
.article-body ul, .article-body ol{ padding-left:1.4em; }
.article-body blockquote{ border-left:3px solid var(--accent); margin:0; padding:2px 0 2px 16px; color:var(--ink-muted); }
.article-body code{ background:var(--surface-2); padding:2px 6px; border-radius:5px; font-size:.9em; }
.article-body pre{ background:var(--surface-2); padding:14px; border-radius:10px; overflow-x:auto; }
.article-body pre code{ background:none; padding:0; }
.share-row{ display:flex; gap:8px; margin:24px 0; }
.share-btn{ width:38px; height:38px; border-radius:50%; background:var(--surface-2); display:flex; align-items:center; justify-content:center; }
.share-btn svg{ width:16px; height:16px; }
.related-posts{ display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }

/* =========================================================================
   Marketing/legal simple pages
   ========================================================================= */
.prose{ max-width:760px; margin:0 auto; }
.prose h2{ margin-top:1.6em; font-size:19px; }
.prose ul{ padding-left:1.3em; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1080px){
  .grid-4{ grid-template-columns:repeat(2,1fr); }
  .grid-3{ grid-template-columns:repeat(2,1fr); }
  .related-posts{ grid-template-columns:1fr; }
}
@media (max-width: 900px){
  .sidebar{ transform:translateX(-100%); box-shadow:var(--shadow-pop); }
  .sidebar.open{ transform:none; }
  .main{ margin-left:0; }
  .menu-btn{ display:flex; width:38px; height:38px; border-radius:8px; border:1px solid var(--border); background:var(--surface); align-items:center; justify-content:center; cursor:pointer; }
  .sidebar-scrim{ position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:39; }
}
@media (max-width: 640px){
  .grid-4, .grid-3, .grid-2{ grid-template-columns:1fr; }
  .content{ padding:16px; }
  .topbar{ padding:0 14px; }
  .page-title{ font-size:16px; }
}
@media (max-width: 380px){
  .content{ padding:12px; }
  .btn{ padding:9px 13px; }
}
