/* ============================================================
   360tools Online — Design System
   Professional · Elegant · 100% Responsive
   ============================================================ */

:root {
  --font: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #17203a;
  --text-2: #5a6480;
  --text-3: #8b93ab;
  --border: #e5e8f0;
  --accent: #4f46e5;
  --accent-2: #0ea5a4;
  --brand-mark-fg: #ffffff;
  --brand-mark-from: #4f46e5;
  --brand-mark-to: #0ea5a4;
  --accent-soft: #eef0ff;
  --accent-2-soft: #e6fbfa;
  --success: #16a34a;
  --success-soft: #e8f8ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;

  --shadow-sm: 0 1px 2px rgba(23, 32, 58, .06);
  --shadow: 0 6px 24px -6px rgba(23, 32, 58, .10);
  --shadow-lg: 0 20px 48px -12px rgba(23, 32, 58, .16);
  --card-ring: inset 0 1px 0 rgba(255, 255, 255, .75);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --container: 1200px;
  --header-h: 68px;
}

[data-theme="dark"] {
  --bg: #0d111c;
  --surface: #151b2b;
  --surface-2: #1b2235;
  --text: #e9edf7;
  --text-2: #a7b0c8;
  --text-3: #7b849e;
  --border: #262f47;
  --accent: #7c74ff;
  --accent-2: #2dd4bf;
  --accent-soft: #232548;
  --accent-2-soft: #12312f;
  --success-soft: #12291b;
  --danger-soft: #2c1518;
  --warn-soft: #2c2210;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 24px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, .6);
  --card-ring: inset 0 1px 0 rgba(255, 255, 255, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111c;
    --surface: #151b2b;
    --surface-2: #1b2235;
    --text: #e9edf7;
    --text-2: #a7b0c8;
    --text-3: #7b849e;
    --border: #262f47;
    --accent: #7c74ff;
    --accent-2: #2dd4bf;
    --accent-soft: #232548;
    --accent-2-soft: #12312f;
    --success-soft: #12291b;
    --danger-soft: #2c1518;
    --warn-soft: #2c2210;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 6px 24px -6px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, .6);
    --card-ring: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(55% 45% at 88% -8%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    radial-gradient(45% 40% at 2% 2%, color-mix(in srgb, var(--accent-2) 6%, transparent), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); }

html { scrollbar-color: color-mix(in srgb, var(--text-3) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-3) 40%, transparent);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-2) 55%, transparent); background-clip: padding-box; }

img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; color: var(--text); }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }

main { flex: 1; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px) saturate(1.6);
  -webkit-backdrop-filter: blur(12px) saturate(1.6);
  border-bottom: 1px solid var(--border);
  transition: box-shadow .25s var(--ease);
}
.site-header.scrolled { box-shadow: 0 6px 20px -12px rgba(23, 32, 58, .25); }

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -.02em;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  min-width: 34px; height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-mark-from), var(--brand-mark-to));
  display: grid; place-items: center;
  color: var(--brand-mark-fg); font-size: .86rem;
  font-weight: 800;
  letter-spacing: -.03em;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.logo > span:not(.logo-mark) { color: var(--accent); }

.main-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.main-nav a {
  position: relative;
  color: var(--text-2);
  font-weight: 600;
  font-size: .95rem;
  padding: 8px 14px;
  border-radius: 8px;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.main-nav a:hover, .main-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}
.main-nav a::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px; bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s var(--ease);
}
.main-nav a:hover::after, .main-nav a.active::after { transform: scaleX(1); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-2);
  font-size: 1.05rem;
  transition: .18s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  padding: 72px 0 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto;
  height: 420px;
  background:
    radial-gradient(50% 60% at 30% 40%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    radial-gradient(45% 55% at 70% 35%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent);
  pointer-events: none;
}
.hero > * { position: relative; }

.hero h1 {
  font-size: clamp(1.9rem, 4.6vw, 3.2rem);
  line-height: 1.15;
  letter-spacing: -.03em;
  font-weight: 800;
  max-width: 820px;
  margin: 0 auto 16px;
}
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  color: var(--text-2);
  font-size: clamp(1rem, 2vw, 1.15rem);
  max-width: 640px;
  margin: 0 auto 28px;
}

