/* =====================================================================
   AI Curriculum Authoring Studio — project-local SaaS chrome
   ---------------------------------------------------------------------
   Layered ON TOP of the shared portfolio design-system.css.
   Adds the professional authoring-studio feel: workspace shell, builder
   tree, scope & sequence grid, kanban collaboration, version history,
   template gallery, publishing wizard, command palette, dark mode.
   Vanilla CSS. All AI is simulated client-side for demonstration.
   ===================================================================== */

:root {
  --acs-accent: #7048e8;        /* studio violet */
  --acs-accent-2: #0ca678;      /* teal */
  --acs-accent-dark: #5a35c9;
  --acs-glow: rgba(112, 72, 232, 0.14);
  --acs-rail-w: 252px;
}

/* ---------- Dark mode ---------- */
body.acs-dark {
  --navy: #1a1730; --navy-dark: #131127; --navy-deep: #0c0a1c;
  --ink: #ece9f8; --ink-soft: #aaa3c7; --slate: #c2bce0;
  --bg: #0e0c1d; --bg-warm: #14112a;
  --surface: #1a1733; --surface-alt: #241f43; --border: #322c55;
  --shadow: rgba(0,0,0,0.42); --shadow-lg: rgba(0,0,0,0.6);
}
body.acs-dark { background: var(--bg); color: var(--ink); }
body.acs-dark .site-header { background: rgba(14,12,29,0.92); }
body.acs-dark .card, body.acs-dark .metric, body.acs-dark .chat, body.acs-dark .app-rail, body.acs-dark .gen-output,
body.acs-dark .panel, body.acs-dark .tmpl-card, body.acs-dark .kanban-col, body.acs-dark .tree-node { background: var(--surface); }
body.acs-dark .muted, body.acs-dark .m-label { color: var(--ink-soft); }
body.acs-dark .metric .m-num, body.acs-dark .card h3, body.acs-dark .card h4 { color: #f1eefb; }
body.acs-dark input, body.acs-dark select, body.acs-dark textarea { background: #120f26; color: var(--ink); border-color: var(--border); }
body.acs-dark .out-body { background: #120f26; }
.theme-toggle { background: none; border: 1px solid var(--border); color: inherit; border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; display: grid; place-items: center; transition: .15s; }
.theme-toggle:hover { border-color: var(--acs-accent); color: var(--acs-accent); }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--acs-rail-w) 1fr; gap: 1.6rem; max-width: 1360px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; align-items: start; }
.app-rail { position: sticky; top: 84px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; box-shadow: 0 6px 20px var(--shadow); max-height: calc(100vh - 110px); overflow-y: auto; }
.rail-brand { display: flex; align-items: center; gap: 0.55rem; padding: 0.3rem 0.5rem 0.8rem; border-bottom: 1px solid var(--border); margin-bottom: 0.6rem; }
.rail-brand .mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--acs-accent), var(--acs-accent-2)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 0.95rem; }
.rail-brand b { font-size: 0.9rem; color: var(--ink); }
.rail-group { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); padding: 0.8rem 0.6rem 0.3rem; }
.rail-link { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 9px; color: var(--ink); text-decoration: none; font-size: 0.9rem; font-weight: 600; transition: .12s; }
.rail-link .ico { width: 20px; text-align: center; }
.rail-link:hover { background: var(--surface-alt); }
.rail-link.active { background: var(--acs-glow); color: var(--acs-accent-dark); }
body.acs-dark .rail-link.active { color: #d4c8ff; }

.app-main { min-width: 0; }
.app-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1.2rem; }
.app-bar .crumb { color: var(--ink-soft); font-size: 0.9rem; }
.app-bar .crumb b { color: var(--ink); }
.app-actions { display: flex; align-items: center; gap: 0.5rem; }
.autosave { font-size: 0.78rem; color: var(--acs-accent-2); font-weight: 700; display: inline-flex; align-items: center; gap: 0.35rem; }
.autosave .d { width: 8px; height: 8px; border-radius: 50%; background: var(--acs-accent-2); animation: pulse 2s infinite; }

