/* CCH builder — editor UI (internal tool styling). */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: #1d2b33; }
body { background: #eef2f4; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

:root {
  /* CCH Mint palette (from the login mockup) */
  --brand: #0a3a5c;        /* navy — topbar, headings, primary buttons */
  --brand-dark: #052e4d;   /* deepest navy */
  --teal: #12abb6;         /* the "Mint" accent */
  --accent: #f59c16;       /* orange — Save, highlights, focus */
  --accent-dark: #d4870f;
  --line: #d4dde1; --muted: #3d4f5a; --ink: #14323f;
}

.hidden { display: none !important; }

/* ---- Login (navy backdrop with soft circles + off-white card) ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand-dark); position: relative; overflow: hidden; padding: 24px; }
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; border-radius: 50%; }
.login-wrap::before { width: 340px; height: 340px; background: var(--brand); top: -120px; left: -100px; }
.login-wrap::after { width: 260px; height: 260px; background: var(--teal); opacity: .14; bottom: -90px; right: -80px; }
.login-bubble { position: absolute; width: 150px; height: 150px; border-radius: 50%; background: #2997d3; opacity: .16; top: 8%; right: 9%; }
.login-card { position: relative; z-index: 1; background: #faf7f1; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.login-brand .wordmark { font-size: 24px; font-weight: 500; color: var(--brand); letter-spacing: .3px; }
.login-brand .wordmark .mint { color: var(--teal); }
.login-rule { width: 38px; height: 3px; background: var(--accent); border-radius: 2px; margin-bottom: 22px; }
.login-card h1 { color: #0066ab; font-size: 19px; font-weight: 500; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; color: #3d4f5a; margin: 0 0 6px; font-weight: 500; }
.login-card input { width: 100%; height: 42px; border: 1.5px solid #7f8d98; border-radius: 8px; padding: 0 12px; font-size: 14px; color: var(--ink); background: #fff; margin-bottom: 16px; }
.login-card input::placeholder { color: #6f7d87; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,156,22,.32); }
.login-card button { width: 100%; height: 44px; margin-top: 6px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; }
.login-card button:hover { background: var(--accent-dark); }
.login-err { color: #c0392b; font-size: .85rem; margin-top: .6rem; min-height: 1em; }

/* ---- App chrome ---- */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .5rem .9rem; }
.topbar .brand { font-weight: 700; cursor: pointer; }
.topbar .brand .mint { color: var(--teal); }
.topbar .spacer { flex: 1; }
.topbar button { background: rgba(255,255,255,.15); color: #fff; border: 0; padding: .4rem .75rem; border-radius: 6px; display: inline-flex; align-items: center; gap: .4rem; }
.topbar button:hover { background: rgba(255,255,255,.28); }
/* Save stands out in the contrast colour */
.topbar button.save-btn { background: var(--accent); font-weight: 600; }
.topbar button.save-btn:hover { background: var(--accent-dark); }
/* flat monochrome line icons */
.ic { display: inline-flex; }
.ic svg { width: 16px; height: 16px; display: block; }

/* new-course dialog */
.modal-input { width: 100%; padding: .55rem; border: 1px solid var(--line); border-radius: 6px; }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid transparent; padding: .5rem 1rem; border-radius: 6px; font: inherit; line-height: 1.2; }
.btn-primary:hover { background: var(--accent-dark); }
.modal-body > .btn-primary { margin-top: 1rem; }   /* spacing for the new-course dialog only */
.topbar .save-status { font-size: .82rem; opacity: .9; }

