/* Formattly — shared styles */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8eef6;
  --text-muted: #9aa8bc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --max: 960px;
  --header-h: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.logo span {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none;
}

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

/* Main */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.page-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.25;
}

.lead {
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 42rem;
}

/* Cards / tools list */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
}

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

.tool-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}

.tool-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

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

/* AdSense placeholder */
.ad-slot {
  margin: 1.5rem 0;
  padding: 1.5rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Tool UI */
.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tool-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  filter: brightness(1.1);
}

.tool-status {
  margin-left: auto;
  align-self: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.25em;
}

.tool-status[data-tone="error"] {
  color: var(--danger);
}

.tool-status[data-tone="ok"] {
  color: var(--success);
}

.tool-io {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .tool-io {
    grid-template-columns: 1fr 1fr;
  }

  .tool-io .io-block:first-child {
    border-right: 1px solid var(--border);
  }
}

.io-block {
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.io-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.io-block textarea {
  flex: 1;
  width: 100%;
  min-height: 240px;
  padding: 0.75rem;
  border: none;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
}

.io-block textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* FAQ */
.faq {
  margin-top: 2.5rem;
}

.faq h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.faq details {
  margin-bottom: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.faq details p {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
}

/* Features / about */
.features {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}

@media (min-width: 600px) {
  .features {
    grid-template-columns: repeat(3, 1fr);
  }
}

.feature {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.feature h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.feature p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.75rem 1.25rem;
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.privacy-note {
  margin: 0;
  max-width: 40rem;
}

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

.footer-links a {
  color: var(--text-muted);
}

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

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

/* Tool options (checkboxes / count) */
.tool-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
}

.opt-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.opt-label input[type="number"] {
  width: 4.5rem;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.opt-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.opt-check input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.tool-io-single .io-block {
  min-height: 200px;
}

.tool-io-single .io-block textarea {
  min-height: 160px;
}

/* Decode / secondary panel */
.decode-panel {
  margin-top: 1.25rem;
}

.panel-title {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.decode-body {
  padding: 0 0 1rem;
}

.decode-body .io-label {
  display: block;
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.text-input {
  display: block;
  width: calc(100% - 1.5rem);
  margin: 0 0.75rem;
  padding: 0.6rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.text-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.decode-result {
  margin: 0.75rem 0.75rem 0;
  padding: 0.75rem;
  min-height: 1.5em;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.decode-result:empty {
  display: none;
}

/* Related tools */
.related {
  margin-top: 2.5rem;
}

.related h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

.related-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-list li {
  margin-bottom: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.related-list a[aria-disabled="true"] {
  color: var(--text-muted);
  pointer-events: none;
  text-decoration: none;
}

.coming-soon {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* HAR → cURL request list */
.file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.file-row input[type="file"] {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  max-width: 100%;
}

.request-list-wrap {
  padding: 0.75rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.request-list-wrap .io-label {
  display: block;
  border-bottom: none;
  padding: 0 0 0.35rem;
}

#har-request-list {
  display: block;
  width: 100%;
  min-height: 8rem;
  max-height: 14rem;
  padding: 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#har-request-list:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tool-io-stack {
  display: grid;
  grid-template-columns: 1fr;
}

.tool-io-stack .io-block {
  min-height: 180px;
  border-bottom: 1px solid var(--border);
}

.tool-io-stack .io-block:last-child {
  border-bottom: none;
}

.tool-io-stack .io-block textarea {
  min-height: 160px;
}
