/* Settings page, project workspace and the live editors (notes, docs, sheets, roadmap, graph, Discord tab). */

/* ---------- settings page ---------- */
.settings-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 80px; }
.settings-nav a { color: var(--text-dim); padding: 7px 10px; border-radius: 8px; }
.settings-nav a:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
@media (max-width: 760px) { .settings-layout { grid-template-columns: 1fr; } .settings-nav { flex-direction: row; position: static; } }

/* ---------- project workspace ---------- */
.workspace { flex: 1; display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.ws-sidebar { background: var(--bg-elev); border-right: 1px solid var(--border); padding: 14px 10px; overflow-y: auto;
    position: sticky; top: 58px; height: calc(100vh - 58px); }
.ws-main { padding: 22px 26px 60px; min-width: 0; }
.ws-project { padding: 4px 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.ws-project-name { font-weight: 700; font-size: 1.05rem; color: var(--text); display: block; }
.ws-nav, .ws-pages { display: flex; flex-direction: column; gap: 1px; }
.ws-link { color: var(--text-dim); padding: 6px 10px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-link:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.ws-link.active { background: var(--bg-elev-2); color: var(--text); font-weight: 600; }
.ws-section { display: flex; align-items: center; justify-content: space-between; margin: 16px 8px 6px;
    font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); font-weight: 700; }
.ws-folder { font-size: .78rem; color: var(--text-dim); padding: 8px 10px 2px; font-weight: 600; }
.ws-empty { padding: 4px 10px; }
.ws-new { position: relative; }
.ws-new > summary { list-style: none; cursor: pointer; padding: 0 6px; border-radius: 6px; font-size: 1rem; color: var(--text); }
.ws-new > summary::-webkit-details-marker { display: none; }
.ws-new-form { position: absolute; left: -180px; top: 24px; z-index: 30; width: 230px; display: flex; flex-direction: column; gap: 6px;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    text-transform: none; letter-spacing: 0; font-weight: 400; }
@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; }
    .ws-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .ws-main { padding: 18px 16px 40px; }
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.stat-card:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-card b { display: block; font-size: 1.6rem; }
.stat-card span { color: var(--text-dim); font-size: .85rem; }
.stat-card.warn b { color: var(--bad); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 16px; }
.chart-grid .card + .card { margin-top: 0; }
.chart-box { position: relative; height: 240px; }
.chart-embed { position: relative; height: 280px; margin: 14px 0; padding-bottom: 24px; }
.chart-title { font-weight: 600; margin-bottom: 6px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.activity time { margin-left: auto; color: var(--text-dim); font-size: .8rem; white-space: nowrap; }

.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; }
.tag-chip { --c: #8e9297; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: var(--c);
    background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
a.tag-chip:hover { text-decoration: none; filter: brightness(1.15); }
.tag-chip.big { font-size: 1.4rem; padding: 2px 14px; }

.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; }
.seg .btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.group { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
button.badge { cursor: pointer; font: inherit; font-size: .75rem; color: var(--text); }

/* ---------- editors: shared ---------- */
.page-head-editor h1 { font-size: 1.5rem; }
.collab-status { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }
.collab-status[data-state="live"] { color: var(--ok); border-color: currentColor; }
.collab-status[data-state="offline"], .collab-status[data-state="deleted"] { color: var(--bad); border-color: currentColor; }
.collab-status[data-state="readonly"] { color: var(--warn); border-color: currentColor; }
.peers { display: inline-flex; gap: 3px; }
.peer { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: .75rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; }
.page-menu { min-width: 260px; gap: 10px; }
.page-menu label { font-weight: 400; display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }

/* notes (CodeMirror) */
.note-toolbar { margin-bottom: 10px; }
.note-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 60vh; }
.note-page[data-mode="edit"] .note-panes, .note-page[data-mode="preview"] .note-panes { grid-template-columns: 1fr; }
.note-page[data-mode="edit"] .note-preview { display: none; }
.note-page[data-mode="preview"] .note-editor { display: none; }
.note-editor { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); }
.note-editor .cm-editor { height: 100%; min-height: 60vh; color: var(--text); background: var(--bg-elev); }
.note-editor .cm-gutters { background: var(--bg-elev-2); border-right-color: var(--border); color: var(--text-dim); }
.note-editor .cm-activeLine, .note-editor .cm-activeLineGutter { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.note-editor .cm-content { font-family: var(--mono); font-size: .92rem; caret-color: var(--text); }
.note-editor .cm-cursor { border-left-color: var(--text); }
.note-editor .cm-tooltip { background: var(--bg-elev); border-color: var(--border); color: var(--text); }
.note-preview { margin: 0 !important; overflow: auto; }
.note-preview a[title="Create this page"] { color: var(--text-dim); border-bottom: 1px dashed currentColor; }
.note-meta { margin-top: 14px; }
@media (max-width: 900px) { .note-panes { grid-template-columns: 1fr; } }

/* docs (Quill) */
.doc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; position: sticky; top: 58px; z-index: 5;
    background: var(--bg-elev); border: 1px solid var(--border) !important; border-radius: var(--radius) var(--radius) 0 0; padding: 6px 8px !important; }
