:root {
  --primary-color: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #f0fdfa;
  --border-light: #e2e8f0;
  --text-main: #1f2937;
  --text-muted: #475569;
  --radius-lg: 24px;
  --focus-ring-color: rgba(13, 148, 136, 0.45);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  line-height: 1.6;
}
* { box-sizing: border-box; }
a { color: var(--primary-color); text-underline-offset: 4px; }
button, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus-ring-color); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Same layered gradient as the four service pages, in the HTML teal. */
body.html-section {
  --section-tab-active-bg: linear-gradient(135deg, #0f766e 0%, #2dd4bf 100%);
  --section-tab-active-shadow: rgba(20, 184, 166, 0.34);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(204, 251, 241, 0.5) 0%, rgba(204, 251, 241, 0) 34%),
    radial-gradient(circle at 84% 18%, rgba(45, 212, 191, 0.26) 0%, rgba(45, 212, 191, 0) 30%),
    linear-gradient(145deg, #d5fbf3 0%, #2dd4bf 22%, #0d9488 64%, #134e4a 100%);
  background-attachment: fixed;
}
body.html-section::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.08) 16%, rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 50% -8%, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0) 42%);
}
body.html-section > * { position: relative; z-index: 1; }

.site-header { display: flex; justify-content: center; padding: 20px 16px 4px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; color: var(--primary-color); background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18), inset 0 1px 0 #fff; }
.brand-text { display: flex; flex-direction: column; font-size: 52px; font-weight: 900; line-height: .95; letter-spacing: .02em; text-shadow: 0 2px 10px rgba(15, 23, 42, 0.28); }
.brand-sub { font-size: 15px; font-weight: 800; letter-spacing: .24em; opacity: .92; }

