/* AI Skills and Prompts Library. Colours follow AI Prompt Builder and AI Skill Designer. */
:root {
  --ail-bg: #f5f7fa;
  --ail-panel: #ffffff;
  --ail-soft: #eef2f7;
  --ail-ink: #0f172a;
  --ail-muted: #4f5f73;
  --ail-line: #d5dde8;
  --ail-accent: #2563eb;
  --ail-accent-ink: #ffffff;
  --ail-danger: #b42318;
  --ail-warn: #8a4b00;
  --ail-warn-bg: #fff7e6;
  --ail-ok: #166534;
  --ail-ok-bg: #effaf2;
  --ail-header-bg: #16233a;
  --ail-header-text: #dbe7f5;
}

body { background: var(--ail-bg); color: var(--ail-ink); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
.tab-bar { background: var(--ail-header-bg); }
.tab-bar .title { color: var(--ail-header-text); }
/* Logo on the left followed by the title, like the At My Gate app header. */
.tab-bar-section.ail-brand { display: flex; align-items: center; gap: 10px; text-align: left; padding: 0 12px 0 4px; }
.ail-brand .ail-logo { height: 30px; width: auto; flex: none; }
.ail-brand .title { margin: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ail-app-view { height: calc(100vh - 45px); overflow: auto; padding: 12px; }

.ail-page { max-width: 1400px; margin: 0 auto; }
.ail-page h2 { font-size: 1.35rem; margin: 0; outline: none; }
.ail-page h3, .ail-dialog h3 { font-size: 1.05rem; margin: 0; }
.ail-page h4, .ail-dialog h4 { font-size: 0.9rem; margin: 10px 0 4px; }
.ail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ail-heading > * { min-width: 0; overflow-wrap: anywhere; }
.ail-intro, .ail-hint { color: var(--ail-muted); font-size: 0.85rem; margin: 4px 0 10px; }
.ail-hint { display: block; }
.ail-section-title { margin-top: 22px !important; margin-bottom: 6px !important; }
[hidden] { display: none !important; }
.ail-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons: Foundation's defaults force white text, so every state is set here. */
.ail-button { display: inline-block; margin: 0; padding: 6px 12px; min-height: 34px; border: 1px solid var(--ail-line); border-radius: 6px; background: var(--ail-panel); color: var(--ail-ink); font-size: 0.875rem; line-height: 1.3; cursor: pointer; text-decoration: none; }
a.ail-button { line-height: 20px; }
.ail-button:hover, .ail-button:focus { background: var(--ail-soft); color: var(--ail-ink); }
.ail-button:disabled, .ail-button:disabled:hover, .ail-button.ail-primary:disabled, .ail-button.ail-danger:disabled { opacity: 0.5; cursor: default; background: var(--ail-panel); border-color: var(--ail-line); color: var(--ail-muted); }
.ail-button.ail-primary { background: var(--ail-accent); border-color: var(--ail-accent); color: var(--ail-accent-ink); }
.ail-button.ail-primary:hover, .ail-button.ail-primary:focus { background: #1d4ed8; color: var(--ail-accent-ink); }
.ail-button.ail-danger { background: var(--ail-danger); border-color: var(--ail-danger); color: #fff; }
.ail-button.ail-danger:hover, .ail-button.ail-danger:focus { background: #912018; color: #fff; }
.ail-button.ail-small { padding: 3px 8px; min-height: 28px; font-size: 0.8rem; }
.ail-page :focus-visible, .ail-dialog :focus-visible { outline: 2px solid var(--ail-accent); outline-offset: 2px; }

.ail-page input, .ail-page select, .ail-page textarea, .ail-dialog input, .ail-dialog select, .ail-dialog textarea { margin: 0; border-radius: 6px; border-color: var(--ail-line); box-shadow: none; font-size: 0.9rem; }
.ail-page select, .ail-dialog select { height: 34px; padding: 4px 8px; width: auto; max-width: 100%; }
.ail-page input[type=text], .ail-page input[type=search], .ail-dialog input[type=text] { height: 34px; }
.ail-page label, .ail-dialog label { font-weight: 600; font-size: 0.875rem; color: var(--ail-ink); margin: 12px 0 6px; display: block; }
.ail-page input[type=checkbox], .ail-page input[type=radio], .ail-dialog input[type=checkbox], .ail-dialog input[type=radio] { width: 18px; height: 18px; margin: 2px 0 0; flex: none; }
.ail-check { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; font-weight: 500 !important; }

.ail-status { min-height: 1.4em; margin: 4px 0 8px; font-size: 0.85rem; color: var(--ail-muted); }
.ail-error { color: var(--ail-danger) !important; }
.ail-notice { background: var(--ail-warn-bg); border: 1px solid #f5d38a; border-radius: 6px; padding: 8px 12px; font-size: 0.875rem; }
.ail-warnings { background: var(--ail-warn-bg); border: 1px solid #f5d38a; border-radius: 6px; padding: 8px 12px 8px 28px; font-size: 0.85rem; margin: 6px 0; }
.ail-ok { background: var(--ail-ok-bg); border: 1px solid #a7d7b4; color: var(--ail-ok); border-radius: 6px; padding: 8px 12px; font-size: 0.875rem; }
.ail-meta { color: var(--ail-muted); font-size: 0.78rem; margin: 0; overflow-wrap: anywhere; }
.ail-empty { color: var(--ail-muted); font-size: 0.875rem; }
.ail-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.ail-spacer { flex: 1; }

/* Browser: folder tree beside the list */
.ail-browser { display: grid; grid-template-columns: minmax(200px, 270px) minmax(0, 1fr); gap: 12px; align-items: start; }
.ail-tree-panel { background: var(--ail-panel); border: 1px solid var(--ail-line); border-radius: 10px; padding: 10px; position: sticky; top: 0; max-height: calc(100vh - 80px); overflow: auto; }
.ail-tree-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ail-tree-title { margin: 6px 0 !important; font-size: 0.8rem !important; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ail-muted); }
.ail-tree, .ail-tree ul { list-style: none; margin: 0; padding: 0; }
.ail-tree ul { padding-left: 14px; }
.ail-treeitem { margin: 1px 0; outline: none; }
.ail-tree-label { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 0.875rem; border: 1px solid transparent; }
.ail-tree-label:hover { background: var(--ail-soft); }
.ail-treeitem:focus-visible > .ail-tree-label { outline: 2px solid var(--ail-accent); outline-offset: 1px; }
.ail-selected > .ail-tree-label { background: #dbeafe; color: #1e3a8a; font-weight: 600; }
.ail-tree-label.ail-drop { border: 1px dashed var(--ail-accent); background: #eff6ff; }
.ail-twisty { width: 14px; flex: none; color: var(--ail-muted); text-align: center; }
.ail-tree-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ail-count { background: var(--ail-soft); color: var(--ail-muted); border-radius: 999px; padding: 0 7px; font-size: 0.72rem; font-weight: 600; }
.ail-list-panel { min-width: 0; }
.ail-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.ail-toolbar input[type=search] { flex: 1 1 220px; min-width: 0; }
.ail-tagbar input[type=text] { flex: 0 1 180px; min-width: 120px; }
.ail-page .ail-inline-label { margin: 0 !important; }
.ail-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ail-chip { display: inline-flex; align-items: center; gap: 2px; background: #dbeafe; color: #1e3a8a; border-radius: 999px; padding: 1px 4px 1px 9px; font-size: 0.78rem; }
.ail-chip-remove { margin: 0; padding: 0 5px; border: 0; background: transparent; color: #1e3a8a; font-size: 1rem; line-height: 1; cursor: pointer; border-radius: 999px; }
.ail-chip-remove:hover, .ail-chip-remove:focus { background: #bfdbfe; color: #1e3a8a; }
.ail-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ail-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.9rem; }
.ail-crumb { margin: 0; padding: 0; border: 0; background: transparent; color: #1d4ed8; text-decoration: underline; cursor: pointer; font-size: 0.9rem; }
.ail-crumb:hover, .ail-crumb:focus { background: transparent; color: #1e3a8a; }
.ail-crumb-sep { color: var(--ail-muted); }
.ail-folder-tools { margin-bottom: 6px; }

/* Cards */
.ail-card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; }
.ail-card-list > .ail-empty { grid-column: 1 / -1; }
.ail-card { background: var(--ail-panel); border: 1px solid var(--ail-line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ail-card[draggable=true] { cursor: grab; }
.ail-card.ail-dragging { opacity: 0.5; }
.ail-card h3 { overflow-wrap: anywhere; }
.ail-card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.ail-description { font-size: 0.875rem; margin: 0; flex: 1; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ail-tags { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.ail-tag { background: var(--ail-soft); border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; color: #334155; border: 0; margin: 0; }
.ail-tag-button { cursor: pointer; }
.ail-tag-button:hover, .ail-tag-button:focus { background: #dbeafe; color: #1e3a8a; }
/* ASPL-R-012: tag chip bar styled as in Web Links */
.ail-tagfilter { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.ail-tag-chip { display: inline-block; margin: 0; padding: 5px 14px; border-radius: 16px; background: #fff; color: #555; font-size: 0.8rem; line-height: 1.3; cursor: pointer; border: 1px solid #e2ddd6; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.ail-tag-chip:hover, .ail-tag-chip:focus { background: #f3f0ff; color: #3b2a8f; }
.ail-tag-chip.active, .ail-tag-chip.active:hover, .ail-tag-chip.active:focus { background: #7651fd; color: #fff; border-color: #7651fd; }
.ail-tag-chip.ail-card-tag { padding: 2px 10px; font-size: 0.75rem; box-shadow: none; }
.ail-badge { background: #e0e7ff; color: #3730a3; border-radius: 999px; padding: 1px 8px; font-size: 0.72rem; font-weight: 600; vertical-align: middle; }
.ail-type-skill { background: #ede9fe; color: #5b21b6; }
.ail-type-prompt { background: #e0f2fe; color: #075985; }
.ail-state-published { background: #dcfce7; color: var(--ail-ok); }
.ail-state-taken-down { background: #fee4e2; color: var(--ail-danger); }
.ail-state-draft-deleted { background: var(--ail-soft); color: var(--ail-muted); }
.ail-state-draft { background: #fef3c7; color: var(--ail-warn); }
.ail-badge-soft { background: var(--ail-soft); color: var(--ail-muted); }

/* Tabs */
.ail-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--ail-line); margin: 8px 0 10px; }
.ail-tab { margin: 0 0 -1px; padding: 6px 12px; border: 1px solid transparent; border-radius: 8px 8px 0 0; background: transparent; color: var(--ail-muted); font-size: 0.875rem; cursor: pointer; }
.ail-tab:hover, .ail-tab:focus { background: var(--ail-soft); color: var(--ail-ink); }
.ail-tab-selected, .ail-tab-selected:hover, .ail-tab-selected:focus { background: var(--ail-panel); color: var(--ail-ink); border-color: var(--ail-line); border-bottom-color: var(--ail-panel); font-weight: 600; }

/* Entry */
.ail-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 0.875rem; margin: 8px 0; }
.ail-facts dt { font-weight: 600; color: #334155; }
.ail-facts dd { margin: 0; overflow-wrap: anywhere; }
.ail-hash { font-size: 0.75rem; word-break: break-all; }
.ail-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--ail-panel); }
.ail-table th, .ail-table td { padding: 6px 8px; border-bottom: 1px solid var(--ail-line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ail-preview-wrap { background: var(--ail-panel); border: 1px solid var(--ail-line); border-radius: 10px; padding: 10px 14px; }
.ail-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: #1e293b; background: #f8fafc; border: 1px solid var(--ail-line); border-radius: 6px; padding: 10px; margin: 4px 0 10px; max-height: 45vh; overflow: auto; }
.ail-file-list { font-size: 0.85rem; }
.ail-details { margin: 14px 0; }
.ail-details summary { cursor: pointer; font-weight: 600; color: #334155; font-size: 0.875rem; }
.ail-audit { font-size: 0.82rem; margin: 6px 0 0 1.2em; }
.ail-versions { font-size: 0.875rem; }

/* Dialogs */
.ail-dialog { border: 1px solid var(--ail-line); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25); color: var(--ail-ink); }
.ail-dialog-wide { width: min(820px, calc(100vw - 24px)); }
.ail-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.ail-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--ail-line); position: sticky; top: 0; background: var(--ail-panel); z-index: 1; }
.ail-dialog-head h3 { outline: none; }
.ail-dialog-close { margin: 0; padding: 0 8px; border: 0; background: transparent; color: var(--ail-muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.ail-dialog-close:hover, .ail-dialog-close:focus { background: transparent; color: var(--ail-ink); }
.ail-dialog-body { padding: 4px 16px 14px; }
.ail-dialog-actions { justify-content: flex-end; margin-top: 12px; }
.ail-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; padding: 0; }
.ail-step { padding: 3px 10px; border: 1px solid var(--ail-line); border-radius: 999px; font-size: 0.8rem; color: var(--ail-muted); }
.ail-step-done { border-color: #86b38a; background: #f0f8f1; color: var(--ail-ok); }
.ail-step-current { border-color: var(--ail-accent); background: var(--ail-accent); color: #fff; }
.ail-choices { border: 0; margin: 8px 0; padding: 0; }
.ail-choices legend { font-weight: 600; font-size: 0.875rem; margin-bottom: 6px; }
.ail-choice, .ail-check-row { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; }
.ail-choice label, .ail-check-row label { margin: 0 !important; font-weight: 500 !important; }
.ail-choice .ail-hint { margin: 2px 0 0; font-weight: 400; }
.ail-choice-disabled label { color: var(--ail-muted) !important; }
.ail-finding { border: 1px solid var(--ail-line); border-left-width: 4px; border-radius: 6px; padding: 6px 10px; margin: 8px 0; font-size: 0.85rem; }
.ail-finding p { margin: 0 0 4px; }
.ail-finding ul { margin: 0 0 0 1.2em; }
.ail-finding-block { border-left-color: var(--ail-danger); background: #fef3f2; }
.ail-finding-warn { border-left-color: #d97706; background: var(--ail-warn-bg); }
.ail-warning { border: 1px solid #f4a39b; border-left: 4px solid var(--ail-danger); background: #fef3f2; border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 0.875rem; }
.ail-warning p { margin: 2px 0; }
.ail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ail-dialog textarea { width: 100%; }

/* Moderation */
.ail-policy { background: var(--ail-panel); border: 1px solid var(--ail-line); border-radius: 10px; padding: 10px 14px; font-size: 0.875rem; }
.ail-policy p { margin: 6px 0 0; }
.ail-mod-list { list-style: none; margin: 0; padding: 0; }
.ail-mod-item { background: var(--ail-panel); border: 1px solid var(--ail-line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 0.875rem; }
.ail-mod-item p { margin: 2px 0; }
.ail-mod-open { border-left: 4px solid #d97706; }
.ail-mod-item blockquote { margin: 6px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--ail-line); font-size: 0.85rem; color: #334155; }
#ailModSearch { max-width: 360px; margin-bottom: 8px; }

@media (max-width: 760px) {
  .ail-app-view { padding: 8px; }
  .ail-browser { grid-template-columns: 1fr; }
  .ail-tree-panel { position: static; max-height: 40vh; }
  .ail-grid { grid-template-columns: 1fr; }
  .ail-tagbar .ail-spacer { display: none; }
  .ail-facts { grid-template-columns: 1fr; }
  .ail-facts dd { margin-bottom: 6px; }
  .ail-table thead { display: none; }
  .ail-table tr { display: block; border-bottom: 1px solid var(--ail-line); padding: 4px 0; }
  .ail-table td { display: block; border: 0; padding: 2px 8px; }
}

/* AISE-T-007: formatted previews (MarkdownView); the Markdown option keeps the monospace text. */
.ail-preview-box .mdv-markdown { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: #1e293b; background: #f8fafc; border: 1px solid var(--ail-line); border-radius: 6px; padding: 10px; }
.ail-preview-formatted { font: 13px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; color: #1e293b; }
.ail-preview-formatted .ail-preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #64748b; margin: 14px 0 4px; }
.ail-preview-formatted .ail-preview-label:first-child { margin-top: 0; }
.ail-preview-formatted .ail-preview-label code { text-transform: none; background: none; padding: 0; }
.ail-front-matter { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 12px; display: table !important; }
.ail-front-matter th { width: 30%; color: #64748b; font-weight: 600; background: #f8fafc; }
.ail-description-full { white-space: pre-line; }
.ail-description-full.mdv-formatted { white-space: normal; }
.ail-description-full.mdv-formatted > :last-child, .ail-front-description > :last-child { margin-bottom: 0; }
.ail-front-description ul { margin: 4px 0 0; }
.ail-front-matter th, .ail-front-matter td { border: 1px solid var(--ail-line); padding: 4px 8px; vertical-align: top; overflow-wrap: anywhere; }

/* ASPL-T-019: Publish several */
.ail-bulk-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--ail-line); border-radius: 6px; padding: 6px 10px; }
.ail-bulk-list li { margin: 2px 0; }

/* Prompt sources (PB-R-015) */
.ail-sources { margin-top: 12px; }
.ail-source-list { list-style: none; margin: 0; padding: 0; }
.ail-source { border-top: 1px solid #e2e8f0; padding: 8px 0; }
.ail-source p { margin: 0 0 4px; }
.ail-source-head a { font-weight: 600; }
.ail-source-quote { margin: 4px 0; padding-left: 10px; border-left: 3px solid #cbd5e1; color: #475569; font-size: 0.95em; }