.doc-toolbar .ql-formats { display: inline-flex; align-items: center; margin-right: 10px !important; }
.doc-toolbar .ql-stroke { stroke: var(--text) !important; }
.doc-toolbar .ql-fill { fill: var(--text) !important; }
.doc-toolbar .ql-picker { color: var(--text) !important; }
.doc-toolbar .ql-picker-options { background: var(--bg-elev) !important; border-color: var(--border) !important; }
.doc-toolbar button:hover .ql-stroke, .doc-toolbar .ql-active .ql-stroke { stroke: var(--accent) !important; }
.doc-toolbar button:hover .ql-fill, .doc-toolbar .ql-active .ql-fill { fill: var(--accent) !important; }
.doc-paper { background: var(--bg-elev); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.doc-paper .ql-container.ql-snow { border: 0; font-size: 16px; font-family: inherit; color: var(--text); }
.doc-paper .ql-editor { min-height: 65vh; max-width: 860px; margin: 0 auto; padding: 36px 40px; line-height: 1.6; }
.doc-paper .ql-editor.ql-blank::before { color: var(--text-dim); }
.doc-footer { margin-top: 8px; }
.font-picker { position: relative; }
.font-button { width: 150px !important; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: 6px; padding: 3px 8px !important; height: auto !important; }
.font-panel { position: absolute; top: 34px; left: 0; z-index: 40; width: 300px; padding: 8px !important; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.font-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; margin-top: 6px; }
.font-list button { all: unset; display: flex !important; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px;
    cursor: pointer; color: var(--text); font-size: 15px; width: auto !important; height: auto !important; }
.font-list button:hover { background: var(--bg-elev-2); }
.font-list small { color: var(--text-dim); font-family: var(--font); font-size: .7rem; }
.ql-snow .ql-tooltip { background: var(--bg-elev); color: var(--text); border-color: var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, .3); }
.ql-snow .ql-tooltip input[type=text] { background: var(--bg); color: var(--text); border-color: var(--border); }
@media print {
    .topbar, .ws-sidebar, .doc-toolbar, .page-head-editor, .doc-footer, .flash { display: none !important; }
    .workspace { display: block; }
    .doc-paper { border: 0; background: #fff; }
    .doc-paper .ql-container.ql-snow { color: #000; }
}

/* sheets */
.sheet-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.sheet-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.color-btn { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; margin: 0; cursor: pointer;
    padding: 2px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev-2); }
.color-btn input[type=color] { width: 20px; height: 20px; border: 0; padding: 0; background: none; }
.formula-row { display: flex; gap: 6px; margin-bottom: 6px; }
.cell-name { min-width: 60px; text-align: center; padding: 6px; background: var(--bg-elev-2); border: 1px solid var(--border);
    border-radius: 8px; font-family: var(--mono); font-size: .85rem; }
.formula { font-family: var(--mono); }
.sheet-grid { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); outline: none; }
.sheet-grid:focus { border-color: var(--accent); }
table.sheet { border-collapse: collapse; table-layout: fixed; font-size: .88rem; }
.sheet th { position: sticky; top: 0; background: var(--bg-elev-2); color: var(--text-dim); font-weight: 600; font-size: .78rem;
    border: 1px solid var(--border); padding: 4px; z-index: 2; user-select: none; }
