:root {
  color-scheme: light;
  --bg: #f7fafc;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #16202a;
  --muted: #637083;
  --border: #dce5ee;
  --accent: #0f8b8d;
  --accent-strong: #0a6466;
  --accent-contrast: #ffffff;
  --warn: #d97706;
  --shadow: 0 24px 70px rgba(20, 32, 42, 0.14);
  --radius: 8px;
  --page: min(1120px, calc(100% - 32px));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101820;
  --surface: #17232d;
  --surface-soft: #20303b;
  --text: #f2f7fb;
  --muted: #a7b6c4;
  --border: #2e4352;
  --accent: #4bc3b5;
  --accent-strong: #87ddd4;
  --accent-contrast: #062527;
  --warn: #f2a33a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #101820;
    --surface: #17232d;
    --surface-soft: #20303b;
    --text: #f2f7fb;
    --muted: #a7b6c4;
    --border: #2e4352;
    --accent: #4bc3b5;
    --accent-strong: #87ddd4;
    --accent-contrast: #062527;
    --warn: #f2a33a;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28rem),
    linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--surface-soft) 56%, var(--bg)));
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 46%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 10;
  transform: translateY(-120%);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 14px;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.site-footer {
  width: var(--page);
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  display: block;
}

.controls,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-nav {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.main-nav a {
  border-radius: var(--radius);
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--text);
}

.segmented {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  padding: 4px;
}

.segment,
.icon-button,
.text-button {
  min-height: 40px;
  border-radius: var(--radius);
  color: var(--text);
}

.segment {
  min-width: 44px;
  background: transparent;
  font-weight: 800;
}

.segment.active {
  background: var(--text);
  color: var(--bg);
}

.icon-button {
  display: grid;
  width: 44px;
  place-items: center;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}

.icon-button svg {
  width: 20px;
  fill: currentColor;
}

.page-shell {
  display: grid;
  width: var(--page);
  margin: 18px auto 0;
  grid-template-columns: minmax(280px, 430px) minmax(0, 1fr);
  grid-template-areas:
    "calculator intro"
    "calculator history";
  gap: 24px;
  align-items: start;
}

.intro {
  grid-area: intro;
  padding: clamp(24px, 4vw, 56px) 0 6px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.small {
  margin-bottom: 4px;
  font-size: 0.72rem;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.lede {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.7;
}

.feature-list {
  display: grid;
  max-width: 650px;
  margin: 28px 0 0;
  padding: 0;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  list-style: none;
}

.feature-list li {
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  padding: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.feature-icon {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent-strong);
  font-weight: 900;
}

.calculator-panel,
.history-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.calculator-panel {
  grid-area: calculator;
  padding: 18px;
}

.calculator-panel.alicia-calculator {
  max-width: 430px;
  justify-self: start;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.alicia-title {
  margin: 0 0 12px;
  text-align: center;
  text-transform: uppercase;
}

.alicia-topbar {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 10px;
  margin-bottom: 10px;
}

.view-button {
  width: 100%;
  min-height: 52px;
  text-transform: uppercase;
}

.screen-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-card {
  grid-area: history;
  padding: 18px;
}

.panel-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-topline.compact {
  margin-bottom: 10px;
}

.text-button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.display {
  display: grid;
  min-height: 132px;
  align-content: end;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 72%, transparent), var(--surface));
  padding: 18px;
  text-align: right;
}

.alicia-display {
  min-height: 104px;
  background: #f9fbfd;
}

:root[data-theme="dark"] .alicia-display {
  background: #111d26;
}

.expression {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

.result {
  display: block;
  min-height: 58px;
  color: var(--text);
  font-size: clamp(2.2rem, 8vw, 3.8rem);
  font-weight: 850;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.keypad {
  display: grid;
  margin-top: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.alicia-keypad {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.key {
  display: grid;
  min-height: 64px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 850;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.alicia-keypad .key {
  min-height: 58px;
  font-size: 1.12rem;
}

.key.special {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent-strong);
  text-transform: lowercase;
}

.zero-key {
  grid-column: span 1;
}

.equals-key {
  grid-column: span 5;
}

.key:hover {
  background: color-mix(in srgb, var(--surface-soft) 76%, var(--surface));
}

.key:active {
  transform: translateY(1px) scale(0.99);
}

.key.muted {
  color: var(--muted);
}

.key.operator {
  background: color-mix(in srgb, var(--warn) 16%, var(--surface));
  color: color-mix(in srgb, var(--warn) 78%, var(--text));
}

.key.equals {
  background: var(--accent);
  color: var(--accent-contrast);
}

.alicia-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.option-button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.option-button.active {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--accent-strong);
}

.mode-help,
.form-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.steps-panel {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-soft) 70%, transparent);
  margin-top: 12px;
  padding: 12px;
}

.steps-panel.is-visible {
  display: block;
}

.steps-panel pre {
  margin: 0;
  color: var(--muted);
  font: 800 0.98rem/1.45 "Cascadia Mono", "Consolas", "Courier New", monospace;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

.history-list {
  display: grid;
  max-height: 240px;
  margin: 0;
  padding: 0;
  gap: 8px;
  list-style: none;
  overflow: auto;
}

.history-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-soft) 60%, transparent);
  padding: 10px 12px;
  color: var(--muted);
  line-height: 1.45;
}

.history-list .history-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.history-result {
  color: var(--text);
  font-weight: 850;
}