/* ---- Dashboard ---- */
.dash { max-width: 880px; margin: 1.5rem auto; padding: 0 1rem; }
.dash h2 { color: var(--brand-dark); }
.dash .toolbar { margin-bottom: 1rem; }
.course-row { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; margin-bottom: .6rem; display: flex; align-items: center; gap: 1rem; }
.course-row .meta { flex: 1; }
.course-row .meta .title { font-weight: 600; }
.course-row .meta .sub { font-size: .8rem; color: var(--muted); }
.course-row button { border: 1px solid var(--line); background: #fff; padding: .35rem .7rem; border-radius: 6px; }
.course-row button.danger { color: #c0392b; border-color: #e3b6b1; }
.course-row button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
/* icon-only action buttons (dashboard) */
.course-row .act { display: inline-flex; align-items: center; justify-content: center; padding: .5rem; }
.course-row .act .ic svg { width: 19px; height: 19px; }
.course-row .act:hover { border-color: var(--brand); color: var(--brand); }
.course-row .act.primary:hover { background: var(--brand-dark, var(--brand)); color: #fff; }
.course-row .act.danger:hover { border-color: #c0392b; color: #c0392b; }
/* red confirm button for destructive dialogs */
.btn-danger { background: #c0392b; color: #fff; border: 1px solid transparent; padding: .5rem 1rem; border-radius: 6px; font: inherit; line-height: 1.2; }
.btn-danger:hover { background: #a93226; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
.modal-body > .btn-danger { margin-top: 1rem; }
/* shared confirm/alert dialog buttons */
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: .5rem 1rem; border-radius: 6px; font: inherit; line-height: 1.2; }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.2rem; }

/* ---- Editor 3-pane ---- */
.editor { display: grid; grid-template-columns: 230px 1fr 340px; height: calc(100vh - 44px); }
.pane { overflow-y: auto; height: 100%; }
.pane-left { background: #f7fafb; border-right: 1px solid var(--line); }
.pane-center { background: #d9e0e3; display: flex; flex-direction: column; }
.pane-right { background: #fff; border-left: 1px solid var(--line); }

.pane h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .9rem .9rem .4rem; }

/* screen list */
.screen-item { display: flex; align-items: center; gap: .4rem; padding: .5rem .7rem; margin: 0 .5rem .25rem; border-radius: 6px; border: 1px solid transparent; }
.screen-item:hover { background: #eaf1f3; }
.screen-item.active { background: #fff; border-color: var(--brand); }
.screen-item .num { font-size: .72rem; color: var(--muted); width: 1.2em; }
.screen-item .name { flex: 1; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-item .mini { opacity: .35; border: 0; background: none; padding: 0 .2rem; }
.screen-item:hover .mini { opacity: .8; }
.add-btn { display: block; width: calc(100% - 1rem); margin: .5rem; padding: .5rem; border: 1px dashed var(--brand); color: var(--brand); background: #fff; border-radius: 6px; }

/* center: course title + preview */
.center-toolbar { padding: .5rem .8rem; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .6rem; }
.center-toolbar input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; font-weight: 600; }
.preview-frame-wrap { flex: 1; padding: 12px; }
.preview-frame { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); }

/* properties */
.props { padding: .3rem .9rem 2rem; }
.field { margin: .6rem 0; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.field input[type=text], .field select, .field textarea { width: 100%; padding: .45rem; border: 1px solid var(--line); border-radius: 6px; }
.field textarea { min-height: 90px; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }
.seg { display: flex; gap: .3rem; }
.seg button { flex: 1; border: 1px solid var(--line); background: #fff; padding: .4rem; border-radius: 6px; }
.seg button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.block-item { border: 1px solid var(--line); border-radius: 6px; margin: .35rem 0; padding: .4rem .5rem; background: #fbfdfe; }
.block-item.active { border-color: var(--brand); background: #eef6f9; }
.block-item .row { display: flex; align-items: center; gap: .4rem; }
.block-item .type { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--brand-dark); font-weight: 700; }
.block-item .col-tag { font-size: .68rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; }
.block-item .snippet { flex: 1; font-size: .8rem; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-item .mini { opacity: .4; border: 0; background: none; }
.block-item:hover .mini { opacity: .85; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin: .4rem 0; }
.palette button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .4rem; font-size: .8rem; }
.palette button:hover { border-color: var(--brand); color: var(--brand); }

.divider { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.hint { font-size: .76rem; color: var(--muted); line-height: 1.4; }

/* rich-text editor */
.rt { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.rt-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: #f1f5f7; border-bottom: 1px solid var(--line); }
.rt-bar button { border: 1px solid transparent; background: #fff; border-radius: 4px; min-width: 26px; padding: .2rem .35rem; font-size: .8rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.rt-bar button:hover { border-color: var(--brand); color: var(--brand); }
/* custom text-style dropdown (replaces the native <select>, whose macOS popup
   overlays the control and hangs its checkmark gutter left of the field) */
.rt-style-dd { flex: 1 0 100%; position: relative; }
.rt-bar .rt-style {
  width: 100%; justify-content: space-between; text-align: left;
  font-size: .78rem; border: 1px solid var(--line); border-radius: 4px; background: #fff;
  padding: .45rem .5rem .45rem 7px;
}
.rt-style-chev { color: var(--muted); font-size: .7rem; }
.rt-style-menu {
  position: absolute; top: calc(100% + 2px); left: 0; min-width: 100%; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 3px;
}
.rt-bar .rt-style-opt {
  display: flex; width: 100%; justify-content: flex-start; gap: .45em; align-items: center;
  text-align: left; padding: .4rem .6rem; font-size: .82rem; border: 0; border-radius: 4px; background: #fff;
}
.rt-bar .rt-style-opt:hover { background: #eef5f8; color: var(--brand); border-color: transparent; }
.rt-bar .rt-style-opt .tick { visibility: hidden; font-size: .75rem; color: var(--brand); }
.rt-bar .rt-style-opt[aria-selected="true"] .tick { visibility: visible; }
/* the native <select> insets its text a few px more than the buttons; nudge the button
   strip right by the same amount so the first button lines up under "Paragraph" */
.rt-bar button:first-of-type { margin-left: 1px; }
.rt-ed { min-height: 90px; max-height: 260px; overflow-y: auto; padding: .5rem .6rem; font-size: .9rem; line-height: 1.5; outline: none; background: #fff; }
.rt-ed:focus { box-shadow: inset 0 0 0 2px rgba(11,110,143,.25); }
.rt-ed p { margin: 0 0 .5em; } .rt-ed ul, .rt-ed ol { margin: .2em 0 .5em 1.2em; padding: 0; }
.rt-ed a { color: var(--brand); text-decoration: underline; }
/* content headings inside the editor must NOT inherit the pane's section-label styling
   (.pane h3 = uppercase/small/muted). The player renders plain bold headings — match it. */
.pane .rt-ed h2, .pane .rt-ed h3 {
  text-transform: none; letter-spacing: normal; color: inherit; margin: 0 0 .4em;
}
.pane .rt-ed h2 { font-size: 1.15rem; }
.pane .rt-ed h3 { font-size: 1rem; }

/* popups section */
.popup-item { display: flex; align-items: center; gap: .4rem; border: 1px solid var(--line); border-radius: 6px; margin: .3rem 0; padding: .35rem .5rem; background: #fbfdfe; }
.popup-item .snippet { flex: 1; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text { border: 1px solid var(--line); background: #fff; border-radius: 4px; font-size: .78rem; padding: .15rem .5rem; color: var(--brand); }
.mini-text:hover { border-color: var(--brand); }
.linkbtn { border: 0; background: none; color: var(--brand); padding: 0; font-size: .85rem; margin-bottom: .4rem; }
.linkbtn:hover { text-decoration: underline; }
.btn-row { display: flex; gap: .4rem; }
.btn-row button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: .4rem; }

/* ---- structured block editors ---- */
.sub-label { display: block; font-size: .78rem; font-weight: 600; color: var(--brand-dark); margin: .7rem 0 .3rem; }
.item-list { display: flex; flex-direction: column; gap: .4rem; }
.item-card { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .5rem; background: #f7fafb; }
.item-bar { display: flex; align-items: center; gap: .2rem; margin-bottom: .3rem; }
.item-bar .item-n { flex: 1; font-size: .72rem; color: var(--muted); font-weight: 600; }
.item-bar .mini { opacity: .5; border: 0; background: none; padding: 0 .25rem; }
.item-bar .mini:hover { opacity: 1; }
.item-card .field { margin: .35rem 0; }
.opt-row { display: flex; align-items: center; gap: .45rem; }
.opt-row input[type=text] { flex: 1; padding: .4rem; border: 1px solid var(--line); border-radius: 6px; }
.opt-row input[type=radio], .opt-row input[type=checkbox] { width: 1.05rem; height: 1.05rem; flex: none; }
.coord-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.coord label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }
.coord input { width: 100%; padding: .35rem; border: 1px solid var(--line); border-radius: 6px; }
.check-field .check { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: #1d2b33; cursor: pointer; }
.check-field .check input { width: 1.05rem; height: 1.05rem; }

/* ---- media picker + library ---- */
.media-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.media-picker input[type=text] { flex: 1; min-width: 8rem; padding: .45rem; border: 1px solid var(--line); border-radius: 6px; }
.media-thumb { width: 100%; max-height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-top: .2rem; }
.media-bar { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.media-bar .hint { margin-left: auto; text-align: right; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.media-tile { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; background: #fbfdfe; display: flex; flex-direction: column; gap: .25rem; position: relative; }
.media-tile img { width: 100%; height: 90px; object-fit: contain; background: #fff; border-radius: 4px; }
.media-tile .media-icon { height: 90px; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--brand); background: #fff; border-radius: 4px; }
.media-tile .media-name { font-size: .76rem; word-break: break-all; }
.media-tile .media-size { font-size: .7rem; color: var(--muted); }
.media-tile .mini-text { align-self: flex-start; }
.media-tile .mini { position: absolute; top: .3rem; right: .3rem; border: 0; background: rgba(255,255,255,.85); border-radius: 4px; opacity: .6; }
.media-tile:hover .mini { opacity: 1; }
.media-search { flex: 1; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; line-height: 1.2; }
.media-actions { display: flex; gap: .3rem; margin-top: auto; }
.media-rename { width: 100%; font-size: .76rem; padding: .2rem .35rem; border: 1px solid var(--brand); border-radius: 4px; }

/* ---- modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,30,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: #fff; border-radius: 12px; width: 460px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0,0,0,.28); }
.modal-card.wide { width: 720px; }
.modal-head { display: flex; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 1rem; color: var(--brand-dark); flex: 1; }
.modal-close { border: 0; background: none; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.modal-body { padding: 1rem; overflow-y: auto; }

/* ---- version history ---- */
.version-list { display: flex; flex-direction: column; gap: .4rem; }
.version-row { display: flex; align-items: center; gap: 1rem; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; }
.version-row .meta { flex: 1; }
.version-row .meta .title { font-weight: 600; font-size: .9rem; }
.version-row .meta .sub { font-size: .76rem; color: var(--muted); }
.version-row button.primary { background: var(--brand); color: #fff; border: 0; padding: .35rem .8rem; border-radius: 6px; }

/* ---- soft-lock indicator ---- */
.lock-banner { display: none; background: #fde9d8; color: #9a4a16; border-bottom: 1px solid #f0c39a; padding: .45rem .9rem; font-size: .82rem; }
.lock-tag { font-size: .76rem; color: #9a4a16; margin-top: .15rem; }
