/* AI Skills Editor by CloudSchool.AI */

:root {
  --bg: #f7f8fc;
  --bg-alt: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --text: #141a2e;
  --muted: #5b6480;
  --border: #dde2ee;
  --accent: #4f46e5;
  --accent-2: #0891b2;
  --accent-contrast: #ffffff;
  --code-bg: #f1f3f9;
  --ok: #15803d;
  --warn: #b45309;
  --error: #b91c1c;
  --info: #1d4ed8;
  --shadow: 0 10px 30px rgba(20, 26, 46, 0.08);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-alt: #0f162b;
  --surface: #121a31;
  --surface-2: #18213b;
  --text: #e6e9f5;
  --muted: #9aa3c0;
  --border: #26304f;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --accent-contrast: #0b1020;
  --code-bg: #0d1428;
  --ok: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --info: #93c5fd;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre { font-family: var(--mono); font-size: 0.92em; }
:not(pre) > code { background: var(--code-bg); border: 1px solid var(--border); padding: 0.08em 0.38em; border-radius: 6px; }
kbd { background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; font-size: 0.85em; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1480px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: var(--accent-contrast); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-mark { display: inline-flex; }
.brand-text small { display: block; font-weight: 500; font-size: 0.75rem; color: var(--muted); line-height: 1.1; }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 0.95rem; }
.site-nav a:hover { background: var(--surface-2); }
.theme-toggle, .nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; margin-left: 6px;
}
.nav-toggle { display: none; }
[data-theme="dark"] .icon-sun, :root:not([data-theme="dark"]) .icon-moon { display: none; }

/* Hero */
.hero {
  padding: 56px 0 32px;
  background:
    radial-gradient(900px 300px at 15% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(700px 260px at 90% 0%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 70%);
}
.eyebrow { margin: 0 0 8px; color: var(--accent-2); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.02em; }
.hero h1 {
  margin: 0 0 12px; font-size: clamp(1.9rem, 4.2vw, 3rem); line-height: 1.15; letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text), var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 1.125rem; color: var(--muted); max-width: 760px; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
[data-theme="dark"] .btn-primary { color: #0b1020; }
.btn-ghost { background: transparent; }
.btn-small { padding: 7px 12px; font-size: 0.875rem; border-radius: 9px; }

/* Editor */
.editor-section { padding: 8px 0 40px; }
.editor-shell {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.tool-group { display: flex; flex-wrap: wrap; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--border); }
.tool-group:last-child, .tool-group-end { border-right: 0; }
.tool-group-end { margin-left: auto; }
.toolbar button {
  font: inherit; font-size: 0.85rem; min-width: 34px; height: 32px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer;
}
.toolbar button:hover { background: var(--surface); border-color: var(--border); }
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.view-switch button { border-radius: 0; }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }

.actions-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.filename { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--muted); }
.filename input {
  font: inherit; font-family: var(--mono); font-size: 0.875rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; width: 200px;
}
.action-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

.panes { display: grid; grid-template-columns: 1fr 1fr; height: min(72vh, 820px); min-height: 420px; }
.pane { min-width: 0; min-height: 0; }
.pane-editor { border-right: 1px solid var(--border); }
#md-input {
  display: block; width: 100%; height: 100%; resize: none; border: 0; outline: none;
  padding: 18px 20px; background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 0.9rem; line-height: 1.65; tab-size: 2;
}
#md-input:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.pane-preview { overflow: auto; padding: 18px 24px 40px; background: var(--surface); }

.editor-shell[data-view="editor"] .panes { grid-template-columns: 1fr; }
.editor-shell[data-view="editor"] .pane-preview { display: none; }
.editor-shell[data-view="editor"] .pane-editor { border-right: 0; }
.editor-shell[data-view="preview"] .panes { grid-template-columns: 1fr; }
.editor-shell[data-view="preview"] .pane-editor { display: none; }

.status-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding: 6px 12px; font-size: 0.8rem; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--surface-2);
}

.validation { border-top: 1px solid var(--border); }
.validation summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 12px; font-weight: 600; font-size: 0.9rem; list-style: none;
}
.validation summary::-webkit-details-marker { display: none; }
.validation summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
.validation[open] summary::before { transform: rotate(90deg); }
.validation ul { list-style: none; margin: 0; padding: 0 12px 12px; display: grid; gap: 6px; }
.validation li { display: flex; gap: 8px; align-items: flex-start; font-size: 0.875rem; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.v-icon { font-weight: 700; width: 1em; flex: none; }
.v-error .v-icon { color: var(--error); }
.v-warn .v-icon { color: var(--warn); }
.v-info .v-icon { color: var(--info); }
.v-ok .v-icon { color: var(--ok); }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); }
.badge-ok { color: var(--ok); border-color: currentColor; }
.badge-warn { color: var(--warn); border-color: currentColor; }
.badge-error { color: var(--error); border-color: currentColor; }

