/* ══════════════════════════════════════════════════════════════════
   WorkSpace — Mobile-first responsive styles
══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --bg:        #f8f7f5;
  --surface:   #ffffff;
  --surface2:  #f2f1ef;
  --border:    rgba(0,0,0,0.09);
  --border2:   rgba(0,0,0,0.16);
  --text:      #1a1a18;
  --muted:     #6b6b68;
  --hint:      #9e9e9b;
  --blue:      #3b7de8;
  --blue-bg:   #eef4ff;
  --blue-text: #1a4fa0;
  --green:     #3aaa5f;
  --green-bg:  #edfbf3;
  --green-text:#1a6636;
  --amber:     #d08a00;
  --amber-bg:  #fffbeb;
  --amber-text:#7a5200;
  --red:       #d63f3f;
  --red-bg:    #fff1f1;
  --red-text:  #8b1c1c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --topbar-h:  52px;
  --sidebar-w: 220px;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }

/* ── Screens ─────────────────────────────────────────────────────── */
.screen { display: none; height: 100vh; height: 100dvh; overflow: hidden; }
.screen.active { display: flex; flex-direction: column; overflow: hidden; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border: none; border-radius: var(--radius-sm);
  background: var(--blue); color: #fff; font-family: var(--font);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s; -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover:not(:disabled) { background: #2d6ed4; }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--border2); border-radius: var(--radius-sm);
  background: none; color: var(--text); font-family: var(--font);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all .12s; -webkit-tap-highlight-color: transparent;
}
.btn-outline:hover:not(:disabled) { background: var(--surface2); }
.btn-outline.active { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.btn-outline:disabled { opacity: .4; cursor: default; }

.btn-ghost {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border2); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--muted); transition: all .12s;
  -webkit-tap-highlight-color: transparent; flex-shrink: 0;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 10px; font-size: 15px; color: var(--hint); pointer-events: none; }