.site-footer {
  padding: 34px 0 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 24px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.footer-brand {
  margin-bottom: 10px;
}

.footer-links,
.social-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-links {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.footer-links a,
.info-panel a {
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.footer-links a:hover,
.info-panel a:hover {
  color: var(--text);
}

.social-links a {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text);
}

.social-links svg {
  width: 20px;
  fill: currentColor;
}

.content-page {
  width: var(--page);
  margin: 28px auto 0;
}

.content-block {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: clamp(20px, 3vw, 30px);
}

.home-content {
  margin-top: 4px;
}

.rich-text {
  max-width: 900px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.rich-text h2,
.rich-text h3 {
  color: var(--text);
  line-height: 1.22;
}

.rich-text h2 {
  margin: clamp(30px, 5vw, 52px) 0 14px;
  font-size: clamp(1.45rem, 2.8vw, 2.15rem);
}

.rich-text h2:first-child {
  margin-top: 0;
}

.rich-text h3 {
  margin: 24px 0 8px;
  font-size: 1.08rem;
}

.rich-text p {
  margin: 0 0 14px;
}

.rich-text ul,
.rich-text ol {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
  padding-left: 22px;
}

.rich-text li {
  padding-left: 4px;
}

.content-figure {
  margin: clamp(24px, 4vw, 42px) 0;
}

.content-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(20, 32, 42, 0.12);
}

.content-figure-dark img {
  background: #101820;
}

.content-figure figcaption {
  max-width: 760px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.55;
  text-align: center;
}

.content-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.content-columns article {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}

.content-columns h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1rem;
}

.content-columns p {
  margin: 0;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.faq-list details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
}

.faq-list summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 900;
}

.faq-list p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.content-page.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 24px;
  align-items: start;
}

.content-page.two-column .page-intro {
  grid-column: 1 / -1;
}

.page-intro {
  max-width: 760px;
  margin-bottom: 24px;
}

.form-panel,
.posts-panel,
.info-panel,
.blog-card,
.readable {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 20px;
}

.publisher-form {
  display: grid;
  gap: 14px;
}

.publisher-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.publisher-form input,
.publisher-form select,
.publisher-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  line-height: 1.4;
}

.link-params-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-help {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.primary-button {
  min-height: 46px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0 18px;
  font-weight: 900;
}

.post-list,
.blog-grid {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.post-row small {
  color: var(--muted);
  line-height: 1.5;
}

.post-row span,
.blog-card p,
.article-body,
.info-panel p,
.readable p {
  color: var(--muted);
  line-height: 1.7;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 900;
}

.blog-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.blog-card h2,
.readable h2,
.info-panel h2 {
  margin: 0 0 10px;
}

.article-body {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.readable {
  max-width: 860px;
}

.login-panel {
  grid-column: 1 / -1;
  max-width: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 22px;
}

.editor-panel {
  align-self: start;
}

.seo-panel {
  position: sticky;
  top: 14px;
}

.published-panel {
  grid-column: 1 / -1;
}

.status-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  color: color-mix(in srgb, var(--warn) 78%, var(--text));
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 950;
}

.status-pill[data-score="good"] {
  background: color-mix(in srgb, #16a34a 16%, var(--surface));
  color: color-mix(in srgb, #15803d 86%, var(--text));
}

.status-pill[data-score="ok"] {
  background: color-mix(in srgb, #eab308 18%, var(--surface));
  color: color-mix(in srgb, #a16207 82%, var(--text));
}

.serp-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.serp-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.serp-preview h3 {
  margin: 6px 0;
  color: #1a0dab;
  font-size: 1.05rem;
  line-height: 1.35;
}

:root[data-theme="dark"] .serp-preview h3 {
  color: #8ab4f8;
}

.seo-checklist {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.seo-checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}

.seo-checklist li::before {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 950;
}

.seo-checklist .pass::before {
  content: "OK";
  background: color-mix(in srgb, #16a34a 18%, var(--surface));
  color: #15803d;
}

.seo-checklist .fail::before {
  content: "!";
  background: color-mix(in srgb, var(--warn) 18%, var(--surface));
  color: color-mix(in srgb, var(--warn) 78%, var(--text));
}

.content-page.is-locked > :not(.login-panel) {
  display: none;
}

.ad-slot {
  display: grid;
  gap: 10px;
}

.ad-placeholder {
  display: grid;
  min-height: 120px;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 36%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-soft) 78%, transparent);
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 16px;
}

[hidden] {
  display: none !important;
}

.readable h1 {
  margin-bottom: 18px;
}

@media (max-width: 860px) {
  .page-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "calculator"
      "intro"
      "history";
  }

  .intro {
    padding-top: 18px;
  }

  .feature-list {
    grid-template-columns: 1fr;
  }

  .content-columns,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-links,
  .social-links {
    justify-content: flex-start;
  }

  .calculator-panel.alicia-calculator {
    justify-self: stretch;
    max-width: none;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .main-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .content-page.two-column,
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .link-params-grid {
    grid-template-columns: 1fr;
  }

  .seo-panel {
    position: static;
  }
}

@media (max-width: 1080px) {
  .content-page.two-column {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  }
}

@media (max-width: 520px) {
  :root {
    --page: min(100% - 24px, 1120px);
  }

  .site-header {
    align-items: flex-start;
  }

  .brand span {
    max-width: 130px;
  }

  .calculator-panel,
  .history-card {
    padding: 14px;
  }

  .panel-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .text-button {
    width: 100%;
  }

  .key {
    min-height: 58px;
  }

  .alicia-keypad {
    gap: 8px;
  }

  .alicia-keypad .key {
    min-height: 52px;
  }

  .alicia-topbar,
  .alicia-options {
    grid-template-columns: 1fr;
  }
}

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