.sheet tbody th { left: 0; width: 46px; min-width: 46px; z-index: 1; }
.sheet thead th.corner { left: 0; z-index: 3; width: 46px; }
.sheet td { border: 1px solid var(--border); padding: 3px 6px; height: 26px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; cursor: cell; color: var(--text); }
.sheet td.sel { background: color-mix(in srgb, var(--accent) 14%, transparent) !important; }
.sheet td.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.sheet td.err { color: var(--bad); }
.sheet .col-resize { position: absolute; right: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.cell-input { width: 100%; border: 0 !important; padding: 0 !important; background: transparent !important; outline: none !important;
    font: inherit; color: inherit; border-radius: 0 !important; }
.sheet-page.readonly .sheet td { cursor: default; }

/* roadmap */
.roadmap-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.rm-panel { width: 320px; margin: 0 !important; position: sticky; top: 76px; }
.rm-panel label { font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.timeline { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); overflow: hidden; }
.rm { display: grid; grid-template-columns: 150px minmax(0, 1fr); }
.rm-lanes { border-right: 1px solid var(--border); background: var(--bg-elev-2); }
.rm-corner { height: 32px; border-bottom: 1px solid var(--border); }
.rm-lane-label { padding: 10px; font-weight: 600; font-size: .88rem; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; }
.rm-scroll { overflow-x: auto; }
.rm-header { position: relative; height: 32px; border-bottom: 1px solid var(--border); }
.rm-month { position: absolute; top: 0; height: 32px; line-height: 32px; padding-left: 6px; font-size: .78rem; color: var(--text-dim);
    border-left: 1px solid var(--border); white-space: nowrap; }
.rm-body { position: relative; }
.rm-lane { position: relative; border-bottom: 1px solid var(--border); }
.rm-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); opacity: .7; pointer-events: none; }
.rm-bar { --c: #5865f2; position: absolute; height: 30px; border-radius: 6px; background: color-mix(in srgb, var(--c) 35%, var(--bg-elev));
    border: 1px solid var(--c); overflow: hidden; cursor: pointer; display: flex; align-items: center; touch-action: none; user-select: none; }
.rm-bar.dragging, .rm-milestone.dragging { opacity: .8; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); z-index: 5; }
.rm-progress { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); opacity: .55; pointer-events: none; }
.rm-label { position: relative; padding: 0 8px; font-size: .8rem; font-weight: 600; white-space: nowrap; color: var(--text); pointer-events: none; }
.rm-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2; }
.rm-handle.l { left: 0; }
.rm-handle.r { right: 0; }
.rm-milestone { --c: #faa61a; position: absolute; width: 18px; height: 18px; background: var(--c); transform: rotate(45deg);
    border-radius: 3px; cursor: pointer; touch-action: none; user-select: none; }
.rm-milestone .rm-label { position: absolute; left: 22px; top: -2px; transform: rotate(-45deg); transform-origin: left top; }
@media (max-width: 1000px) { .roadmap-wrap { grid-template-columns: 1fr; } .rm-panel { width: auto; position: static; } }

/* graph */
.graph-filters { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; }
.graph-filters .check { margin: 0; }
.graph-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; }
.graph-canvas { height: 70vh; margin: 0 !important; padding: 0 !important; }
.graph-info { margin: 0 !important; max-height: 70vh; overflow-y: auto; }
.graph-links { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.graph-links li { padding: 4px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 900px) { .graph-wrap { grid-template-columns: 1fr; } }

/* discord tab */
.dc-chat { display: flex; flex-direction: column; height: 72vh; padding: 0 !important; }
.dc-messages { flex: 1; overflow-y: auto; padding: 14px 16px; }
.dc-msg { display: flex; gap: 10px; padding: 7px 0; }
.dc-msg.from-site { background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 8px; padding: 7px; }
.dc-img { max-width: 320px; max-height: 240px; border-radius: 8px; display: block; margin-top: 6px; }
.dc-send { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.dc-send textarea { min-height: 44px; flex: 1; }