.privacy-note { margin: 10px 4px 0; font-size: 0.85rem; color: var(--muted); }

/* Frontmatter card in preview */
.frontmatter-card {
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; background: var(--surface-2); padding: 12px 14px; margin-bottom: 20px; font-size: 0.9rem;
}
.fm-title { margin: 0 0 8px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.frontmatter-card dl { margin: 0; display: grid; gap: 6px; }
.fm-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; }
.fm-row dt { font-family: var(--mono); font-size: 0.85rem; color: var(--accent); }
.fm-row dd { margin: 0; overflow-wrap: anywhere; }
.fm-nested .fm-row { grid-template-columns: 90px 1fr; }

/* Rendered Markdown */
.markdown-body { overflow-wrap: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { line-height: 1.25; margin: 1.5em 0 0.6em; }
.markdown-body h1 { font-size: 1.9rem; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.45rem; padding-bottom: 0.25em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2rem; }
.markdown-body h4 { font-size: 1.05rem; }
.markdown-body h5 { font-size: 0.95rem; }
.markdown-body h6 { font-size: 0.9rem; color: var(--muted); }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre, .markdown-body table { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li + li { margin-top: 0.25em; }
.markdown-body li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.markdown-body input[type="checkbox"] { margin: 0 0.45em 0 0; vertical-align: middle; accent-color: var(--accent); }
.markdown-body blockquote { margin-left: 0; padding: 0.4em 1em; border-left: 4px solid var(--accent-2); color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.markdown-body pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow: auto; line-height: 1.5; }
.markdown-body pre code { background: none; border: 0; padding: 0; font-size: 0.875rem; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 8px; }
.markdown-body hr { border: 0; height: 1px; background: var(--border); margin: 1.6em 0; }
.markdown-body table { display: block; width: max-content; max-width: 100%; overflow: auto; }

/* Tables (shared) */
table { border-collapse: collapse; font-size: 0.925rem; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.table-wrap table { width: 100%; background: var(--surface); }

/* Content sections */
.content-section { padding: 56px 0; }
.content-section.alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.content-section h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 14px; letter-spacing: -0.01em; }
.content-section h3 { margin: 1.6em 0 0.6em; font-size: 1.15rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 20px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.tree { margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow: auto; font-size: 0.875rem; line-height: 1.55; }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: 0.4em; }

.tips { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 24px 0; }
.tip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tip h3 { margin: 0 0 6px; font-size: 1.02rem; }
.tip p { margin: 0 0 8px; font-size: 0.95rem; }
.eg { padding: 6px 10px; border-radius: 8px; font-size: 0.9rem; }
.eg.bad { background: color-mix(in srgb, var(--error) 10%, transparent); }
.eg.good { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.callout {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent-2);
  border-radius: var(--radius); padding: 6px 22px 10px;
}
.cheatsheet td:first-child { white-space: nowrap; }

/* Footer */
.site-footer { padding: 36px 0 44px; border-top: 1px solid var(--border); }
.footer-inner { display: grid; gap: 8px; justify-items: center; text-align: center; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 0.9rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 404 */
.notfound { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: 60px 20px; }

/* Responsive */
@media (max-width: 900px) {
  .only-wide { display: none; }
  .panes { grid-template-columns: 1fr; height: 70vh; }
  .editor-shell[data-view="split"] .pane-preview { display: none; }
  .editor-shell[data-view="split"] .pane-editor { border-right: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px 14px;
    background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 8px; }
  .theme-toggle { margin: 8px 0 0; align-self: flex-start; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .hero { padding-top: 36px; }
  .tool-group { border-right: 0; padding-right: 0; }
  .tool-group-end { margin-left: 0; width: 100%; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; }
  .filename { width: 100%; }
  .filename input { flex: 1; width: auto; }
  .action-buttons .btn { flex: 1 1 auto; }
  .fm-row { grid-template-columns: 1fr; gap: 0; }
  .cheatsheet td:first-child { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .site-header, .hero, .toolbar, .actions-bar, .status-bar, .validation, .content-section, .site-footer, .pane-editor, .privacy-note { display: none !important; }
  .panes { display: block; height: auto; }
  .pane-preview { display: block !important; overflow: visible; }
  .editor-shell { border: 0; box-shadow: none; }
}