.input-wrap input, .input-wrap select {
  width: 100%; padding: 10px 12px 10px 34px;
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px;
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s; -webkit-appearance: none;
}
.input-wrap input:focus, .input-wrap select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,125,232,.12); }
.pass-toggle { position: absolute; right: 10px; background: none; border: none; cursor: pointer; color: var(--hint); font-size: 16px; padding: 4px; display: flex; align-items: center; }
.login-error { font-size: 12px; color: var(--red); min-height: 18px; margin-bottom: 6px; }
.form-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; }
.forgot-success { font-size: 12px; color: var(--green); min-height: 18px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.forgot-link-wrap { margin-top: 14px; text-align: center; }
.forgot-link { font-size: 12px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.forgot-link:hover { color: var(--blue); }
.filter-select { padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: var(--surface); color: var(--text); font-family: var(--font); font-size: 13px; cursor: pointer; -webkit-appearance: none; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-bg { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 24px; width: 100%; max-width: 360px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-logo { width: 48px !important; height: 48px !important; max-width: 48px !important; max-height: 48px !important; object-fit: contain; flex-shrink: 0; display: block; }
.brand-name { font-size: 16px; font-weight: 600; }
.brand-sub  { font-size: 12px; color: var(--muted); }
.btn-login {
  width: 100%; padding: 11px; border: none; border-radius: var(--radius-sm);
  background: var(--blue); color: #fff; font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s; margin-top: 4px;
}
.btn-login:hover { background: #2d6ed4; }
.btn-login.loading { opacity: .7; pointer-events: none; }
.login-footer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; color: var(--blue); font-weight: 400; line-height: 1; }
.footer-line1 { display: block; font-size: 13px; font-weight: 500; color: var(--blue); margin-bottom: 2px; }
.footer-line2 { display: block; font-size: 11px; font-weight: 400; color: var(--blue); }

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center;
  padding: 0 12px; gap: 8px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-left  { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.topbar-sep   { width: 1px; height: 16px; background: var(--border2); flex-shrink: 0; }
.topbar-logo { width: 36px; height: 36px; max-width: 36px; max-height: 36px; object-fit: contain; flex-shrink: 0; display: block; }
.brand-mini-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.doc-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.version-pill { font-size: 10px; font-weight: 500; padding: 2px 8px; border-radius: 20px; background: var(--blue-bg); color: var(--blue-text); white-space: nowrap; flex-shrink: 0; }
.version-pill.old { background: var(--surface2); color: var(--muted); }
.lock-status  { display: none; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.status-dot   { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.status-dot.locked { background: var(--red); }
.idle-chip { display: none; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--amber-bg); color: var(--amber-text); border: 1px solid rgba(208,138,0,.25); }
.idle-chip.visible { display: flex; }
.user-pill { display: flex; align-items: center; gap: 6px; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: #fff; flex-shrink: 0; }
.role-badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; }
.role-admin  { background: var(--blue-bg);  color: var(--blue-text); }
.role-editor { background: var(--green-bg); color: var(--green-text); }
.role-reader { background: var(--surface2); color: var(--muted); }

/* ── Doc title rename ────────────────────────────────────────────── */
.doc-title-wrap { display: flex; align-items: center; gap: 5px; min-width: 0; }
.doc-rename-btn { width: 24px; height: 24px; background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--hint); border-radius: var(--radius-sm); font-size: 13px; padding: 0; }
.doc-rename-btn:hover { color: var(--blue); background: var(--blue-bg); }
.doc-rename-form { display: flex; align-items: center; gap: 4px; }
.doc-rename-input { font-family: var(--font); font-size: 13px; font-weight: 500; padding: 3px 8px; height: 28px; border: 1px solid var(--blue); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); outline: none; min-width: 100px; max-width: 200px; }
.doc-rename-ok, .doc-rename-cancel { width: 26px; height: 26px; border-radius: var(--radius-sm); border: none; display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.doc-rename-ok { background: var(--blue); color: #fff; }
.doc-rename-cancel { background: var(--surface2); color: var(--muted); border: 1px solid var(--border2); }

/* ── Main layout ─────────────────────────────────────────────────── */
.layout { flex: 1; display: flex; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface2); display: flex; flex-direction: column;
  overflow: hidden; transition: transform .25s ease;
}
.sidebar-section-head { padding: 8px 12px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--hint); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.viewer-list { padding: 8px; border-bottom: 1px solid var(--border); min-height: 44px; flex-shrink: 0; }
.viewer-row  { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
.viewer-name { font-size: 12px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-badge { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 8px; }
.badge-editing { background: var(--red-bg); color: var(--red-text); }
.badge-viewing { background: var(--surface); color: var(--hint); border: 1px solid var(--border); }
.empty-state { font-size: 12px; color: var(--hint); padding: 4px 0; }
.version-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.v-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.v-item:hover { background: var(--surface); }
.v-item.selected { background: var(--surface); border-left: 3px solid var(--blue); padding-left: 9px; }
.vi-row  { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.vi-name { font-size: 12px; font-weight: 500; max-width: 95px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.vi-vnum { font-size: 11px; font-weight: 600; color: var(--blue); white-space: nowrap; flex-shrink: 0; margin-left: 2px; }
.vi-row  { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; flex-wrap: nowrap; cursor: default; }
.latest-tag { font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 6px; background: var(--green-bg); color: var(--green-text); text-transform: uppercase; }
.vi-meta { font-size: 11px; color: var(--muted); line-height: 1.6; }
.vi-actions { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.vi-dl, .vi-share { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--border2); background: none; color: var(--muted); cursor: pointer; font-family: var(--font); transition: all .1s; -webkit-tap-highlight-color: transparent; }
.vi-dl:hover    { background: var(--surface); color: var(--blue); border-color: var(--blue); }
.vi-share:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }

/* Sidebar mobile toggle */
.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }

/* ── Editor panel ────────────────────────────────────────────────── */
.editor-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); min-width: 0; }
.alert-bar { display: none; align-items: center; gap: 7px; padding: 8px 14px; font-size: 12px; border-bottom: 1px solid transparent; flex-shrink: 0; }
.alert-bar.visible { display: flex; }
.alert-warn   { background: var(--amber-bg); color: var(--amber-text); border-color: rgba(208,138,0,.2); }
.alert-danger { background: var(--red-bg);   color: var(--red-text);   border-color: rgba(214,63,63,.2); }
.alert-info   { background: var(--blue-bg);  color: var(--blue-text);  border-color: rgba(59,125,232,.2); }

/* ── Quill toolbar ───────────────────────────────────────────────── */
.quill-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px 8px; border: none !important; border-bottom: 1px solid var(--border) !important;
  background: var(--surface2); flex-shrink: 0; overflow: visible; position: relative; z-index: 20;
}
.quill-toolbar .ql-formats { display: flex; align-items: center; gap: 1px; }
.quill-toolbar button, .quill-toolbar select { font-family: var(--font) !important; font-size: 12px !important; color: var(--muted) !important; background: none !important; border: 1px solid transparent !important; border-radius: var(--radius-sm) !important; cursor: pointer; height: 28px !important; }
.quill-toolbar button:hover  { background: var(--surface) !important; border-color: var(--border2) !important; color: var(--text) !important; }
.quill-toolbar button.ql-active { background: var(--blue-bg) !important; color: var(--blue) !important; border-color: var(--blue) !important; }
.quill-toolbar select { padding: 0 4px !important; }
.toolbar-right-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.tb-import-btn { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: none; color: var(--muted); cursor: pointer; white-space: nowrap; font-family: var(--font); }
.tb-import-btn:hover { background: var(--surface); color: var(--text); }
.char-count { font-size: 11px; color: var(--hint); white-space: nowrap; }

/* Export dropdown */
.export-wrap { position: relative; }
.tb-export-btn { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: none; color: var(--muted); cursor: pointer; white-space: nowrap; font-family: var(--font); }
.tb-export-btn:hover { background: var(--surface); color: var(--text); }
.export-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-md); padding: 4px; min-width: 190px; z-index: 50; box-shadow: 0 4px 20px rgba(0,0,0,.1); }
.export-menu.open { display: block; }
.export-menu button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: none; background: none; font-family: var(--font); font-size: 13px; color: var(--text); border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.export-menu button:hover { background: var(--surface2); }
.export-menu button i { font-size: 16px; color: var(--muted); }

/* Editor area */
.editor-wrap { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#quill-editor { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ql-container.ql-snow { border: none !important; height: 100%; }
.ql-editor { padding: 20px 18px !important; font-family: var(--font) !important; font-size: 14px !important; line-height: 1.8 !important; color: var(--text) !important; min-height: 100%; }
.ql-editor h1 { font-size: 20px !important; font-weight: 600 !important; margin: 16px 0 8px !important; }
.ql-editor h2 { font-size: 16px !important; font-weight: 600 !important; margin: 14px 0 6px !important; }
.ql-editor h3 { font-size: 14px !important; font-weight: 600 !important; margin: 12px 0 4px !important; }
.ql-editor p  { margin-bottom: 6px !important; }
.ql-editor blockquote { border-left: 3px solid var(--border2); padding-left: 12px; color: var(--muted); font-style: italic; }
.ql-editor pre.ql-syntax { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px; font-family: monospace; font-size: 12px; }
.ql-editor a { color: var(--blue); }
.ql-editor.ql-blank::before { color: var(--hint) !important; font-style: normal !important; }
.ql-editor[contenteditable="false"] { background: var(--surface2); cursor: default; }
.ql-snow .ql-tooltip { z-index: 500; border-radius: var(--radius-sm); border-color: var(--border2); }
.ql-snow .ql-picker-options { z-index: 500 !important; position: absolute !important; }
.ql-snow .ql-picker.ql-expanded .ql-picker-options { z-index: 500 !important; }
.ql-toolbar.ql-snow .ql-picker-options { z-index: 500 !important; }
.ql-container { overflow: visible !important; }
.ql-snow.ql-toolbar { overflow: visible !important; }
.quill-toolbar { overflow: visible !important; z-index: 20; }

/* ── Footer ──────────────────────────────────────────────────────── */
.editor-footer { display: flex; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); gap: 8px; flex-shrink: 0; background: var(--surface); position: sticky; bottom: 0; z-index: 10; box-shadow: 0 -1px 4px rgba(0,0,0,.04); -webkit-transform: translateZ(0); transform: translateZ(0); }
.footer-left { flex: 1; min-width: 0; overflow: hidden; }
.footer-right { display: flex; gap: 6px; flex-shrink: 0; }
.current-user-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--text); color: #fff; border-radius: var(--radius-md); font-size: 13px; animation: toast-in .2s ease; max-width: 300px; }
.toast.success { background: var(--green); }
.toast.warn    { background: var(--amber); }
.toast.error   { background: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 22px 22px 18px; width: 100%; max-width: 360px; animation: modal-in .18s ease; }
@keyframes modal-in { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 26px; margin-bottom: 10px; }
.modal h3   { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.modal p    { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions button { padding: 8px 14px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 12px; font-weight: 500; cursor: pointer; transition: all .12s; }
.mbtn-cancel  { background: none; border: 1px solid var(--border2); color: var(--text); }
.mbtn-confirm { background: var(--blue);  border: none; color: #fff; }
.mbtn-danger  { background: var(--red);   border: none; color: #fff; }
.mbtn-save    { background: var(--green); border: none; color: #fff; }

/* ── Share modal ─────────────────────────────────────────────────── */
#share-backdrop { z-index: 200; }
.share-link-row { display: flex; align-items: center; gap: 6px; }
.share-link-mini { font-family: var(--mono); font-size: 11px; padding: 6px 8px; border: 1px solid var(--border2); border-radius: var(--radius-sm); background: var(--surface2); color: var(--text); outline: none; flex: 1; min-width: 0; }

/* ── Projects page ───────────────────────────────────────────────── */
.projects-page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.projects-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.projects-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.projects-title { font-size: 20px; font-weight: 600; margin-bottom: 3px; }
.projects-sub   { font-size: 12px; color: var(--muted); }
.projects-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj-loading   { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; grid-column: 1/-1; }
.proj-empty     { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; grid-column: 1/-1; }
.proj-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s, border-color .15s; }
.proj-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); border-color: var(--border2); }
.proj-locked  { border-color: rgba(214,63,63,.3); background: var(--red-bg); }
.proj-archived{ opacity: .7; }
.proj-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.proj-card-icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--blue-bg); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.proj-card-icon.locked   { background: var(--red-bg);   color: var(--red); }
.proj-card-icon.archived { background: var(--surface2); color: var(--muted); }
.proj-card-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.proj-badge { font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 10px; display: flex; align-items: center; gap: 4px; }
.badge-locked  { background: var(--red-bg);   color: var(--red-text); }
.badge-archived{ background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.badge-editing { background: var(--amber-bg); color: var(--amber-text); }
.proj-card-name  { font-size: 14px; font-weight: 600; }
.proj-card-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }
.proj-card-meta  { display: flex; gap: 10px; flex-wrap: wrap; }
.proj-card-meta span { font-size: 11px; color: var(--hint); display: flex; align-items: center; gap: 3px; }
.proj-card-folder{ font-size: 11px; color: var(--hint); font-family: var(--mono); }
.proj-card-actions { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.proj-open { flex: 1; }
.proj-open:disabled { opacity: .4; cursor: default; }

/* ── Admin layout ────────────────────────────────────────────────── */
.admin-body   { background: var(--bg); }
.admin-layout { display: flex; height: calc(100vh - var(--topbar-h)); overflow: hidden; }
.admin-sidebar { width: 200px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; padding: 10px 0; }
.admin-nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px; color: var(--muted); text-decoration: none; border-left: 3px solid transparent; transition: all .12s; }
.admin-nav-item:hover { background: var(--surface2); color: var(--text); }
.admin-nav-item.active { border-left-color: var(--blue); color: var(--blue); background: var(--blue-bg); font-weight: 500; }
.admin-nav-item i { font-size: 15px; }
.admin-sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.sidebar-stat { font-size: 11px; color: var(--hint); line-height: 1.8; }
.admin-main { flex: 1; overflow-y: auto; padding: 20px 16px; -webkit-overflow-scrolling: touch; }
.admin-tab  { display: none; }
.admin-tab.active { display: block; }
.admin-tab-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.admin-tab-header h2 { font-size: 17px; font-weight: 600; }
.admin-filters { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-filters .input-wrap { width: 200px; }
.admin-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 550px; }
.admin-table thead { background: var(--surface2); }
.admin-table th { padding: 9px 12px; text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--surface2); }
.table-empty { padding: 28px; text-align: center; color: var(--hint); font-size: 13px; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-cell .avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.user-cell-name { font-weight: 500; font-size: 13px; }
.status-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 10px; }
.status-active   { background: var(--green-bg); color: var(--green-text); }
.status-inactive { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.action-btns { display: flex; gap: 5px; justify-content: flex-end; }
.action-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); transition: all .1s; -webkit-tap-highlight-color: transparent; }
.action-btn:hover { background: var(--surface2); color: var(--text); }
.action-btn.danger:hover { background: var(--red-bg); color: var(--red); border-color: rgba(214,63,63,.3); }