.hero-search {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: 15px 52px 15px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  transition: .18s;
}
.hero-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.hero-search button {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
}
.hero-search input { padding-right: 92px; }
.hero-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.hero-search .search-clear {
  right: 52px;
  width: 32px; height: 32px;
  background: transparent;
  color: var(--text-3);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
}
.hero-search .search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-status { margin: 14px auto 0; min-height: 1.2em; color: var(--text-3); font-size: .9rem; font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- Sections / Headings ---------- */
.section { padding: 48px 0; }
.section-head { margin-bottom: 24px; }
.section-head h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -.02em;
  font-weight: 800;
}
.section-head p { color: var(--text-2); margin-top: 6px; }
.section-head .see-all { font-size: .92rem; font-weight: 600; }
.section-head .count {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  vertical-align: middle;
  margin-left: 6px;
}
.cat-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.cat-jump a {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.cat-jump a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

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

@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm), var(--card-ring);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease);
  display: block;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--card-ring);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  text-decoration: none;
}

.tool-card { position: relative; }
.tool-card .tool-icon {
  width: 56px; height: 56px;
  border-radius: 15px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  margin-bottom: 14px;
  transition: transform .22s var(--ease), background .22s var(--ease);
}
.tool-card:hover .tool-icon { transform: scale(1.06) rotate(-3deg); }
.tool-icon .ic { width: 30px; height: 30px; }
.tool-card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  margin-bottom: 4px;
}
.tool-card p { font-size: .87rem; color: var(--text-2); line-height: 1.5; }

.cat-card { text-align: left; }
.cat-card .tool-icon {
  width: 56px; height: 56px;
  border-radius: 15px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  margin-bottom: 14px;
}
.cat-card h3 { font-size: 1.05rem; margin-bottom: 4px; font-weight: 700; }
.cat-card .count { font-size: .82rem; color: var(--text-3); font-weight: 600; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  padding: 16px 0 0;
  font-size: .84rem;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: .5; }

/* ---------- Page layout (tool pages) ---------- */
.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 32px;
  padding: 24px 0 56px;
  align-items: start;
}
.page-grid > * { min-width: 0; }
@media (max-width: 1024px) {
  .page-grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
}

.tool-header { margin-bottom: 20px; }
.tool-header .category-chip {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.tool-header h1 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  letter-spacing: -.025em;
  font-weight: 800;
  line-height: 1.2;
}
.tool-header .subtitle { color: var(--text-2); margin-top: 8px; font-size: 1.02rem; }
.tool-header .meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: .82rem;
  color: var(--text-3);
  font-weight: 600;
}
.tool-header .meta-line .dot { color: var(--border); }

/* ---------- Tool panel ---------- */
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), var(--card-ring);
  overflow: hidden;
  margin-bottom: 28px;
}
.tool-panel-body { padding: 26px; }
@media (max-width: 480px) { .tool-panel-body { padding: 18px; } }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.tool-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-grid.cols-1 { grid-template-columns: 1fr; }
.tool-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .tool-grid, .tool-grid.cols-3 { grid-template-columns: 1fr; }
  .tool-grid .span-2 { grid-column: span 1; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-2);
}
.field .hint { font-size: .78rem; color: var(--text-3); font-weight: 500; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  transition: .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 120px; font-size: .92rem; line-height: 1.55; }
.field textarea.mono, .field input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .95rem;
  transition: .16s;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  color: #fff;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; }

/* Results */
.result-box {
  margin-top: 20px;
  padding: 20px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
}
.result-box h3 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 12px;
}
.result-main {
  font-size: clamp(1.75rem, 4.4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1.12;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}
.result-sub { color: var(--text-2); font-size: .92rem; margin-top: 6px; }

.result-rows { display: grid; gap: 8px; margin-top: 4px; }
.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
}
.result-row .k { color: var(--text-2); }
.result-row .v { font-weight: 700; text-align: right; word-break: break-word; font-variant-numeric: tabular-nums; }

/* Reserve space for outputs and previews to avoid layout shift (CLS) */
.result { display: grid; gap: 8px; margin-top: 14px; min-height: 120px; }
[id$="-prev"], .preview { min-height: 24px; }
[id$="-prev"] img, .preview img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

