* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-a: #0f172a;
  --bg-b: #1e293b;
  --card: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --input-bg: rgba(255, 255, 255, 0.92);
  --input-text: #0f172a;
  --danger: #f97316;
}

body.light {
  --bg-a: #dbeafe;
  --bg-b: #bfdbfe;
  --card: rgba(255, 255, 255, 0.7);
  --border: rgba(255, 255, 255, 0.8);
  --text: #0f172a;
  --muted: #334155;
  --input-bg: rgba(255, 255, 255, 0.95);
  --input-text: #0f172a;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, var(--bg-a), var(--bg-b));
  min-height: 100vh;
  padding: 20px;
  color: var(--text);
}

.tp-app { max-width: 960px; margin: auto; }

.tp-card {
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.headingRow { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.headerActions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
h1 { font-size: 30px; margin-bottom: 8px; }
.sub { color: var(--muted); margin-bottom: 24px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
select, input {
  padding: 12px; border-radius: 12px; border: none; font-size: 15px;
  background: var(--input-bg); color: var(--input-text);
}
input[type="range"] { padding: 0; }

button {
  border: none; background: #2563eb; color: #fff; padding: 12px 16px;
  border-radius: 12px; cursor: pointer; font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
button:hover { background: #1d4ed8; transform: translateY(-1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.hidden { display: none !important; }

.chip-btn { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.2); display: inline-flex; align-items: center; gap: 6px; }
.secondary-btn { background: rgba(255,255,255,0.14); }
.ghostBtn { background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.2); }
.dangerBtn { background: var(--danger); }

.result {
  margin-top: 24px; background: rgba(255, 255, 255, 0.06); border-radius: 20px;
  padding: 20px; text-align: center; transition: 0.4s ease;
}
.big { font-size: 40px; font-weight: 900; margin-bottom: 14px; }
.split { display: flex; justify-content: space-around; margin-bottom: 16px; gap: 10px; }
.split div { background: rgba(255, 255, 255, 0.07); padding: 12px; border-radius: 14px; width: 100%; }
.split strong { display: block; font-size: 22px; margin-top: 6px; }

.gaugeWrap { margin: 6px 0 18px; }
.gaugeTrack { width: 100%; height: 14px; border-radius: 999px; background: #1e293b; position: relative; overflow: hidden; }
.gaugeNeedle {
  position: absolute; top: -4px; width: 22px; height: 22px; border-radius: 999px;
  background: #22d3ee; border: 3px solid #fff; transform: translateX(-50%); left: 50%; transition: left 0.35s ease;
}

.barsWrap { margin-bottom: 12px; }
.compareRow { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 12px; margin: 10px 0; text-align: left; }
.rangeBar { height: 12px; background: #1e293b; border-radius: 999px; overflow: hidden; }
.fill { height: 100%; width: 30%; background: linear-gradient(90deg, #22c55e, #3b82f6); transition: width 0.35s ease, background 0.35s ease; }
.fill.blue { background: linear-gradient(90deg, #38bdf8, #2563eb); }
.fill.cyan { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.fill.green { background: linear-gradient(90deg, #22c55e, #84cc16); }
.fill.violet { background: linear-gradient(90deg, #a855f7, #6366f1); }

.variants { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.variants div { text-align: left; background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 10px; }
.variants strong { display: block; margin-top: 6px; }
.warning { margin-top: 14px; color: #86efac; font-weight: 700; }
.warning.warn { color: #facc15; }
.warning.danger { color: #fb7185; }

.actions { margin-top: 20px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.expertPanel { margin-top: 20px; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 14px; padding: 12px; background: rgba(255, 255, 255, 0.04); }
.expertPanel summary { cursor: pointer; font-weight: 700; }
.expertGrid { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trustBlock, .seoBlock { margin-top: 18px; background: rgba(255, 255, 255, 0.05); border-radius: 14px; padding: 14px; }
.seoBlock h2 { font-size: 18px; margin-bottom: 8px; }

.statusLow .big, .statusLow .split strong { color: #facc15; }
.statusHigh .big, .statusHigh .split strong { color: #fb7185; }

.tool-extra-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.tool-toggle-btn {
  background: linear-gradient(135deg, #ffffff, #f8fafc); color: #0f172a; border: 1px solid #e2e8f0;
  padding: 14px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.tool-toggle-btn:hover { background: linear-gradient(135deg, #f1f5f9, #ffffff); border-color: #cbd5e1; box-shadow: 0 10px 25px rgba(15, 23, 42, 0.10); }

.popup-overlay, .legal-popup-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: none;
  align-items: center; justify-content: center; z-index: 99999; padding: 20px;
}
.popup-overlay.active, .legal-popup-overlay.active { display: flex; animation: fadeIn 0.25s ease; }
.popup-box, .legal-popup-box {
  width: 100%; max-width: 720px; background: #ffffff; color: #111827; border-radius: 24px;
  padding: 28px; box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25); position: relative; animation: popIn 0.28s ease;
  max-height: calc(100vh - 40px); overflow: auto;
}
.legal-popup-box { max-width: 520px; text-align: center; }
.popup-close {
  position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 1px solid #e5e7eb;
  border-radius: 50%; background: #f1f5f9; color: #111827; font-size: 18px; cursor: pointer;
}
.popup-close:hover { background: #e2e8f0; }
textarea {
  width: 100%; min-height: 180px; margin-top: 12px; border: 1px solid #d1d5db; border-radius: 14px;
  padding: 14px; resize: vertical; font-family: monospace;
}
.copy-btn { margin-top: 14px; background: #10b981; }
.copy-btn:hover { background: #059669; }

.top-ad, .bottom-ad { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 90px; margin: 10px 0; }
.top-ad ins.adsbygoogle, .bottom-ad ins.adsbygoogle { display: block !important; width: 100%; max-width: 960px; margin: 0 auto; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr 1fr; }
  .compareRow { grid-template-columns: 1fr; gap: 6px; }
  .headerActions { justify-content: flex-start; }
}

@media (max-width: 700px) {
  .headingRow { flex-direction: column; }
  .big { font-size: 34px; }
  .variants, .expertGrid, .actions { grid-template-columns: 1fr; }
  .popup-box, .legal-popup-box { padding: 22px; border-radius: 18px; }
  .tool-extra-actions { flex-direction: column; }
  .tool-toggle-btn { width: 100%; }
}