/* Drawer */
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 50; }
.drawer-backdrop.open { display: block; }
.drawer { position: fixed; top: 0; right: -420px; width: min(400px, 100vw); height: 100vh; background: var(--surface); border-left: 1px solid var(--border2); display: flex; flex-direction: column; z-index: 51; transition: right .22s ease; }
.drawer.open { right: 0; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-header h3 { font-size: 14px; font-weight: 600; }
.drawer-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--muted); padding: 4px; display: flex; align-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.drawer-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
.drawer-error { font-size: 12px; color: var(--red); min-height: 18px; margin-top: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-desc { font-size: 12px; color: var(--muted); margin-top: 6px; padding: 8px 10px; background: var(--surface2); border-radius: var(--radius-sm); line-height: 1.5; }
.welcome-email-note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--green-bg); color: var(--green-text); border: 1px solid rgba(58,170,95,.2); font-size: 12px; line-height: 1.5; }
.welcome-email-note i { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* Admin versions tab */
.admin-info-bar { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; margin-bottom: 14px; background: var(--blue-bg); color: var(--blue-text); border: 1px solid rgba(59,125,232,.2); border-radius: var(--radius-md); font-size: 12px; line-height: 1.5; }
.v-num-badge { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--muted); flex-shrink: 0; }
.v-name-cell { display: flex; align-items: center; gap: 6px; }
.v-label-short { font-size: 13px; font-weight: 500; cursor: default; }
.v-note { color: var(--amber); cursor: pointer; }
.share-gen-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: none; color: var(--muted); cursor: pointer; font-family: var(--font); }
.share-gen-btn:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.share-copy, .share-revoke { width: 26px; height: 26px; padding: 0; display: flex; align-items: center; justify-content: center; }

