/* ============================================================
   ClipShare — theme.css
   Minimalist, mobile-first design system. Class-based, no build.
   Light/dark via CSS variables. Premium inline SVG icons.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-hover: #f1f2f5;
  --border: #eaebef;
  --border-strong: #dcdee4;
  --text: #16181d;
  --text-2: #5b6169;
  --text-3: #9aa0aa;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-ring: rgba(79, 70, 229, 0.22);
  --success: #0f9d58;
  --success-soft: #e8f5ee;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #d9820a;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px -8px rgba(16, 24, 40, 0.14);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --container: 1120px;
  --header-h: 60px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

html.dark {
  --bg: #0c0d10;
  --bg-soft: #111318;
  --surface: #131519;
  --surface-2: #16181d;
  --surface-hover: #1c1f26;
  --border: #24262d;
  --border-strong: #30333c;
  --text: #ecedf0;
  --text-2: #a2a8b3;
  --text-3: #6a707b;
  --accent: #7c74ff;
  --accent-hover: #938cff;
  --accent-soft: rgba(124, 116, 255, 0.13);
  --accent-ring: rgba(124, 116, 255, 0.3);
  --success: #37c979;
  --success-soft: rgba(55, 201, 121, 0.13);
  --danger: #ff5a5f;
  --danger-soft: rgba(255, 90, 95, 0.13);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, 0.7);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; font-weight: 650; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.5rem; }
.muted { color: var(--text-2); }
.muted-3 { color: var(--text-3); }

/* ---------- Icons ---------- */
.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.ico svg { width: 1em; height: 1em; display: block; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .bar { min-height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--text); }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 17px; background: var(--accent); }
.brand .brand-short { display: none; }
@media (max-width: 400px) {
  .brand .brand-full { display: none; }
  .brand .brand-short { display: inline; }
}
.nav { display: flex; align-items: center; gap: .15rem; }
.nav a { padding: .5rem .75rem; border-radius: 8px; font-size: .92rem; font-weight: 500; color: var(--text-2); transition: color .15s, background .15s; }
.nav a:hover { color: var(--text); background: var(--surface-hover); }
.nav a.active { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: .4rem; }

.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; font-size: 18px; transition: background .15s, border-color .15s; }
.icon-btn:hover { background: var(--surface-hover); }
.menu-btn { display: none; }

.mobile-nav { display: flex; flex-direction: column; gap: .15rem; max-height: 0; overflow: hidden; transition: max-height .28s ease; }
.mobile-nav a { padding: .8rem .25rem; font-size: 1rem; font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--border); }
.mobile-nav a:last-child { border-bottom: 0; }
.mobile-nav a.active { color: var(--accent); }
.site-header.menu-open .mobile-nav { max-height: 320px; padding-bottom: .75rem; }