main { flex: 1 0 auto; width: 100%; max-width: 1360px; margin: 0 auto; padding: 8px 24px 28px; }
.intro, .panel, .notice, .cdn-help {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
}
.intro { padding: 28px 32px; margin-bottom: 20px; text-align: center; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.35; margin: 0 0 8px; overflow-wrap: anywhere; color: #134e4a; }
.description { color: var(--text-muted); margin: 0 auto 14px; max-width: 760px; }
.privacy { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--primary-soft); border: 1px solid #ccfbf1; color: var(--primary-color); font-size: 14px; font-weight: 600; }
.privacy svg { flex: none; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.panel { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.panel-header { min-height: 72px; padding: 12px 16px 12px 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; border-bottom: 1px solid var(--border-light); }
h2 { margin: 0; font-size: 16px; }
.local-badge { background: var(--primary-soft); color: var(--primary-color); padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
button { border: 1px solid var(--border-light); border-radius: 12px; padding: 11px 18px; min-height: 46px; background: #fff; color: var(--text-main); }
.tool-button, .width-switch button { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.tool-button { color: var(--primary-color); border-color: #99f6e4; background: #fff; }
.tool-button:not(:disabled):hover { background: var(--primary-soft); border-color: var(--primary-color); }
.tool-button svg, .width-switch svg { flex: none; }
.width-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: #f1f5f9; border: 1px solid var(--border-light); }
.width-switch button { border-color: transparent; background: transparent; color: var(--text-muted); }
.width-switch button:hover { color: var(--text-main); }
.width-switch button[aria-pressed="true"] { background: #fff; color: var(--primary-color); border-color: #99f6e4; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08); }

textarea { display: block; width: calc(100% - 32px); min-height: 380px; height: 46vh; margin: 16px 16px 0; padding: 16px; resize: vertical; border: 1px solid var(--border-light); border-radius: 14px; background: #f8fafc; color: #0f172a; font: 15px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; transition: border-color .15s ease, box-shadow .15s ease; }
textarea:focus { border-color: #5eead4; box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.15); background: #fff; }
textarea::placeholder { color: #64748b; }
.panel-hint { color: var(--text-muted); margin: 10px 20px 0; font-size: 13px; overflow-wrap: anywhere; }
.panel-hint:empty { display: none; }
.script-option { display: flex; align-items: center; gap: 8px; margin: 14px 20px 0; font-size: 14px; font-weight: 600; }
.script-option input { flex: none; width: 18px; height: 18px; accent-color: var(--primary-color); }
.actions { padding: 16px 20px 20px; margin-top: auto; }
button.primary { min-width: 200px; background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%); color: #fff; border-color: transparent; font-weight: 700; box-shadow: 0 10px 22px rgba(20, 184, 166, 0.3); transition: transform .15s ease, box-shadow .15s ease; }
button.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(20, 184, 166, 0.36); }

.preview-stage { position: relative; flex: 1; min-height: 460px; overflow-x: auto; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #64748b; padding: 32px; margin: 0; background: #fff; }
iframe { display: block; width: 100%; height: 100%; min-height: 460px; margin: 0 auto; border: 0; background: #fff; }
/* The width switch is hidden on phones, so fixed widths only apply where it is visible. */
@media (min-width: 768px) {
  .preview-stage:not([data-width="desktop"]) { padding: 20px; background: #f1f5f9; background-image: radial-gradient(#cbd5e1 1px, transparent 1px); background-size: 16px 16px; }
  .preview-stage[data-width="tablet"] iframe { width: 768px; max-width: none; }
  .preview-stage[data-width="mobile"] iframe { width: 390px; max-width: none; }
  .preview-stage:not([data-width="desktop"]) iframe { border-radius: 14px; box-shadow: 0 0 0 1px #cbd5e1, 0 12px 32px rgba(15, 23, 42, 0.16); }
}
#preview-status { margin-bottom: 14px; }
/* Two side-by-side panels leave room for icons only; the label stays readable by AT. */
@media (max-width: 1439.98px) {
  .width-switch button { padding-inline: 10px; }
  .preview-panel:not(.is-fullscreen) .width-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Fullscreen API when available; the same class is a fixed overlay elsewhere (iPhone). */
.icon-exit { display: none; }
.preview-panel.is-fullscreen .icon-enter { display: none; }
.preview-panel.is-fullscreen .icon-exit { display: inline; }
.preview-panel.is-fullscreen { position: fixed; inset: 0; z-index: 1000; border-radius: 0; border: 0; background: #fff; backdrop-filter: none; }
.preview-panel.is-fullscreen .preview-stage { overflow: auto; min-height: 0; }
.preview-panel.is-fullscreen iframe { min-height: 100%; }
html.preview-fullscreen { overflow: hidden; }
/* Lift main above the later header/footer siblings so the fallback overlay covers them. */
html.preview-fullscreen main { z-index: 2; }

.notice { padding: 20px 24px; margin-top: 20px; }
.notice h2 { color: var(--primary-color); font-size: 15px; }
.notice p { color: var(--text-muted); margin: 6px 0 0; font-size: 14px; }
.cdn-help { margin-top: 16px; padding: 4px 24px; color: var(--text-muted); font-size: 14px; }
.cdn-help summary { cursor: pointer; display: flex; align-items: center; min-height: 52px; color: var(--primary-color); font-weight: 700; }
.cdn-help summary::-webkit-details-marker { display: none; }
.cdn-help summary::after { content: "+"; display: grid; place-items: center; flex: none; width: 24px; height: 24px; margin-inline-start: auto; border-radius: 50%; background: var(--primary-soft); font-size: 18px; line-height: 1; }
.cdn-help[open] summary::after { content: "\2212"; }
.cdn-help[open] { padding-bottom: 16px; }
.cdn-help code { display: block; overflow-wrap: anywhere; padding: 8px 0; }
.cdn-help ul { padding-inline-start: 20px; }
.cdn-help pre { overflow: auto; padding: 12px; border-radius: 12px; background: #f8fafc; }
.mobile-switch { display: none; }

.site-footer { margin: 0 16px calc(24px + env(safe-area-inset-bottom)); padding: 20px 18px; text-align: center; font-size: 14px; color: #fff; border-radius: 22px; background: rgba(13, 24, 44, 0.85); border: 1px solid rgba(255, 255, 255, 0.22); box-shadow: 0 16px 32px rgba(15, 23, 42, 0.24); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; margin-bottom: 8px; }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer small { font-size: 12px; opacity: .85; }

@media (max-width: 767.98px) {
  .desktop-only { display: none !important; }
  .site-header { padding-top: 14px; }
  .brand-mark { width: 56px; height: 56px; border-radius: 18px; }
  .brand-mark svg { width: 32px; height: 32px; }
  .brand-text { font-size: 40px; }
  .brand-sub { font-size: 12px; }
  main { padding: 4px 12px 20px; }
  .intro { padding: 20px 18px; margin-bottom: 14px; }
  .privacy { font-size: 13px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mobile-switch { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(255, 255, 255, 0.46); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12); }
  .mobile-switch button { flex: 1; min-width: 0; overflow-wrap: anywhere; border-color: transparent; background: rgba(255, 255, 255, 0.85); font-weight: 700; }
  .mobile-switch button[aria-pressed="true"] { background: var(--section-tab-active-bg); color: #fff; }
  .workspace[data-view="source"] .preview-panel, .workspace[data-view="preview"] .source-panel { display: none; }
  .panel { border-radius: 20px; }
  .panel-header { padding: 10px 12px 10px 16px; }
  .toolbar { gap: 6px; }
  .tool-button { padding: 6px 10px; font-size: 13px; }
  textarea { width: calc(100% - 24px); margin: 12px 12px 0; min-height: 320px; height: 48dvh; }
  .panel-hint { margin-inline: 16px; }
  .script-option { margin-inline: 16px; }
  .actions { padding: 14px 16px 16px; }
  .actions .primary { width: 100%; }
  .preview-stage, iframe { min-height: 55dvh; }
  .notice { padding: 16px 18px; margin-top: 14px; }
  .cdn-help { padding: 2px 18px; }
  .site-footer { margin-inline: 12px; }
}