.amort { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.amort th, .amort td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.amort th:first-child, .amort td:first-child { text-align: left; }
.amort thead th { background: var(--surface-2); color: var(--text-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
#mc-schedule h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 800; margin: 4px 0 10px; }

.out-area {
  width: 100%;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem;
  line-height: 1.55;
  resize: vertical;
  color: var(--text);
  margin-top: 14px;
}
.out-area.err { border-color: var(--danger); background: var(--danger-soft); }

.stat-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill {
  font-size: .8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.pill strong { color: var(--text); }

.empty-note { color: var(--text-3); font-size: .9rem; margin-top: 14px; font-style: italic; }

/* ---------- Guide / article ---------- */
.guide {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 480px) { .guide { padding: 20px; } }

.guide h2 {
  font-size: 1.35rem;
  letter-spacing: -.02em;
  margin: 30px 0 12px;
  font-weight: 800;
}
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 1.08rem; margin: 22px 0 8px; font-weight: 700; }
.guide p { margin-bottom: 14px; color: var(--text-2); }
.guide ul, .guide ol { margin: 0 0 16px 22px; color: var(--text-2); }
.guide li { margin-bottom: 7px; }
.guide strong { color: var(--text); }
.guide table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 20px;
  font-size: .9rem;
}
.guide table, .prose-page table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.guide pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.guide th, .guide td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}
.guide th { background: var(--surface-2); font-weight: 700; }
.guide code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .86em;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* FAQ accordion */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.faq-q {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 15px 18px;
  font-weight: 700;
  font-size: .97rem;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.faq-q::after { content: "+"; color: var(--accent); font-size: 1.3rem; font-weight: 400; transition: .2s; }
.faq-item.open .faq-q::after { transform: rotate(45deg); }
.faq-a {
  display: none;
  padding: 0 18px 16px;
  color: var(--text-2);
  font-size: .94rem;
}
.faq-item.open .faq-a { display: block; }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: calc(var(--header-h) + 16px); }
.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.side-card h4 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  font-weight: 800;
  margin-bottom: 12px;
}
.side-list { list-style: none; display: grid; gap: 4px; }
.side-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: .9rem;
  font-weight: 600;
}
.side-list a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* ---------- Ad slots (all standard AdSense sizes) ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-inline: auto;
  position: relative;
  color: var(--text-3);
}
.ad-slot::before {
  content: "Advertisement";
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  opacity: .7;
}

.ad-slot--300x250 { width: 300px; max-width: 100%; height: 250px; }
.ad-slot--336x280 { width: 336px; max-width: 100%; height: 280px; }
.ad-slot--300x600 { width: 300px; max-width: 100%; height: 600px; }
.ad-slot--160x600 { width: 160px; max-width: 100%; height: 600px; }
.ad-slot--728x90  { width: 728px; max-width: 100%; height: 90px; }
.ad-slot--970x90  { width: 970px; max-width: 100%; height: 90px; }
.ad-slot--970x250 { width: 970px; max-width: 100%; height: 250px; }
.ad-slot--320x50  { width: 320px; max-width: 100%; height: 50px; }
.ad-slot--320x100 { width: 320px; max-width: 100%; height: 100px; }

.ad-wrap { display: flex; justify-content: center; padding: 8px 0; }

/* desktop/mobile visibility */
@media (max-width: 1023px) {
  .ad-desktop { display: none !important; }
}
@media (min-width: 1024px) {
  .ad-mobile { display: none !important; }
}

/* sticky mobile ad */
.ad-sticky {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  display: none;
}
@media (max-width: 767px) {
  .ad-sticky { display: block; }
  body { padding-bottom: 74px; }
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 48px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 44px 0 28px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-grid h5 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  font-weight: 800;
  margin-bottom: 14px;
}
.footer-grid ul { list-style: none; display: grid; gap: 8px; }
.footer-grid a { color: var(--text-2); font-size: .92rem; font-weight: 500; }
.footer-grid a:hover { color: var(--accent); }
.footer-cats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 16px 0; margin-bottom: 20px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.footer-cats strong { color: var(--text); font-size: .85rem; margin-right: 4px; }
.footer-cats a {
  color: var(--text-2); font-size: .8rem; font-weight: 600;
  padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px;
}
.footer-cats a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.footer-about { color: var(--text-2); font-size: .92rem; max-width: 340px; margin-top: 12px; }

/* 360 Developers partnership badge */
.partner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin-top: 16px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
}
.partner:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.partner strong { color: var(--text); }
.partner-logo {
  display: block;
  width: 118px;
  height: auto;
  background: transparent;
}
.prose-page .partner-card {
  display: inline-block;
  margin: 4px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
}
.prose-page .partner-card img { display: block; width: 160px; height: auto; }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  color: var(--text-3);
  font-size: .85rem;
}
.footer-bottom a { color: var(--accent); font-weight: 600; }
.footer-bottom a:hover { text-decoration: underline; }