/* Admin settings tab */
.settings-grid { display: grid; gap: 20px; max-width: 560px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; }
.settings-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--text); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.settings-label { font-size: 13px; color: var(--text); flex: 1; }
.settings-hint  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.settings-input { width: 180px; padding: 7px 10px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-family: var(--font); font-size: 13px; background: var(--surface); color: var(--text); outline: none; }
.settings-input:focus { border-color: var(--blue); }
.logo-preview { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface2); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — ≤ 768px
══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --topbar-h: 50px; --sidebar-w: 260px; }

  /* Topbar: hide less-essential items on small screens */
  .lock-status { display: none !important; }
  .doc-name { max-width: 100px; }
  .brand-mini-name { display: none; }
  .topbar-sep { display: none; }
  .user-pill .role-badge { display: none; }
  #topbar-display { display: none; }

  /* Sidebar becomes off-canvas drawer on mobile */
  .layout { position: relative; }
  .sidebar {
    position: fixed; left: -100%; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
    width: var(--sidebar-w); z-index: 20; transition: left .25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar-overlay.active { display: block; position: fixed; inset: 0; top: var(--topbar-h); z-index: 19; }
  .sidebar-toggle { display: flex; }

  /* Editor takes full width */
  .editor-panel { width: 100%; }

  /* Quill toolbar: compact, scrollable */
  .quill-toolbar { padding: 4px 6px; gap: 1px; }
  .quill-toolbar button { height: 26px !important; padding: 0 5px !important; }
  .toolbar-right-actions { gap: 4px; }
  .char-count { display: none; }

  /* Footer: stack on small screens */
  .editor-footer { padding: 6px 10px; }
  .btn-outline span, .btn-primary span { display: none; }
  .btn-outline, .btn-primary { padding: 8px 10px; }
  .current-user-badge span { display: none; }

  /* Projects grid: single column */
  .projects-grid { grid-template-columns: 1fr; }
  .projects-page { padding: 14px 12px 60px; }
  .projects-header { gap: 10px; }

  /* Admin: sidebar becomes top nav */
  .admin-layout { flex-direction: column; height: auto; min-height: calc(100vh - var(--topbar-h)); }
  .admin-sidebar { width: 100%; height: auto; padding: 0; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; }
  .admin-nav { display: flex; flex-direction: row; }
  .admin-nav-item { padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .admin-nav-item.active { border-left: none; border-bottom-color: var(--blue); }
  .admin-sidebar-footer { display: none; }
  .admin-main { padding: 14px 12px; }
  .admin-table { min-width: 400px; }
  .drawer { width: 100vw; }
  .form-row { grid-template-columns: 1fr; }

  /* Modal: full-width on mobile */
  .modal { max-width: 100%; }
  .modal-backdrop { padding: 12px; }

  /* Toast: full width bottom */
  .toast-container { left: 16px; right: 16px; bottom: 12px; }
  .toast { max-width: 100%; }

  /* Share link */
  .share-link-mini { font-size: 10px; }
}


  /* Mobile footer fix */
  .screen.active { height: 100vh; height: 100dvh; }
  .layout { height: calc(100dvh - var(--topbar-h)); overflow: hidden; }
  .editor-panel { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  .editor-wrap { flex: 1; overflow: hidden; min-height: 0; }
  #quill-editor { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .editor-footer { position: sticky; bottom: 0; flex-shrink: 0; z-index: 20; }

@media (max-width: 480px) {
  .login-card { padding: 24px 18px; }
  .export-menu { right: auto; left: 0; }
  .quill-toolbar .ql-formats:nth-child(n+4) { display: none; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
}

@media (min-width: 769px) {
  .lock-status { display: flex; }
}

/* ── Version summary icon ─────────────────────────────────────────── */
.vi-summary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 5px; border-radius: 6px;
  border: 1px solid var(--border2); background: none;
  color: var(--muted); cursor: pointer; font-family: var(--font);
  transition: all .15s; -webkit-tap-highlight-color: transparent;
}
.vi-summary:hover { background: var(--blue-bg); color: var(--blue); border-color: var(--blue); }
.vi-summary i { font-size: 12px; }

/* Save summary textarea focus */
#save-summary-text:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,125,232,.12); }

/* ── Version locked badge ────────────────────────────────────────── */
.v-locked-badge { display:inline-flex;align-items:center;margin-left:2px;flex-shrink:0; }
