/* SovrenAI Publish — Document Editor + AI Content Generator */
/* SovrenAI Design Standard v1.0: light only, IBM Plex Sans, blue/green/amber */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #FAFAFA;
  --white: #FFFFFF;
  --text: #111111;
  --muted: #666666;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #2563EB;
  --green: #7dba7d;
  --green-bg: #1a2e1a;
  --red: #c96b6b;
  --amber: #D97706;
  --amber-bg: #2e2a1a;
  --ui: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--ui); background: var(--bg); color: var(--text); height: 100vh; display: flex; overflow: hidden; font-size: 15px; }

/* ── Toolbar (left, 52px) ── */
.toolbar {
  width: 52px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 2px; flex-shrink: 0;
}
.tb {
  width: 38px; height: 38px; border-radius: 8px; border: none; background: transparent;
  color: var(--muted); font-size: 17px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; position: relative;
}
.tb:hover { background: var(--bg); color: var(--text); }
.tb.active { background: rgba(37, 99, 235, 0.08); color: var(--accent); }
.tb .tip {
  display: none; position: absolute; left: 48px; background: var(--white); color: var(--text);
  padding: 3px 8px; border-radius: 5px; font-size: 10px; white-space: nowrap; z-index: 99;
  border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tb:hover .tip { display: block; }
.tb-sep { width: 24px; height: 1px; background: var(--border); margin: 4px 0; }

/* ── Drawer (left, 220px) ── */
.drawer {
  width: 0; overflow: hidden; background: var(--white); border-right: 1px solid var(--border);
  transition: width 0.2s; flex-shrink: 0;
}
.drawer.open { width: 220px; }
.drawer-head { padding: 10px; border-bottom: 1px solid var(--border); }
.drawer-head input {
  width: 100%; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; font-size: 11px; outline: none; font-family: var(--ui);
}
.drawer-head input:focus { border-color: var(--accent); }
.drawer-list { overflow-y: auto; padding: 4px; max-height: calc(100vh - 50px); }
.ditem { padding: 7px 8px; border-radius: 5px; cursor: pointer; font-size: 11px; margin-bottom: 1px; }
.ditem:hover { background: var(--bg); }
.ditem.active { background: rgba(37, 99, 235, 0.06); border-left: 3px solid var(--accent); }
.ditem .dt { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem .dm { color: var(--muted); font-size: 10px; margin-top: 2px; }

/* ── Main area ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Header ── */
.head {
  display: flex; align-items: center; padding: 6px 16px; background: var(--white);
  border-bottom: 1px solid var(--border); gap: 8px; flex-shrink: 0;
}
.head input {
  flex: 1; background: none; border: none; color: var(--text); font-size: 16px;
  font-weight: 300; outline: none; font-family: var(--ui);
}
.head input::placeholder { color: var(--muted); }
.hbtn {
  padding: 4px 10px; border-radius: 5px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 10px; cursor: pointer;
  font-weight: 600; font-family: var(--ui);
}
.hbtn:hover { border-color: var(--accent); color: var(--accent); }
.hbtn.green { background: var(--green); border-color: var(--green); color: #fff; }
.hbtn.green:hover { filter: brightness(1.1); }
.hbtn.amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.hbtn.publish { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.ok { background: var(--green); }
.user-indicator { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }

/* ── Chat panel ── */
.chat-panel {
  display: flex; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--border);
  max-height: 280px; overflow: hidden; transition: max-height 0.2s;
}
.chat-panel.collapsed { max-height: 44px; }
.chat-toggle {
  padding: 5px 12px; background: none; border: none; color: var(--accent); font-size: 11px;
  cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 6px; font-family: var(--ui);
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 6px 16px; }
.chat-msg { margin-bottom: 6px; font-size: 13px; line-height: 1.5; }
.chat-msg.human { color: var(--text); }
.chat-msg.human::before { content: 'You: '; color: var(--muted); font-size: 11px; }
.chat-msg.ai {
  color: var(--muted); padding: 6px 10px; background: var(--white);
  border-radius: 6px; border-left: 2px solid var(--accent);
}
.chat-msg.ai strong { color: var(--text); }
.chat-input { display: flex; padding: 6px 12px; gap: 6px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; padding: 6px 10px; background: var(--white); border: 1px solid var(--border);
  color: var(--text); border-radius: 5px; font-size: 12px; outline: none; font-family: var(--ui);
}
.chat-input input:focus { border-color: var(--accent); }
.chat-input button {
  padding: 5px 12px; border: none; border-radius: 5px; font-size: 11px;
  font-weight: 600; color: #fff; cursor: pointer; font-family: var(--ui);
}
.chat-status { padding: 2px 12px; font-size: 10px; color: var(--muted); }

/* ── Canvas ── */
.canvas { flex: 1; overflow-y: auto; padding: 24px 32px 80px; }
.canvas-inner { max-width: 720px; margin: 0 auto; }

/* ── Blocks ── */
.blk { position: relative; margin-bottom: 1px; border-radius: 6px; transition: background 0.15s; }
.blk:hover { background: rgba(37, 99, 235, 0.02); }
.blk:hover .blk-x { opacity: 1; }
.blk-x {
  position: absolute; right: -4px; top: 4px; opacity: 0; width: 20px; height: 20px;
  border-radius: 4px; border: none; background: var(--bg); color: var(--muted); font-size: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity 0.15s;
}
.blk-x:hover { color: var(--red); }

/* Text blocks */
.blk-text { padding: 3px 6px; }
.blk-text [contenteditable] { outline: none; font-size: 15px; line-height: 1.7; }
.blk-text [contenteditable]:empty::before { content: attr(data-ph); color: var(--muted); }
.blk-text.h1 [contenteditable] { font-size: 26px; font-weight: 600; line-height: 1.3; margin: 20px 0 6px; }
.blk-text.h2 [contenteditable] { font-size: 18px; font-weight: 500; line-height: 1.3; margin: 14px 0 4px; color: var(--muted); }
.blk-text.qt [contenteditable] { border-left: 3px solid var(--accent); padding-left: 14px; font-style: italic; color: var(--muted); }
.tier-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* Code blocks */
.blk-code { margin: 6px 0; }
.code-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px; background: #EEEEEE; border-radius: 6px 6px 0 0;
  border: 1px solid var(--border); border-bottom: none;
}
.code-top .lang { font-size: 10px; color: var(--muted); }
.run-btn { padding: 2px 8px; background: var(--green); border: none; color: #fff; border-radius: 3px; font-size: 10px; font-weight: 700; cursor: pointer; }
.edit-btn { padding: 2px 8px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); border-radius: 3px; font-size: 10px; cursor: pointer; }
.blk-code pre {
  margin: 0; padding: 10px 12px; background: #1E1E1E; border: 1px solid var(--border); border-top: none;
  color: #D4D4D4; font-family: var(--mono); font-size: 12px; line-height: 1.5; overflow-x: auto; white-space: pre-wrap;
}
.blk-code textarea {
  display: none; width: 100%; min-height: 60px; padding: 10px 12px; background: #1E1E1E;
  border: 1px solid var(--accent); border-top: none; color: #D4D4D4; font-family: var(--mono);
  font-size: 12px; line-height: 1.5; resize: vertical; outline: none;
}
.code-out {
  padding: 8px 12px; background: #EEEEEE; border: 1px solid var(--border);
  border-top: 2px solid var(--green); border-radius: 0 0 6px 6px;
  font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: pre-wrap;
}
.code-out.err { border-top-color: var(--red); }
.code-out .olbl { font-size: 9px; font-weight: 700; letter-spacing: 0.5px; }

/* YouTube */
.blk-yt { margin: 8px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.blk-yt iframe { width: 100%; height: 315px; border: none; display: block; }
.blk-yt .yt-cap { padding: 6px 10px; background: var(--white); font-size: 11px; color: var(--muted); }

/* Image */
.blk-img { margin: 6px 0; text-align: center; }
.blk-img img { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.blk-img .cap { font-size: 11px; color: var(--muted); margin-top: 4px; font-style: italic; }

/* Stage/Slide */
.blk-stage {
  margin: 10px 0; padding: 50px 24px; border-radius: 10px; border: 1px solid var(--border);
  text-align: center; min-height: 160px; display: flex; align-items: center;
  justify-content: center; flex-direction: column;
}
.blk-stage [contenteditable] { font-size: 32px; font-weight: 300; outline: none; min-width: 200px; text-align: center; }
.blk-stage [contenteditable]:empty::before { content: 'Type message...'; color: var(--muted); }

/* Audio */
.blk-audio {
  padding: 6px; display: flex; align-items: center; gap: 8px;
  background: var(--white); border-radius: 6px; border: 1px solid var(--border);
}
.blk-audio audio { flex: 1; height: 28px; }

/* Divider */
.blk-div { padding: 10px 0; }
.blk-div hr { border: none; border-top: 1px solid var(--border); }

/* Insert line */
.ins-line { height: 0; position: relative; margin: 0 6px; }
.ins-line:hover { height: 2px; background: rgba(37, 99, 235, 0.1); }
.ins-line .ins-btn {
  display: none; position: absolute; left: 50%; top: -7px; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent); color: #fff;
  border: none; font-size: 10px; line-height: 14px; text-align: center; cursor: pointer; z-index: 5;
}
.ins-line:hover .ins-btn { display: block; }

/* Insert menu */
.ins-menu {
  display: none; position: fixed; background: var(--white); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; z-index: 200; min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.ins-menu.open { display: block; }
.ins-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px;
  background: none; border: none; color: var(--text); font-size: 12px; cursor: pointer;
  border-radius: 5px; font-family: var(--ui);
}
.ins-menu button:hover { background: var(--bg); }
.ins-menu .ic { width: 20px; text-align: center; font-size: 14px; }

/* Sources */
.sources { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.sources h3 { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sources a { color: var(--accent); text-decoration: none; font-size: 11px; }
.sources a:hover { text-decoration: underline; }

/* Share bar */
.share-bar { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.share-bar a, .share-bar button {
  padding: 5px 10px; border-radius: 5px; font-size: 10px; font-weight: 600;
  color: #fff; text-decoration: none; border: none; cursor: pointer; font-family: var(--ui);
}

/* Footer */
.foot {
  padding: 5px 16px; border-top: 1px solid var(--border); background: var(--white);
  font-size: 10px; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-shrink: 0;
}

/* Preview */
.preview { display: none; position: fixed; inset: 0; background: var(--white); z-index: 300; overflow-y: auto; }
.preview.open { display: block; }
.preview-close {
  position: fixed; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 16px; cursor: pointer; z-index: 310;
}

/* Auth modal */
.auth-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 500; align-items: center; justify-content: center; }
.auth-modal.open { display: flex; }
.auth-box { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 320px; }
.auth-box h3 { margin-bottom: 16px; font-size: 16px; }
.auth-box input {
  width: 100%; padding: 8px 10px; margin-bottom: 8px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text); border-radius: 5px; font-size: 12px;
  outline: none; font-family: var(--ui);
}
.auth-box input:focus { border-color: var(--accent); }
.auth-box button { width: 100%; padding: 8px; border: none; border-radius: 5px; font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 4px; font-family: var(--ui); }
.auth-box .auth-primary { background: var(--accent); color: #fff; }
.auth-box .auth-switch { background: transparent; color: var(--muted); font-size: 11px; }
.auth-box .auth-error { color: var(--red); font-size: 11px; margin-top: 4px; min-height: 16px; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Tablet */
@media (max-width: 900px) {
  .tb, .hbtn { min-height: 36px; padding: 6px 10px; }
  .drawer { width: 220px; }
  .chat-panel { width: 260px; }
}

/* Mobile */
@media (max-width: 600px) {
  .toolbar { padding: 0 8px; gap: 4px; overflow-x: auto; }
  .tb, .hbtn { min-height: 44px; padding: 10px 12px; font-size: 13px; }
  .tb .tip { display: none; }
  .head { flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
  .head input { font-size: 16px; }
  .drawer { width: 100%; }
  .chat-panel { width: 100%; }
  .canvas { padding: 12px; }
}

/* Print */
@media print { .toolbar, .drawer, .head, .chat-panel, .foot, .ins-line, .blk-x { display: none !important; } .canvas { padding: 0; } }