/* ---------- Static page / prose ---------- */
.prose-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 0 56px;
}
.prose-page h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  letter-spacing: -.03em;
  font-weight: 800;
  margin-bottom: 10px;
}
.prose-page .updated { color: var(--text-3); font-size: .87rem; margin-bottom: 28px; }
.prose-page h2 { font-size: 1.3rem; margin: 30px 0 12px; font-weight: 800; }
.prose-page p, .prose-page li { color: var(--text-2); margin-bottom: 12px; }
.prose-page ul { margin-left: 22px; }

/* ---------- Notices ---------- */
.notice {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  margin-bottom: 20px;
  border: 1px solid;
}
.notice-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text-2); }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text-2); }

/* ---------- Misc ---------- */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
}
.text-grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Cookie consent banner */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateY(120%);
  transition: transform .3s ease;
}
.cookie-banner.show { transform: translateY(0); }
.cookie-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding-block: 14px;
}
.cookie-inner p { margin: 0; color: var(--text-2); font-size: .9rem; line-height: 1.5; max-width: 760px; }
.cookie-actions { display: flex; gap: 10px; flex: none; }
@media (max-width: 640px) {
  .cookie-inner { padding-block: 12px; }
  .cookie-actions { width: 100%; }
  .cookie-actions .btn { flex: 1; }
}

/* Back to top */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 24px -6px color-mix(in srgb, var(--accent) 55%, transparent), var(--shadow-sm);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.9);
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease, box-shadow .25s ease;
  z-index: 190;
  -webkit-tap-highlight-color: transparent;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.to-top:hover { transform: translateY(-4px); box-shadow: 0 16px 32px -8px color-mix(in srgb, var(--accent) 65%, transparent); }
.to-top:active { transform: translateY(-1px) scale(.96); }
.to-top-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.tt-track { fill: none; stroke: rgba(255, 255, 255, .3); stroke-width: 3; }
.tt-prog {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset .1s linear;
}
.tt-arrow { position: relative; display: block; }
@media (max-width: 640px) {
  .to-top { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .to-top, .to-top:hover, .to-top:active { transition: opacity .2s ease, visibility .2s ease; transform: none; }
}

/* ---------- Heading icons ---------- */
.head-ic, .hub-ic {
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: -0.34em;
}
.head-ic { width: 1.55em; height: 1.55em; border-radius: 10px; margin-right: .12em; }
.hub-ic { width: 1.5em; height: 1.5em; border-radius: 13px; margin-right: .1em; }
.head-ic .ic, .hub-ic .ic { width: 72%; height: 72%; }

/* ---------- Result copy button ---------- */
.result-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 7px 13px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.result-copy:hover { color: var(--accent); border-color: var(--accent); }
.result-copy:active { transform: scale(.97); }
.result-copy .ic { width: 15px; height: 15px; }
.result-copy.done { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }

/* ---------- Scroll reveal (progressive enhancement) ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .tool-card:hover .tool-icon { transform: none; }
  .card:hover { transform: none; }
  .main-nav a::after { transition: none; }
}

/* 404 */
.err-page { text-align: center; padding: 90px 20px; }
.err-page .code { font-size: clamp(4rem, 14vw, 7rem); font-weight: 800; letter-spacing: -.05em; }
.err-page h1 { margin: 6px 0 10px; }
.err-page p { color: var(--text-2); margin-bottom: 24px; }

/* focus a11y */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 900px) {
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px 18px;
    gap: 4px;
    display: none;
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px 14px; }
  .nav-toggle { display: grid; }
}

/* ---- Backend-driven UI (js/dynamic.js + js/site-config.js) ---- */
.announce-bar { font-size: .9rem; font-weight: 500; text-align: center; }
.announce-inner { padding: 9px 0; }
.announce-bar a { color: inherit; text-decoration: underline; font-weight: 600; }
.announce-info { background: var(--accent); color: #fff; }
.announce-success { background: var(--success); color: #fff; }
.announce-warning { background: var(--warn); color: #fff; }

.form-status { margin: 0; padding: 11px 14px; border-radius: var(--radius-sm); font-size: .9rem; }
.form-status.ok { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.form-status.err { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

.maint-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(13, 17, 28, .72); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(3px); }
.maint-card { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; max-width: 440px; text-align: center; }
.maint-card h3 { margin: 0 0 8px; }
.maint-card p { color: var(--text-2); margin: 0 0 18px; }
