:root {
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --bg-grad-1: #0f172a;
  --bg-grad-2: #1e293b;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #f8fafc;
  --shadow: 0 20px 60px -15px rgba(2, 6, 23, 0.55);
  --radius: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px 18px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, #334155 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 10%, #b45309 0%, transparent 45%),
              linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 600px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 26px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

/* ---------- Layout (card + keyword panel to the right on desktop) ---------- */
.layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.density-panel--empty { display: none; }  /* hide the empty placeholder on mobile */

@media (min-width: 900px) {
  .layout {
    display: grid;
    grid-template-columns: 600px 260px;
    grid-template-areas:
      "card    density"
      "ad      ."
      "footer  .";
    justify-content: center;
    align-items: start;
    column-gap: 18px;
    row-gap: 22px;
  }
  .card { grid-area: card; }
  .density-panel { grid-area: density; align-self: start; width: 260px; }
  .adslot { grid-area: ad; }
  .site-footer { grid-area: footer; }
  .density-panel--empty { display: block; }  /* show the placeholder panel on desktop */
}
.card__header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.card__heading { flex: 1; min-width: 0; }
.logo {
  width: 48px; height: 48px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 14px; box-shadow: 0 8px 20px -6px var(--accent-dark);
}
.logo svg { width: 24px; height: 24px; }
.card__header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 3px; }

/* ---------- Editor ---------- */
.editor {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  padding: 16px;
  font-family: inherit;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #fff; }
.editor::placeholder { color: #cbd5e1; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 18px; min-height: 34px; }
.toolbar__hint { color: var(--text-muted); font-size: 0.82rem; font-weight: 500; }
.toolbar__actions { display: flex; gap: 8px; margin-left: auto; }
.tbtn {
  padding: 8px 16px; font-size: 0.85rem; font-weight: 700; font-family: inherit;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
  border-radius: 999px; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.tbtn:hover { border-color: var(--accent); }
.tbtn:active { transform: scale(0.97); }
.tbtn--clear:hover { border-color: #ef4444; color: #dc2626; background: #fef2f2; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 10px; }
.stat {
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 12px; text-align: center; display: flex; flex-direction: column; gap: 3px;
}
.stat .num { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat--primary { background: var(--accent-soft); border-color: rgba(245, 158, 11, 0.35); }
.stat--primary .num { color: var(--accent-dark); font-size: 1.9rem; }
.stat--primary .lbl { color: var(--accent-dark); }

/* ---------- Keyword density panel ---------- */
.density-panel {
  width: 100%; max-width: 600px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
}
.density-panel h2 { font-size: 0.82rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 14px; }
.density__list { list-style: none; display: flex; flex-direction: column; gap: 11px; }
.density__row { display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.density__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.density__word { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.density__count { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.density__bar { height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; }
.density__bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 999px; }
.density__empty { color: var(--text-muted); font-size: 0.86rem; line-height: 1.6; }
.density-panel .density__empty { display: none; }
.density-panel--empty .density__empty { display: block; }
.density-panel--empty .density__list { display: none; }

/* ---------- Ad slot ---------- */
.adslot {
  width: 100%; max-width: 600px; min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04); border: 1px dashed rgba(148,163,184,0.35);
  border-radius: var(--radius-sm); color: rgba(148,163,184,0.7); font-size: 0.8rem;
}

/* ---------- Footer ---------- */
.site-footer {
  width: 100%; max-width: 600px; display: flex; justify-content: flex-end; align-items: center; gap: 18px;
  padding: 4px 6px 0; color: rgba(148,163,184,0.75); font-size: 0.8rem;
}
.site-footer .copy { margin-right: auto; }
.site-footer a { color: rgba(203,213,225,0.85); text-decoration: none; font-weight: 500; }
.site-footer a:hover { color: #fff; text-decoration: underline; }

/* ---------- Document pages (About / Privacy / Guide) ---------- */
.doc {
  width: 100%; max-width: 720px; background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 34px 30px; border: 1px solid rgba(255,255,255,0.6);
}
.doc__brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); margin-bottom: 22px; }
.doc__brand .logo { width: 40px; height: 40px; }
.doc__brand .logo svg { width: 20px; height: 20px; }
.doc__brand span { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.doc h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.doc .updated { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.doc .lead { font-size: 1.06rem; color: #475569; line-height: 1.7; }
.doc h2 { font-size: 1.1rem; font-weight: 700; margin: 24px 0 8px; }
.doc h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 4px; }
.doc p, .doc li { color: #334155; font-size: 0.96rem; line-height: 1.7; }
.doc p { margin-bottom: 12px; }
.doc ul { margin: 0 0 12px 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc .callout { background: var(--accent-soft); border: 1px solid rgba(245,158,11,0.25); border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 18px; margin: 20px 0; }
.doc .callout p { margin: 0; color: var(--accent-dark); font-weight: 500; }
.doc .faq h3 { font-size: 1.02rem; font-weight: 700; margin: 20px 0 4px; color: var(--text); }
.doc .table-wrap { overflow-x: auto; margin: 14px 0 20px; -webkit-overflow-scrolling: touch; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 360px; }
.doc th, .doc td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--text); font-weight: 700; background: var(--input-bg); }
.doc td { color: #334155; line-height: 1.5; }
.doc td:first-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.doc .back {
  display: inline-block; margin-top: 24px; padding: 11px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem;
}
.doc .back:hover { filter: brightness(1.08); text-decoration: none; }

@media (max-width: 480px) {
  .card { padding: 24px 20px 22px; }
  .doc { padding: 24px 20px 22px; }
  .card__header h1 { font-size: 1.25rem; }
  .stat--primary .num { font-size: 1.6rem; }
  .density__row { grid-template-columns: 90px 1fr auto; }
  .site-footer { justify-content: center; flex-wrap: wrap; gap: 12px; }
  .site-footer .copy { margin-right: 0; width: 100%; text-align: center; }
}