/* ---------- Buttons ---------- */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .94rem; font-weight: 550; line-height: 1;
  padding: .68rem 1.05rem; border-radius: 10px; cursor: pointer;
  background: var(--_bg); color: var(--_fg); border: 1px solid var(--_bd);
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
  white-space: nowrap;
}
.btn .ico { font-size: 1.05em; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { --_bg: var(--accent); --_fg: #fff; --_bd: transparent; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-ghost { --_bg: transparent; --_bd: transparent; --_fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-lg { padding: .85rem 1.4rem; font-size: 1rem; }
.btn-sm { padding: .5rem .8rem; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: 1.5rem; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.card-title { font-size: 1.05rem; font-weight: 650; display: flex; align-items: center; gap: .55rem; }
.card-title .dot { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 16px; }
.card-sub { font-size: .9rem; color: var(--text-2); margin-top: .3rem; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 550; padding: .32rem .7rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge .ico { font-size: .95em; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-muted { background: var(--surface-2); color: var(--text-2); }

/* ---------- Forms ---------- */
.field-label { display: block; font-size: .84rem; font-weight: 550; color: var(--text-2); margin-bottom: .4rem; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: .96rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: .72rem .9rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.textarea { resize: vertical; min-height: 170px; line-height: 1.6; }
.textarea.mono { font-family: var(--mono); font-size: .9rem; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa0aa' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .85rem center; padding-right: 2.4rem; cursor: pointer; }
.code-input { text-align: center; letter-spacing: .45rem; font-weight: 700; font-size: 1.25rem; font-family: var(--mono); }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; cursor: pointer; user-select: none; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .18s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform .18s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); }

.form-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.form-row > .grow { flex: 1; min-width: 170px; }

/* ---------- Result / code ---------- */
.result-box { margin-top: 1.25rem; padding: 1.35rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.code-display { font-family: var(--mono); font-size: 2.1rem; font-weight: 700; letter-spacing: .4rem; color: var(--text); }
.divider { height: 1px; background: var(--border); border: 0; margin: 1.25rem 0; }

/* ---------- Segmented tabs ---------- */
.segmented { display: inline-flex; padding: .3rem; gap: .25rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; max-width: 100%; }
.segmented a, .segmented button { border: 0; cursor: pointer; font-family: inherit; font-weight: 550; font-size: .9rem; color: var(--text-2); background: transparent; padding: .6rem .95rem; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap; transition: background .15s, color .15s; }
.segmented a:hover, .segmented button:hover { color: var(--text); }
.segmented a.active, .segmented button.active { color: var(--accent); background: var(--surface); box-shadow: var(--shadow-xs); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding-block: 3rem 1.75rem; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 2.85rem); font-weight: 700; margin: 1rem auto .8rem; letter-spacing: -0.035em; max-width: 18ch; }
.hero h1 .grad { color: var(--accent); }
.hero p { font-size: clamp(1rem, 1.6vw, 1.12rem); color: var(--text-2); max-width: 38rem; margin: 0 auto; }

/* ---------- Workspace ---------- */
.workspace { display: grid; grid-template-columns: 1fr minmax(0, 720px) 1fr; gap: 1.5rem; align-items: start; }
.workspace .rail { position: sticky; top: calc(var(--header-h) + 1.25rem); }
.workspace .center { min-width: 0; }
.ad-rail { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-height: 600px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; color: var(--text-3); }
.ad-rail .ad-label { text-transform: uppercase; letter-spacing: .12em; font-size: .66rem; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---------- Sections ---------- */
.section { padding-block: 3rem; }
.section-head { text-align: center; max-width: 42rem; margin: 0 auto 2rem; }
.section-head h2 { font-size: clamp(1.4rem, 2.5vw, 1.8rem); }
.section-head p { color: var(--text-2); margin-top: .55rem; font-size: 1.02rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.feature { padding: 1.35rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); transition: border-color .15s; }
.feature:hover { border-color: var(--border-strong); }
.feature .ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: var(--accent-soft); color: var(--accent); margin-bottom: .9rem; }
.feature h3 { font-size: 1.02rem; margin-bottom: .4rem; font-weight: 600; }
.feature p { color: var(--text-2); font-size: .92rem; }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.step { padding: 1.35rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step .n { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: #fff; background: var(--accent); margin-bottom: .8rem; }
.step h3 { font-size: .98rem; margin-bottom: .3rem; font-weight: 600; }
.step p { font-size: .89rem; color: var(--text-2); }

/* ---------- FAQ ---------- */
.faq { max-width: 44rem; margin: 0 auto; display: flex; flex-direction: column; gap: .6rem; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.faq summary { cursor: pointer; list-style: none; padding: 1.05rem 1.2rem; font-weight: 550; font-size: .98rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.25rem; color: var(--text-3); font-weight: 400; transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 1.2rem 1.15rem; color: var(--text-2); font-size: .94rem; }

/* ---------- Prose ---------- */
.prose { max-width: 44rem; margin: 0 auto; color: var(--text); }
.prose h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); margin-bottom: 1rem; }
.prose h2 { font-size: 1.3rem; margin: 1.75rem 0 .55rem; }
.prose p, .prose li { color: var(--text-2); font-size: 1rem; line-height: 1.75; }
.prose ul, .prose ol { padding-left: 1.25rem; display: flex; flex-direction: column; gap: .4rem; }
.prose a { color: var(--accent); font-weight: 550; }
.prose a:hover { text-decoration: underline; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); padding: .1rem .4rem; border-radius: 6px; }

/* ---------- Dropzone ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 2rem 1.25rem; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .ic { font-size: 26px; color: var(--accent); margin-bottom: .5rem; display: flex; justify-content: center; }

/* ---------- Transfers ---------- */
.transfer { padding: .85rem .95rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.transfer .top { display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; font-weight: 500; }
.transfer .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; border-radius: 999px; background: var(--border); margin-top: .5rem; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--text-2); font-weight: 500; }
.status .led { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status.on .led { background: var(--success); }
.status.wait .led { background: var(--warn); animation: pulse 1.4s infinite; }
.status.off .led { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; background: var(--bg-soft); }
.site-footer .inner { padding-block: 2.5rem; display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 2rem; }
.site-footer .col h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin-bottom: .85rem; font-weight: 600; }
.site-footer .col > a { display: block; color: var(--text-2); font-size: .92rem; padding: .28rem 0; transition: color .15s; }
.site-footer .col > a:hover { color: var(--text); }
.site-footer .col p { font-size: .92rem; }
.site-footer .bottom { border-top: 1px solid var(--border); padding: 1.2rem 1.5rem; color: var(--text-3); font-size: .84rem; text-align: center; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--text); color: var(--bg); padding: .75rem 1.1rem; border-radius: 10px; font-size: .9rem; font-weight: 500; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 100; display: flex; align-items: center; gap: .55rem; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .tled { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.success .tled { background: var(--success); }
.toast.error .tled { background: var(--danger); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.row { display: flex; align-items: center; gap: .55rem; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }

/* ---------- Tooltip (info icon; click or hover to reveal) ---------- */
.tip { position: relative; display: inline-flex; }
.tip > .tip-btn {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-3); cursor: pointer;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 0; font-family: var(--font);
}
.tip > .tip-btn:hover { color: var(--text); border-color: var(--text-3); }
.tip > .tip-bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 260px; padding: .6rem .75rem;
  background: var(--text); color: var(--bg); border-radius: 10px; font-size: .78rem; font-weight: 400;
  line-height: 1.45; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .16s ease, transform .16s ease; z-index: 40; text-align: left;
}
.tip > .tip-bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--text);
}
.tip.open > .tip-bubble, .tip:hover > .tip-bubble { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 520px) {
  .tip > .tip-bubble { left: auto; right: 0; transform: translateY(4px); max-width: 220px; }
  .tip > .tip-bubble::after { left: auto; right: 6px; transform: none; }
  .tip.open > .tip-bubble { transform: translateY(0); }
}

/* ---------- Page transitions (soft fade) ---------- */
@media (prefers-reduced-motion: no-preference) {
  main { animation: pageIn .34s cubic-bezier(.22,.61,.36,1) both; }
  body { transition: opacity .2s ease; }
  body.is-leaving { opacity: 0; }
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace .rail { display: none; }
}

@media (max-width: 860px) {
  :root { --header-h: 56px; }
  .container { padding-inline: 1.1rem; }
  .nav { display: none; }
  .menu-btn { display: grid; }
  .hero { padding: 2rem 0 1.25rem; }
  .segmented { display: flex; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented a, .segmented button { flex: 1 0 auto; }
  .site-footer .inner { grid-template-columns: 1fr; gap: 1.75rem; }
}

@media (max-width: 620px) {
  .card-pad { padding: 1.15rem; }
  .form-row { flex-direction: column; align-items: stretch; gap: .85rem; }
  .form-row > * { width: 100%; }
  .form-row .input, .form-row .select, .code-input { width: 100% !important; }
  .btn-lg { padding: .8rem 1.1rem; }
  .code-display { font-size: 1.7rem; letter-spacing: .3rem; }
  .card-head { flex-direction: column; }
  .section { padding-block: 2.25rem; }
  .row.between { flex-direction: column; align-items: flex-start; gap: .6rem; }
}
