* { box-sizing: border-box; }

:root {
  color-scheme: dark;
  font-size: 100%;
  --page-bg: #0f172a;
  --surface: #1e293b;
  --surface-raised: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --radius: 0.75rem;
  --content-width: 110rem;
}

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.sticky-site-top { position: sticky; z-index: 100; top: 0; display: flow-root; }
.header {
  padding: clamp(0.625rem, 1.7vw, 0.85rem) clamp(0.85rem, 2.55vw, 1.7rem);
  background: var(--surface);
  border-bottom: 0.0625rem solid var(--border);
  box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.1);
}
.header-content { position: relative; width: 100%; display: flex; align-items: center; justify-content: center; }
.brand { display: flex; align-items: center; justify-content: center; }
.brand-home { color: inherit; text-decoration: none; }
.brand-home:focus-visible { border-radius: 0.375rem; outline: 0.125rem solid var(--accent); outline-offset: 0.25rem; }
.brand-main { display: grid; grid-template-columns: auto; grid-template-rows: auto auto; align-items: center; }
.brand-name, .logo-title { color: #f8fafc; font-size: clamp(1.25rem, 2.5vw, 1.625rem); font-weight: 800; letter-spacing: 0.03em; }
.brand-name, .brand-badge { width: 100%; text-align: center; }
.brand-name { grid-column: 1; grid-row: 1; font-size: clamp(1.4rem, 2.8vw, 1.8rem); }
.brand-badge { grid-column: 1; grid-row: 2; padding: 0.2rem 0.4rem; border-radius: 0.375rem; background: #0284c7; color: #fff; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em; }
.logo-icon { position: absolute; top: 50%; left: 0; display: block; width: auto; height: clamp(3rem, 6vw, 3.5rem); transform: translateY(-50%); opacity: 0.4; filter: contrast(1.8) drop-shadow(0 0 0.2rem rgba(56, 189, 248, 0.85)); object-fit: contain; background: transparent; }

/* Advertisements */
.ad-banner { display: flex; align-items: center; justify-content: center; margin-inline: auto; border: 0.0625rem dashed #475569; border-radius: 0.5rem; background: var(--page-bg); color: #64748b; font-size: 0.7rem; letter-spacing: 0.08em; text-align: center; text-transform: uppercase; }
.top-banner { width: min(100% - 2rem, 60.625rem); min-height: 5.625rem; margin-block: 0.45rem; }
.ad-support-note {
  display: flex;
  width: fit-content;
  max-width: calc(100% - 2rem);
  align-items: center;
  gap: 0.5rem;
  margin: 0.875rem auto;
  padding: 0.625rem 1rem;
  border: 0.0625rem solid rgba(56, 189, 248, 0.25);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(30, 41, 59, 0.75));
  color: #cbd5e1;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}
.ad-support-note::before { color: var(--accent); content: "✦"; font-size: 1rem; }
.bottom-ad-wrapper { display: flex; align-items: stretch; justify-content: space-between; gap: 1.25rem; width: 100%; margin: 2.5rem auto 0; }
.bottom-banner { flex: 1 1 0; min-height: 5.625rem; margin: 0; }
.video-ad-slot { min-width: 0; min-height: 15.625rem; flex: 0 1 18.75rem; }
.video-ad { position: relative; width: 100%; min-height: 15.625rem; margin: 0; }
.video-ad.is-floating { position: fixed; z-index: 90; right: 1rem; bottom: 1rem; width: min(9.375rem, calc(100vw - 2rem)); min-height: 7.8125rem; max-height: calc(100vh - 2rem); box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45); }
.video-ad-close { position: absolute; top: 0.25rem; right: 0.25rem; z-index: 1; display: none; width: 1.5rem; height: 1.5rem; padding: 0; place-items: center; border: 0; border-radius: 50%; background: #0f172a; color: #fff; cursor: pointer; font: inherit; font-size: 1rem; line-height: 1; }
.video-ad.is-floating .video-ad-close { display: grid; }
.video-ad-close:hover, .video-ad-close:focus-visible { background: #334155; }

.container { width: min(100%, var(--content-width)); margin: 0 auto 2.5rem; padding-inline: clamp(1rem, 2vw, 1.5rem); }

.page-breadcrumbs { margin: 1.5rem 0 0.75rem; color: var(--muted); font-size: 0.875rem; }
.page-breadcrumbs a, .seo-page a:not(.page-action) { color: var(--accent); text-underline-offset: 0.2em; }
.seo-page h3 { margin-top: 1.75rem; color: #f1f5f9; }
.seo-page li { margin-block: 0.5rem; color: var(--muted); line-height: 1.7; }
.seo-page .page-action { display: inline-flex; width: auto; margin-top: 0.75rem; text-decoration: none; }
.seo-page-links { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; padding: 0; list-style: none; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.8fr) minmax(0, 1fr); align-items: stretch; gap: clamp(0.75rem, 1.5vw, 1.25rem); }
.panel, .control-panel {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex-direction: column;
  padding: clamp(0.875rem, 1.6vw, 1.25rem);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
}
.control-panel { justify-content: flex-start; }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.panel-header h2 { margin: 0; color: #f1f5f9; font-size: clamp(0.9rem, 1.2vw, 1rem); font-weight: 600; }
.meta-badge { padding: 0.2rem 0.625rem; border: 0.0625rem solid var(--border); border-radius: 0.375rem; background: var(--page-bg); color: var(--muted); font-family: monospace; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }

.api-fetch-bar { display: flex; width: 100%; gap: 0.5rem; margin-bottom: 0.75rem; }
.api-fetch-bar input { min-width: 0; width: 70%; flex: 1 1 70%; padding: 0.625rem 0.75rem; border: 0.0625rem solid var(--border); border-radius: 0.5rem; background: var(--page-bg); color: #f8fafc; font-size: 0.85rem; transition: border-color 0.2s; }
.api-fetch-bar input:focus { outline: none; border-color: #0284c7; }
.api-fetch-bar button { width: 30%; flex: 0 1 30%; padding-inline: 0.5rem; }
.output-spacer { visibility: hidden; pointer-events: none; }

#outputContainer { position: relative; display: flex; width: 100%; min-width: 0; min-height: 0; flex: 1; flex-direction: column; overflow: hidden; }
#input, #outputContainer {
  min-height: clamp(18rem, 40vw, 26rem);
  flex: 1 1 0;
}
#outputContainer > textarea, #outputContainer > .tree-view, #outputContainer > .html-view { min-height: 0; }
textarea, .tree-view, .html-view {
  width: 100%;
  min-width: 0;
  min-height: clamp(18rem, 40vw, 26rem);
  flex: 1;
  overflow: auto;
  padding: 0.875rem;
  border: 0.0625rem solid var(--border);
  border-radius: 0.5rem;
  background: var(--page-bg);
  color: var(--accent);
  font: 0.85rem/1.6 Consolas, Monaco, monospace;
  tab-size: 2;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea {
  display: flex;
  resize: none;
}
textarea:focus { outline: none; border-color: #0284c7; box-shadow: 0 0 0 0.125rem rgba(2, 132, 199, 0.2); }
.tree-view, .html-view {
  display: block;
  flex: 1;
}

.loader-overlay { position: absolute; z-index: 20; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; border-radius: 0.5rem; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(0.25rem); color: var(--accent); font-size: 0.9rem; font-weight: 500; }
.spinner { width: 2.5rem; aspect-ratio: 1; border: 0.1875rem solid rgba(56, 189, 248, 0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.html-view { background: #f8fafc; color: var(--page-bg); font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.html-view table { width: 100%; border-collapse: collapse; font-size: 0.8rem; white-space: nowrap; }
.html-view th, .html-view td { padding: 0.625rem 0.875rem; border: 0.0625rem solid #cbd5e1; text-align: left; }
.html-view th { position: sticky; z-index: 10; top: 0; background: #e2e8f0; font-weight: 600; }
.hidden { display: none !important; }

/* JSON tree */
.json-branch { margin-top: 0.125rem; margin-left: 1.125rem; padding-left: 0.5rem; border-left: 0.0625rem dashed var(--border); }
.json-toggle { padding: 0.125rem; color: #64748b; font-size: 0.7rem; cursor: pointer; user-select: none; }
.json-toggle:hover { color: #f8fafc; }
.json-summary { color: var(--accent); font-weight: 600; cursor: pointer; }
.json-key { color: #f472b6; font-weight: 500; }
.json-string { color: #a7f3d0; }
.json-number { color: #fbbf24; }
.json-boolean { color: #c084fc; }
.json-null { color: #f87171; font-style: italic; }
.panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.875rem; }

/* Controls */
.control-panel h2 { margin: 0 0 0.5rem; color: #f1f5f9; font-size: 1rem; text-align: center; }
.section-label { margin: 0.375rem 0 0.125rem; color: #64748b; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.control-group { display: flex; flex-direction: column; gap: 0.375rem; }
.control-group label { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
select { padding: 0.625rem; border: 0.0625rem solid var(--border); border-radius: 0.5rem; outline: none; background: var(--page-bg); color: #f8fafc; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: border-color 0.2s; }
select:focus { border-color: #0284c7; }
.action-buttons { display: flex; flex-direction: column; gap: 0.5rem; }
.control-group + .action-buttons { margin-top: 0.5rem; }
button, .upload-btn { width: 100%; padding: 0.625rem 0.875rem; border: 0.0625rem solid var(--border); border-radius: 0.5rem; background: var(--surface-raised); color: #f8fafc; font-size: 0.85rem; font-weight: 600; text-align: center; cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
button:hover, .upload-btn:hover { transform: translateY(-0.0625rem); border-color: #475569; background: #475569; }
button:active, .upload-btn:active { transform: translateY(0); }
.disabled-btn { opacity: 0.4; cursor: not-allowed !important; pointer-events: none; }
.primary-btn { border-color: #0284c7; background: #0ea5e9; color: #fff; }
.primary-btn:hover { border-color: #0369a1; background: #0284c7; }
.accent-btn { border-color: #0d9488; background: #14b8a6; color: #fff; }
.accent-btn:hover { border-color: #0f766e; background: #0d9488; }
.secondary-btn { border: 0.0625rem solid var(--border); background: var(--page-bg); color: var(--muted); }
.secondary-btn:hover { background: var(--surface); color: #f8fafc; }
.html-btn { border-color: #4f46e5; background: #6366f1; }
.html-btn:hover { border-color: #4338ca; background: #4f46e5; }
.upload-btn input { display: none; }
.divider { margin: 0.5rem 0; border: 0; border-top: 0.0625rem solid var(--border); }
.download-group { display: flex; width: 100%; align-items: stretch; gap: 0.5rem; }
.download-group select { min-width: 0; flex: 1; }
.download-group button { flex: 2; }

#status { max-width: 100%; overflow: hidden; color: var(--muted); font-family: Consolas, Monaco, monospace; font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
#status.error { color: #f87171; }
#status.success { color: #4ade80; }
#status.info { color: var(--accent); }

/* SEO and FAQ */
.seo-content { margin-top: clamp(2rem, 5vw, 3rem); padding: clamp(1.25rem, 4vw, 2.5rem); border: 0.0625rem solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.1); }
.seo-content h1 { margin-top: 0; color: #f8fafc; font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.02em; }
.seo-content h2 { margin-bottom: 1rem; color: #f1f5f9; font-size: clamp(1.25rem, 2.3vw, 1.5rem); }
.seo-content p { margin-bottom: 1.5rem; color: var(--muted); font-size: clamp(0.95rem, 1.5vw, 1rem); line-height: 1.7; }
.seo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 2vw, 1.5rem); margin-top: 2rem; }
.seo-card { padding: clamp(1rem, 2.5vw, 1.5rem); border: 0.0625rem solid var(--border); border-radius: 0.5rem; background: var(--page-bg); }
.seo-card h3 { margin: 0 0 0.75rem; color: var(--accent); font-size: 1.125rem; font-weight: 700; }
.seo-card p { margin: 0; font-size: 0.95rem; }
.faq-section { margin-top: 3rem; padding-top: 2rem; border-top: 0.0625rem solid var(--border); }
.faq-toggle { position: relative; width: 100%; margin-bottom: 0.5rem; padding: 1rem 1.5rem; border: 0.0625rem solid var(--border); border-radius: 0.5rem; outline: none; background: var(--page-bg); color: var(--text); font-size: 1rem; font-weight: 600; text-align: left; cursor: pointer; transition: 0.3s; }
.faq-toggle:after { float: right; margin-left: 0.3125rem; color: var(--accent); font-size: 1.25rem; font-weight: bold; line-height: 1rem; content: '\002B'; }
.faq-toggle.active { margin-bottom: 0; border-color: #0284c7; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background: var(--surface); }
.faq-toggle.active:after { color: #0284c7; content: "\2212"; }
.faq-content { max-height: 0; overflow: hidden; margin-bottom: 0.75rem; padding: 0 1.5rem; border: 0.0625rem solid #0284c7; border-top: 0; border-bottom-right-radius: 0.5rem; border-bottom-left-radius: 0.5rem; background: var(--page-bg); transition: max-height 0.2s ease-out; }
.faq-content p { margin: 1rem 0; color: #cbd5e1; font-size: 0.95rem; }

/* Footer */
.footer { margin-top: auto; padding: clamp(2rem, 5vw, 3rem) clamp(1rem, 3vw, 2rem) 1.5rem; border-top: 0.0625rem solid var(--border); background: var(--surface); }
.footer-container { display: grid; width: min(100%, 87.5rem); grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: clamp(1.5rem, 4vw, 2.5rem); margin-inline: auto; }
.footer-brand { display: flex; flex-direction: column; gap: 1rem; }
.brand-logo { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; }
.footer-brand p { margin: 0; color: var(--muted); font-size: 0.9rem; font-weight: 500; line-height: 1.6; }
.footer-heading { margin: 0 0 1rem; color: #f8fafc; font-size: 0.95rem; font-weight: 700; letter-spacing: 0.03em; }
.footer-links { margin: 0; padding: 0; list-style: none; }
.footer-links li { margin-bottom: 0.75rem; }
.footer-links a { color: var(--muted); font-size: 0.9rem; font-weight: 500; text-decoration: none; transition: color 0.2s ease; }
.footer-links a:hover { color: var(--accent); }
.keyword-pages { grid-column: 1 / -1; }
.keyword-pages .footer-heading { margin-bottom: 0.75rem; }
.keyword-pages .footer-links { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem 1rem; }
.keyword-pages .footer-links li { min-width: 0; margin: 0; }
.keyword-pages .footer-links a { display: block; overflow-wrap: anywhere; font-size: 0.8rem; line-height: 1.35; }
.footer-bottom { width: min(100%, 87.5rem); margin: 2.5rem auto 0; padding-top: 1.5rem; border-top: 0.0625rem solid var(--border); color: #64748b; font-size: 0.85rem; font-weight: 500; text-align: center; }

@media (max-width: 75rem) {
  .workspace { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-panel { grid-column: 1 / -1; grid-row: 2; }
  .workspace > .panel:last-child { grid-column: 2; grid-row: 1; }
  .bottom-ad-wrapper { flex-direction: column; }
  .video-ad-slot { width: 100%; flex-basis: auto; }
}

@media (max-width: 56rem) {
  .footer-container { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keyword-pages .footer-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 42rem) {
  .brand { align-items: center; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .control-panel, .workspace > .panel:last-child { grid-column: auto; grid-row: auto; }
  .control-panel .action-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seo-grid, .footer-container { grid-template-columns: minmax(0, 1fr); }
  .keyword-pages .footer-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 30rem) {
  .panel-header { align-items: flex-start; }
  .api-fetch-bar { flex-wrap: wrap; }
  .api-fetch-bar input, .api-fetch-bar button { width: 100%; flex-basis: 100%; }
  .control-panel .action-buttons { grid-template-columns: minmax(0, 1fr); }
  .panel-footer { flex-wrap: wrap; }
  .faq-toggle { padding-inline: 1rem; }
}
