:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #17202a;
  --muted: #5d6b7a;
  --line: #dce2e8;
  --primary: #1261a6;
  --primary-dark: #0a477c;
  --accent: #0f7b6c;
  --danger: #b42318;
  --shadow: 0 14px 35px rgba(24, 38, 55, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: white;
  background: var(--primary);
  border-radius: 7px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-nav a {
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.top-nav a[aria-current="page"],
.top-nav a:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.language-select {
  display: inline-flex;
  align-items: center;
}

.language-select select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 34px 8px 12px;
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: end;
  min-height: 430px;
  padding: 56px 0 30px;
}

.hero-copy h1,
.tool-header h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-text,
.tool-header p {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
}

.eyebrow,
.panel-label,
.tool-category,
.ad-band span,
.ad-sidebar span {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quick-panel,
.tool-card,
.admin-form,
.admin-list,
.editor-panel,
.stats-panel,
.ad-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-panel {
  padding: 24px;
}

.quick-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.quick-panel p {
  color: var(--muted);
}

.tool-count-panel h2 {
  margin-bottom: 18px;
}

.count-grid {
  display: grid;
  gap: 12px;
}

.count-grid .stat-card {
  min-height: 128px;
  padding: 20px;
  align-items: center;
  text-align: center;
}

.count-grid .stat-card strong {
  font-size: 56px;
}

.button,
button,
input,
select,
textarea {
  font: inherit;
}

.button,
.category-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  color: white;
  background: var(--primary);
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary,
.category-button,
.icon-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.button-secondary:hover,
.category-button:hover,
.icon-button:hover {
  background: var(--surface-soft);
}

.button-secondary.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.danger {
  color: var(--danger);
}

.ad-band,
.ad-sidebar {
  min-height: 96px;
  display: grid;
  align-items: center;
  margin: 18px 0 34px;
  padding: 14px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed #b8c3cf;
  border-radius: 8px;
}

.ad-band.compact {
  min-height: 86px;
  margin-bottom: 22px;
}

.ad-top {
  margin-bottom: 0;
}

.ad-top + .hero {
  padding-top: 12px;
}

.ad-top + .tool-header {
  margin-top: 0;
}

.ad-bottom {
  margin-top: 34px;
  margin-bottom: 42px;
}

.content-with-sidebar {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.content-with-sidebar > .ad-sidebar {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 92px;
  min-height: 280px;
  margin: 0;
}

.content-with-sidebar > :not(.ad-sidebar) {
  grid-column: 2;
}

.menu-ad {
  grid-column: 1 / -1;
  min-height: 280px;
  margin: 14px 0 0;
}

.tool-browser,
.tool-page,
.admin-page {
  padding-bottom: 52px;
}

.section-heading,
.tool-header,
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2,
.admin-form h2 {
  margin: 0;
  font-size: 28px;
}

.search-box input,
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 13px;
  background: white;
}

.search-box input {
  width: min(320px, 100%);
}

.layout-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.category-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.category-button {
  justify-content: flex-start;
  width: 100%;
}

.category-button.active {
  color: white;
  background: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  grid-auto-rows: 150px;
  gap: 10px;
}

.tool-card {
  display: grid;
  grid-template-rows: 15px 24px 40px 34px;
  align-content: space-between;
  gap: 6px;
  height: 150px;
  padding: 14px;
  overflow: hidden;
}

.tool-card h3,
.admin-tool-item h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.tool-card h3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.tool-card p,
.admin-tool-item p {
  margin: 0;
  color: var(--muted);
}

.tool-card p {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-card .button {
  align-self: center;
  width: fit-content;
  min-height: 34px;
  padding: 6px 11px;
  font-size: 13px;
}

.tool-grid .empty-state {
  grid-column: 1 / -1;
  height: auto;
}

.tool-header {
  padding: 48px 0 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.editor-panel {
  overflow: hidden;
}

.editor-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.editor-toolbar label {
  font-weight: 800;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

#textInput {
  display: block;
  width: 100%;
  min-height: 470px;
  resize: vertical;
  border: 0;
  padding: 18px;
  outline: none;
  font-size: 17px;
  line-height: 1.6;
}

.stats-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 7px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  font-size: 26px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-layout.single {
  grid-template-columns: minmax(280px, 420px);
  justify-content: center;
}

.admin-form,
.admin-list {
  padding: 20px;
}

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

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

.admin-form textarea {
  min-height: 110px;
  resize: vertical;
}

.admin-login-form {
  width: 100%;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  color: var(--danger);
  background: #fff1f0;
  border: 1px solid #ffd5d2;
  border-radius: 7px;
  font-weight: 800;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.admin-tool-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.admin-tool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.admin-tool-item a {
  color: var(--primary);
  font-weight: 700;
  word-break: break-word;
}

.qr-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.qr-form,
.qr-preview-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.qr-form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.qr-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.qr-form textarea,
.qr-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 13px;
  background: white;
}

.qr-form textarea {
  min-height: 180px;
  resize: vertical;
}

.qr-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.qr-options input[type="color"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.qr-options input[type="range"] {
  width: 100%;
}

.qr-preview-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 22px;
}

.qr-preview {
  display: grid;
  min-width: 260px;
  min-height: 260px;
  place-items: center;
  overflow: auto;
  background: var(--surface-soft);
  border-radius: 8px;
}

.qr-preview img,
.qr-preview canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.qr-status {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.utility-shell {
  margin: 18px 0 24px;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.utility-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.utility-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.utility-card input,
.utility-card select,
.utility-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 13px;
  background: white;
}

.utility-card textarea {
  min-height: 240px;
  resize: vertical;
  font-family: Consolas, Monaco, monospace;
}

.utility-loading {
  padding: 28px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-stack {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 7px;
}

.check-stack label {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
}

.check-stack input {
  width: auto;
}

.html-preview {
  min-height: 180px;
  padding: 16px;
  overflow: auto;
  background: var(--surface-soft);
  border-radius: 8px;
}

.image-canvas {
  max-width: 100%;
  background: var(--surface-soft);
  border-radius: 8px;
}

.download-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-progress {
  width: 100%;
  height: 14px;
}

.doodle-tool {
  gap: 12px;
}

.doodle-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.doodle-toolbar label {
  min-width: 140px;
}

.doodle-canvas {
  width: 100%;
  aspect-ratio: 1100 / 680;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
  cursor: crosshair;
}

.serp-preview {
  display: grid;
  gap: 4px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
}

.serp-title {
  color: #1a0dab;
  font-size: 20px;
  line-height: 1.3;
}

.serp-url {
  color: #006621;
  font-size: 14px;
  word-break: break-all;
}

.serp-description {
  color: #4d5156;
  font-size: 14px;
  line-height: 1.45;
}

.empty-state {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 48px);
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.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;
}

@media (max-width: 850px) {
  .site-header,
  .section-heading,
  .tool-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .content-with-sidebar,
  .layout-grid,
  .workspace,
  .admin-layout,
  .qr-workspace,
  .utility-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 36px;
  }

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

  .search-box,
  .search-box input {
    width: 100%;
  }

  .top-nav,
  .language-select,
  .language-select select {
    width: 100%;
  }

  .top-nav a {
    flex: 1 1 auto;
    text-align: center;
  }

  .content-with-sidebar > .ad-sidebar {
    grid-column: auto;
    grid-row: auto;
    position: static;
  }

  .content-with-sidebar > :not(.ad-sidebar) {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  main {
    width: min(100% - 20px, 1180px);
  }

  .hero-copy h1,
  .tool-header h1 {
    font-size: 36px;
  }

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

  .qr-options {
    grid-template-columns: 1fr;
  }

  .admin-tool-item,
  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }
}