/* ---------- Tool head ---------- */
.tool-head { margin-bottom: 1.2rem; }
.tool-head h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0.2rem 0; }
.tool-head .lead { color: var(--ink-soft); max-width: 70ch; }
.tool-badge { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--acs-glow); color: var(--acs-accent-dark); font-weight: 700; font-size: 0.78rem; padding: 0.25rem 0.8rem; border-radius: 999px; }
body.acs-dark .tool-badge { color: #d4c8ff; }

/* ---------- Generator (form + output) ---------- */
.gen-layout { display: grid; grid-template-columns: minmax(0,0.9fr) minmax(0,1.1fr); gap: 1.4rem; align-items: start; }
.gen-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: 0 6px 20px var(--shadow); }
.gen-form h3 { margin-top: 0; }
.field { margin-bottom: 1rem; }
.field > label { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 0.35rem; }
.field input, .field select, .field textarea { width: 100%; padding: 0.6rem 0.75rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--acs-accent); box-shadow: 0 0 0 3px var(--acs-glow); }
.field textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.field .hint { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.25rem; }
.chip-set { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-toggle { border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 0.35rem 0.85rem; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: .12s; }
.chip-toggle:hover { border-color: var(--acs-accent); } .chip-toggle.on { background: var(--acs-accent); border-color: var(--acs-accent); color: #fff; }
.gen-output { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-height: 340px; }
.out-toolbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.out-toolbar .ai-pill { margin-right: auto; }
.out-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 0.35rem 0.75rem; font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; transition: .12s; }
.out-btn:hover { border-color: var(--acs-accent); color: var(--acs-accent); }
.out-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.out-body { padding: 1.3rem; overflow-y: auto; flex: 1; line-height: 1.6; }
.out-body h3 { margin-top: 0; } .out-body h4 { color: var(--acs-accent-dark); margin-bottom: 0.3rem; }
body.acs-dark .out-body h4 { color: #bcaaff; }
.out-empty { color: var(--ink-soft); display: grid; place-items: center; text-align: center; height: 100%; padding: 2rem; }
.out-empty .big { font-size: 2.6rem; margin-bottom: 0.5rem; }
.gen-loading { padding: 1.3rem; }
.shimmer { height: 13px; border-radius: 6px; margin: 0.55rem 0; background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.shimmer.w70 { width: 70%; } .shimmer.w50 { width: 50%; } .shimmer.w90 { width: 90%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Builder tree (drag-and-drop curriculum) ---------- */
.builder-tree { display: flex; flex-direction: column; gap: 0.5rem; }
.tree-node { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--acs-accent); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; box-shadow: 0 3px 10px var(--shadow); cursor: grab; transition: .12s; }
.tree-node:hover { transform: translateX(3px); border-left-color: var(--acs-accent-2); }
.tree-node.dragging { opacity: 0.5; }
.tree-node.lvl-course { border-left-color: var(--acs-accent); } .tree-node.lvl-unit { border-left-color: var(--acs-accent-2); margin-left: 1.4rem; } .tree-node.lvl-lesson { border-left-color: var(--gold); margin-left: 2.8rem; }
.tree-node .t-meta { font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- Scope & sequence grid ---------- */
.ss-wrap { overflow-x: auto; }
.ss-grid { display: grid; gap: 6px; min-width: 640px; }
.ss-cell { background: var(--surface-alt); border-radius: 6px; padding: 0.5rem 0.6rem; font-size: 0.8rem; }
.ss-cell.head { background: var(--navy); color: #fff; font-weight: 700; text-align: center; }
.ss-cell.unit { background: var(--acs-glow); color: var(--acs-accent-dark); font-weight: 600; }
body.acs-dark .ss-cell.unit { color: #d4c8ff; }

/* ---------- Kanban (collaboration) ---------- */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }
.kanban-col { background: var(--surface-alt); border-radius: var(--radius); padding: 0.8rem; }
.kanban-col h4 { margin: 0 0 0.6rem; font-size: 0.9rem; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; box-shadow: 0 2px 8px var(--shadow); font-size: 0.86rem; }
.kanban-card .who { font-size: 0.74rem; color: var(--ink-soft); }

/* ---------- Version history ---------- */
.version-row { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.version-row:last-child { border-bottom: none; }
.version-row .v-tag { font-family: var(--font-head); font-weight: 700; color: var(--acs-accent); width: 56px; }
.version-row .v-body { flex: 1; } .version-row .v-body small { color: var(--ink-soft); }

/* ---------- Template gallery ---------- */
.tmpl-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1.1rem; }
.tmpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; box-shadow: 0 5px 16px var(--shadow); transition: transform .16s, box-shadow .16s; }
.tmpl-card:hover { transform: translateY(-4px); box-shadow: 0 16px 32px var(--shadow-lg); }
.tmpl-card .t-ico { font-size: 1.6rem; } .tmpl-card h4 { margin: 0.5rem 0 0.3rem; } .tmpl-card p { color: var(--ink-soft); font-size: 0.86rem; margin: 0 0 0.7rem; }

/* ---------- Publishing wizard ---------- */
.wizard { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.wizard-step { flex: 1; min-width: 130px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem; text-align: center; position: relative; }
.wizard-step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-alt); color: var(--ink-soft); display: grid; place-items: center; font-weight: 800; margin: 0 auto 0.4rem; }
.wizard-step.active { border-color: var(--acs-accent); } .wizard-step.active .n { background: var(--acs-accent); color: #fff; }
.wizard-step.done .n { background: var(--acs-accent-2); color: #fff; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.8rem; }
.export-opt { display: flex; align-items: center; gap: 0.6rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; background: var(--surface); cursor: pointer; font-weight: 600; }
.export-opt:hover { border-color: var(--acs-accent); }

/* ---------- Editor (rich text mock) ---------- */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 0.3rem; background: var(--surface-alt); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 0.4rem; }
.editor-toolbar button { border: none; background: transparent; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; font-weight: 700; color: var(--ink); }
.editor-toolbar button:hover { background: var(--surface); }
.editor-area { border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 1rem; min-height: 160px; background: var(--surface); }
.editor-area:focus { outline: 2px solid var(--acs-accent); }

/* ---------- Workspace + AI chat ---------- */
.ws-grid { display: grid; grid-template-columns: 1fr 300px; gap: 1.4rem; align-items: start; }
.ws-side .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: 0 4px 14px var(--shadow); margin-bottom: 1.1rem; }
.ws-side h4 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.ws-list { list-style: none; margin: 0; padding: 0; }
.ws-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; } .ws-list li:last-child { border-bottom: none; }
.ws-list a { text-decoration: none; color: var(--ink); } .ws-list a:hover { color: var(--acs-accent); }
.composer { display: flex; gap: 0.5rem; padding: 0.8rem; border-top: 1px solid var(--border); background: var(--surface-alt); }
.composer input { flex: 1; padding: 0.7rem 0.9rem; border: 1.5px solid var(--border); border-radius: 999px; font: inherit; background: var(--surface); color: var(--ink); }
.composer input:focus { outline: none; border-color: var(--acs-accent); box-shadow: 0 0 0 3px var(--acs-glow); }
.composer button { border: none; background: var(--acs-accent); color: #fff; border-radius: 999px; padding: 0 1.2rem; font: inherit; font-weight: 700; cursor: pointer; }
.composer button:hover { background: var(--acs-accent-dark); }

/* ---------- Stat strip / tool grid / project cards ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin: 1.2rem 0; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: 0 4px 14px var(--shadow); border-left: 4px solid var(--acs-accent); }
.stat-tile .s-num { font-family: var(--font-head); font-size: 1.8rem; color: var(--ink); line-height: 1.1; }
.stat-tile .s-label { font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); gap: 1.1rem; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; box-shadow: 0 5px 16px var(--shadow); text-decoration: none; color: inherit; display: block; transition: transform .16s, box-shadow .16s; }
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 16px 32px var(--shadow-lg); }
.tool-card .t-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: var(--acs-glow); margin-bottom: 0.7rem; }
.tool-card h4 { margin: 0 0 0.3rem; } .tool-card p { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }
.tool-card .t-go { display: inline-block; margin-top: 0.7rem; color: var(--acs-accent); font-weight: 700; font-size: 0.88rem; }
.proj-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: 0 4px 14px var(--shadow); }
.proj-card .p-status { font-size: 0.72rem; font-weight: 800; padding: 0.15rem 0.6rem; border-radius: 999px; }
.p-status.draft { background: #fdf0db; color: #b56a00; } .p-status.review { background: var(--acs-glow); color: var(--acs-accent-dark); } .p-status.published { background: #e6f5ea; color: #1f7a34; }

/* ---------- Command palette + FAB + toasts ---------- */
.cmdk { position: fixed; inset: 0; background: rgba(12,10,28,0.55); backdrop-filter: blur(3px); z-index: 200; display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmdk.open { display: flex; }
.cmdk-box { width: min(640px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 30px 70px rgba(0,0,0,0.45); overflow: hidden; animation: fadeUp .18s ease both; }
.cmdk-input { width: 100%; border: none; border-bottom: 1px solid var(--border); padding: 1.1rem 1.2rem; font: inherit; font-size: 1.05rem; background: var(--surface); color: var(--ink); }
.cmdk-input:focus { outline: none; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 0.5rem; }
.cmdk-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; border-radius: 9px; cursor: pointer; text-decoration: none; color: var(--ink); }
.cmdk-item .ico { width: 22px; text-align: center; } .cmdk-item small { margin-left: auto; color: var(--ink-soft); font-size: 0.78rem; }
.cmdk-item.active, .cmdk-item:hover { background: var(--acs-glow); }
.cmdk-empty { padding: 1.2rem; color: var(--ink-soft); text-align: center; }
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 150; width: 58px; height: 58px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--acs-accent), var(--acs-accent-2)); color: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: 0 12px 28px var(--acs-glow), 0 6px 16px rgba(0,0,0,0.2); transition: transform .15s; }
.fab:hover { transform: scale(1.07) rotate(8deg); }
.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--navy); color: #fff; padding: 0.7rem 1.1rem; border-radius: 10px; box-shadow: 0 10px 26px rgba(0,0,0,0.3); font-weight: 600; font-size: 0.9rem; animation: fadeUp .25s ease both; display: flex; align-items: center; gap: 0.5rem; }
.toast.ok { background: var(--acs-accent-2); } .toast.info { background: var(--acs-accent); }

/* ---------- kbd + soon ---------- */
.kbd { display: inline-block; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 0.05rem 0.45rem; font-family: var(--font-head); font-size: 0.78rem; background: var(--surface-alt); color: var(--ink-soft); }
.soon { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--acs-accent); border: 1px solid var(--acs-accent); border-radius: 999px; padding: 0.1rem 0.55rem; }
.lib-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 0.6rem; }
.lib-item .l-ico { font-size: 1.3rem; } .lib-item .l-body { flex: 1; min-width: 0; } .lib-item .l-body b { display: block; } .lib-item .l-body small { color: var(--ink-soft); }
.lib-item .l-tag { font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--surface-alt); color: var(--ink-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-rail { position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 0.2rem 0.8rem; }
  .rail-group { grid-column: 1 / -1; }
  .gen-layout, .ws-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
