:root {
  --bg: #0f1115;
  --bg-alt: #171a21;
  --bg-raised: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8eb;
  --text-dim: #9aa1ac;
  --accent: #2dd4bf;
  --accent-hover: #26b8a5;
  --radius: 8px;
}

:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-alt: #ffffff;
  --bg-raised: #eef0f3;
  --border: #d8dce3;
  --text: #14161a;
  --text-dim: #5b6472;
  --accent: #0d9488;
  --accent-hover: #0b7d73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

a {
  color: var(--accent);
}

.page-header {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header .home-link {
  margin-bottom: 0;
}

.page-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-header-right .home-link {
  margin-bottom: 0;
}

.theme-toggle {
  margin-left: auto;
}

.page-header-right .theme-toggle {
  margin-left: 0;
}

.home-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}

.home-link:hover {
  color: var(--accent);
}

/* Brand mark (logo + wordmark) */
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
}

.brand-link:hover {
  color: var(--accent);
}

.brand-mark {
  display: block;
  flex-shrink: 0;
}

/* Applied to the h1 itself on the homepage - font-size/weight/margin
   already come from the plain h1 rule below. */
.brand-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Tool-jump dropdown */
.tool-jump {
  max-width: 240px;
  margin-bottom: 1.5rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tagline {
  color: var(--text-dim);
  margin: 0 0 2rem;
}

.tool-desc {
  color: var(--text-dim);
  margin: 0 0 2rem;
}

/* Homepage tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: block;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.tool-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  color: var(--text);
}

.tool-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.tool-card.placeholder {
  opacity: 0.4;
  pointer-events: none;
  border-style: dashed;
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-copy {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease;
}

.btn-copy:hover {
  border-color: var(--accent);
}

.btn-copy.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* Form controls */
.controls {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.field input[type="number"] {
  width: 5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-size: 0.95rem;
}

.field input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.field-grow {
  flex: 1;
  min-width: 200px;
}

.field-narrow {
  max-width: 160px;
}

/* Honeypot field - hidden from real users, often filled in by simple bots */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Standalone text input (not part of a result row) */
.text-input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.text-input {
  min-height: 140px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Disabled buttons */
.btn:disabled,
.btn-copy:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:disabled:hover {
  background: var(--accent);
}

.btn-copy:disabled:hover {
  border-color: var(--border);
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  margin-bottom: 1.5rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Range slider */
.field input[type="range"] {
  width: 220px;
  accent-color: var(--accent);
}

/* Strength indicator */
.strength {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.strength-inline {
  margin-top: 0;
}

.strength-weak {
  color: #f87171;
}

.strength-fair {
  color: #fbbf24;
}

.strength-strong {
  color: #34d399;
}

.strength-very-strong {
  color: var(--accent);
}

/* Inline warning */
.warning {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #f87171;
}

/* QR preview */
.qr-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.qr-preview #qrcode {
  display: none;
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  line-height: 0;
}

.qr-placeholder {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
}

/* Two-column split layout */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .split-grid {
    grid-template-columns: 1fr;
  }
}

.field-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Color palette */
.palette-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.swatch-card {
  flex: 1 1 160px;
  min-width: 150px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}

.swatch-card.locked {
  border-color: var(--accent);
}

.swatch-color {
  position: relative;
  height: 120px;
  width: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
}

.swatch-copied-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.swatch-copied-label.show {
  opacity: 1;
}

.swatch-info {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.swatch-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.swatch-value span {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch-value .btn-copy {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.btn-lock {
  width: 100%;
}

.btn-lock.locked {
  color: var(--accent);
  border-color: var(--accent);
}

/* Hash outputs */
.hash-block {
  margin-bottom: 1.5rem;
}

.hash-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.hash-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #fbbf24;
}

/* Markdown preview */
.markdown-preview {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 140px;
  overflow-y: auto;
  font-size: 0.95rem;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0.75rem 0 0.5rem;
  color: var(--text);
}

.markdown-preview h1:first-child,
.markdown-preview h2:first-child,
.markdown-preview h3:first-child {
  margin-top: 0;
}

.markdown-preview p {
  margin: 0 0 0.75rem;
}

.markdown-preview a {
  color: var(--accent);
}

.markdown-preview code {
  background: var(--bg-raised);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
}

.markdown-preview pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow-x: auto;
}

.markdown-preview pre code {
  background: none;
  padding: 0;
}

.markdown-preview blockquote {
  margin: 0 0 0.75rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 0 0 0.75rem;
  padding-left: 1.5rem;
}

.markdown-preview img {
  max-width: 100%;
}

.markdown-preview table {
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  width: 100%;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

/* Ad slots */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 1.5rem 0;
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Report abuse link */
.abuse-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.abuse-link:hover {
  color: var(--accent);
}

/* Paste view */
.container pre {
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0;
}

/* Regex match preview */
.match-preview {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
}

.match-preview mark {
  background: var(--accent);
  color: #06110f;
  border-radius: 3px;
  padding: 0 2px;
}

.match-item {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
}

.match-item .group {
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* JSON tree view */
.json-tree {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 140px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.tree-row {
  padding: 0.1rem 0;
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
}

.tree-caret {
  display: inline-block;
  width: 1rem;
  color: var(--text-dim);
}

.tree-label {
  color: var(--text-dim);
}

.tree-children {
  margin-left: 1.1rem;
  border-left: 1px solid var(--border);
  padding-left: 0.75rem;
}

.tree-children.collapsed {
  display: none;
}

.tree-key {
  color: var(--text-dim);
}

.tree-value-string {
  color: #34d399;
}

.tree-value-number {
  color: var(--accent);
}

.tree-value-boolean {
  color: #fbbf24;
}

.tree-value-null {
  color: var(--text-dim);
  font-style: italic;
}

/* Contrast checker */
.contrast-preview {
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  text-align: center;
}

.contrast-preview.large-text {
  font-size: 1.5rem;
  font-weight: 700;
}

input[type="color"] {
  width: 4rem;
  height: 2.4rem;
  padding: 0.15rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

/* My stuff dashboard */
.mystuff-item {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.mystuff-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 0.75rem;
}

.mystuff-type-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 700;
}

.mystuff-date {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.mystuff-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

/* Results list */
.result-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.result-list + .result-list {
  margin-top: 1rem;
}

/* Section heading within a tool page */
.section-heading {
  margin: 2.5rem 0 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.result-row {
  display: flex;
  gap: 0.5rem;
}

.result-row-label {
  min-width: 110px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.result-row input[type="text"] {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
}

/* Site footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  margin-top: 3rem;
}

.footer-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}

.footer-brand:hover {
  color: var(--accent);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-tagline,
.footer-copyright {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer-copyright {
  font-size: 0.75rem;
}

/* Keyboard focus indicators - equal specificity to the :focus rules above,
   placed later so they win the cascade only for focus-visible (keyboard) */
a:focus-visible,
button:focus-visible,
select:focus-visible,
.text-input:focus-visible,
.field input[type="number"]:focus-visible,
input[type="color"]:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
