/* kymo editor — light brand theme (docs/brand: Mermaid palette) */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7fa;
  --bg-raise: #efeef4;
  --border: #e7e5ee;
  --border-strong: #cfccdc;
  --ink: #242131;
  --dim: #6e6a7c;
  --accent: #e0095f;
  --accent-deep: #c70854;
  --accent-soft: rgba(224, 9, 95, 0.08);
  --teal: #ddecee;
  --error: #b42318;
  --radius: 14px;
  --radius-btn: 9px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
::selection { background: rgba(224, 9, 95, 0.16); }
:focus-visible { outline: 2px solid rgba(224, 9, 95, 0.45); outline-offset: 1px; }
[hidden] { display: none !important; }

.layout { height: 100%; display: flex; flex-direction: column; }
/* editor body: file sidebar + the source/preview panes. main keeps its own flex
   geometry so the source/preview split math is unaffected by the sidebar. */
.workarea { flex: 1; display: flex; min-height: 0; }

/* ---- header ---- */
header { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
/* padding+negative margin = an invisible ~44px touch target around the 24px mark */
.brand { display: inline-flex; align-items: center; gap: 8px; padding: 10px; margin: -10px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.brand img { width: 24px; height: 24px; display: block; }
.sep { color: var(--border-strong); user-select: none; }
.spacer { flex: 1; }

/* right-side action cluster: nav · create · output (Share = CTA); account sits outside, last */
.nav-group { display: flex; align-items: center; gap: 8px; }
.navlink { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--radius-btn); font-size: 13.5px; font-weight: 600; color: var(--dim); text-decoration: none; transition: background-color 0.16s ease, color 0.16s ease; }
.navlink:hover { background: var(--bg-soft); color: var(--ink); }
.muted { font-size: 12.5px; color: var(--dim); }

button, .btn { background: var(--bg); color: var(--ink); border: 1px solid var(--border-strong); border-radius: var(--radius-btn); padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--dim); background: var(--bg-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { background: var(--error); border-color: var(--error); color: #fff; font-weight: 700; }
.btn-danger:hover { background: #9a1d13; border-color: #9a1d13; }
.btn-danger:focus-visible { outline: 2px solid rgba(180, 35, 24, 0.5); outline-offset: 1px; }

/* ---- confirm modal (replaces window.confirm for deletes) ---- */
.confirm-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(36, 33, 49, 0.4); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.confirm-card { position: relative; width: min(440px, calc(100vw - 32px)); background: var(--bg); border-radius: var(--radius); box-shadow: 0 24px 64px rgba(36, 33, 49, 0.32); padding: 22px 22px 18px; }
.confirm-x { position: absolute; top: 12px; right: 12px; border: 0; background: transparent; color: var(--dim); padding: 5px; border-radius: 7px; }
.confirm-x:hover { background: var(--bg-soft); color: var(--ink); transform: none; box-shadow: none; }
.confirm-body { display: flex; gap: 14px; padding-right: 18px; }
.confirm-icon { flex: none; display: inline-flex; color: #e0a23c; margin-top: 1px; }
.confirm-icon.danger { color: #e0a23c; }
.confirm-text { min-width: 0; }
.confirm-title { margin: 0; font-size: 15.5px; font-weight: 700; line-height: 1.4; color: var(--ink); }
.confirm-detail { margin: 5px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--dim); }
.confirm-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.confirm-foot button { padding: 8px 18px; }

/* padding is asymmetric on purpose: mixed-case labels are optically centered on
   their x-height band, which sits ~1px below the box center — next to the solid
   24px brand tile that 1px reads as "text too low", so the ink is raised. */
.diagram-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 14.5px; font-weight: 650; color: var(--ink); padding: 2px 8px 4px; border-radius: 7px; }
/* long titles ellipsize instead of wrapping the header (rename input still shows the full name) */
.dn-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diagram-name.editable { cursor: text; }
.diagram-name.untitled { color: var(--dim); font-weight: 500; }
.diagram-name.editable:hover { background: var(--bg-raise); }
/* rename affordance: the pencil only materialises on hover, but it exists */
.diagram-name .pencil { color: var(--dim); opacity: 0; flex: none; transition: opacity 0.15s ease; }
.diagram-name.editable:hover .pencil { opacity: 1; }

/* sync state next to the title (room mode): green = every change persisted */
.save-ind { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 11.5px; font-weight: 600; color: var(--dim); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 2.5px 10px; }
.save-ind::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #34a853; }
.save-ind.off { color: #8a6116; background: #fdf6e7; border-color: #f0dfb6; }
.save-ind.off::before { background: #e6a23c; }
/* a draft that isn't on the server yet — the visible Save button does the saving */
.save-ind.unsaved { color: #8a6116; background: #fdf6e7; border-color: #f0dfb6; }
.save-ind.unsaved::before { background: #e6a23c; }
.diagram-input { font: inherit; font-size: 14px; font-weight: 600; background: var(--bg); border: 1px solid var(--accent); border-radius: 7px; color: var(--ink); padding: 3px 8px; outline: none; min-width: 160px; }

.account { position: relative; }
.mob-more { display: none; } /* phones only — see the 720px media block */
.acct-btn { display: inline-flex; align-items: center; gap: 2px; padding: 3px 5px 3px 3px; border-radius: 999px; background: var(--bg-raise); border-color: transparent; }
.acct-btn:hover { background: var(--border); border-color: transparent; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--ink); }
.acct-btn .chev { color: var(--dim); margin: 0 2px; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; box-shadow: 0 12px 32px rgba(36, 33, 49, 0.14); z-index: 20; }
.acct-head { padding: 8px 10px 10px; font-size: 12px; color: var(--dim); border-bottom: 1px solid var(--border); }
.acct-head b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; margin-top: 2px; word-break: break-all; }
.acct-item { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; margin-top: 4px; color: var(--ink); font-weight: 500; }
.acct-item:hover { background: var(--bg-soft); border-color: transparent; }
.exp-menu { min-width: 190px; }
.exp-menu::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; } /* hover bridge over the gap */
.exp-item { display: flex; align-items: center; justify-content: flex-start; gap: 9px; font-size: 13.5px; }
a.exp-item { text-decoration: none; } /* Docs/Diagrams links inside the ⋯ menu */
.exp-item svg { flex: none; color: var(--dim); }
.exp-item:hover svg { color: var(--accent); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* share popover (Figma-style panel under the Share CTA) */
.share-menu { width: min(380px, calc(100vw - 20px)); padding: 12px; cursor: default; }
.share-head { font-size: 13.5px; font-weight: 700; padding: 2px 4px 0; }
.share-desc { margin: 4px 4px 10px; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.share-row { display: flex; gap: 6px; }
.share-url { flex: 1; min-width: 0; font: 12px/1.4 var(--mono); color: var(--ink); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; outline: none; text-overflow: ellipsis; }
.share-url:focus { border-color: rgba(224, 9, 95, 0.45); background: var(--bg); }
.share-copy { flex: none; padding: 7px 12px; font-size: 13px; min-width: 86px; }
.share-warn { margin: 8px 2px 0; font-size: 12px; color: #8a6116; background: #fdf6e7; border: 1px solid #f0dfb6; border-radius: 8px; padding: 7px 10px; line-height: 1.5; }
.share-menu .menu-sep { margin: 10px 2px 4px; }
.share-menu .acct-item[disabled] { opacity: 0.5; cursor: default; }
.chev-icon { color: var(--dim); margin-right: -3px; }

/* ---- editor panes ---- */
main { flex: 1; display: flex; min-height: 0; }
main.scroll { display: block; overflow: auto; }
.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pane + .pane { border-left: 1px solid var(--border); }
textarea { flex: 1; width: 100%; resize: none; border: 0; outline: none !important; padding: 16px; background: var(--bg); color: var(--ink); caret-color: var(--accent); font: 13.5px/1.7 var(--mono); tab-size: 2; }
#preview { flex: 1; position: relative; overflow: hidden; background: #fff; touch-action: none; cursor: grab; }
#preview:active { cursor: grabbing; }
.pv-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.pv-stage svg { display: block; background: #fff; }
.pv-controls { position: absolute; right: 12px; bottom: 12px; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 3px; background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); cursor: default; }
.pv-controls button { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink); border-radius: 7px; cursor: pointer; }
.pv-controls button svg { flex: none; }
.pv-controls button:hover { background: var(--bg-raise); color: var(--accent); }
.pv-controls .pv-pct { width: auto; min-width: 46px; padding: 0 7px; font: 12px/1 var(--mono); color: var(--dim); }
.pv-controls .pv-pct:hover { color: var(--accent); background: var(--bg-raise); }
/* ---- activity bar (VSCode-style left icon rail) ---- */
.activitybar { flex: none; width: 52px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 8px 0; border-right: 1px solid var(--border); background: var(--bg-soft); z-index: 41; }
.act-group { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; }
.act-btn { position: relative; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--dim); border-radius: 10px; cursor: pointer; }
.act-btn:hover { background: var(--bg-raise); color: var(--ink); transform: none; box-shadow: none; }
.act-btn.active { color: var(--ink); }
.act-btn.active::before { content: ""; position: absolute; left: -6px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.act-account .avatar { width: 28px; height: 28px; font-size: 13px; }
.act-pop-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.act-popover { right: auto; top: auto; left: calc(100% + 6px); bottom: 0; min-width: 210px; }
.act-popover .acct-item { display: flex; align-items: center; gap: 9px; }

/* ---- file sidebar / panels (VSCode-style explorer in the editor) ---- */
.sidebar { flex: none; width: 240px; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--bg-soft); }
/* search / filter box at the top of the Search & Templates panels */
.sb-search { display: flex; align-items: center; gap: 7px; margin: 8px 10px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.sb-search:focus-within { border-color: rgba(224, 9, 95, 0.45); }
.sb-search svg { flex: none; color: var(--dim); }
.sb-search input { border: 0; outline: 0; flex: 1; min-width: 0; font: inherit; font-size: 13px; background: transparent; color: var(--ink); }
.sb-kind { flex: none; font-size: 10.5px; color: var(--dim); background: var(--bg-raise); border-radius: 999px; padding: 1px 7px; }
.sb-tpl { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; color: var(--ink); }
.sb-tpl:hover { background: var(--bg-raise); }
.sb-tpl-glyph { flex: none; width: 18px; height: 18px; display: inline-flex; color: var(--dim); }
.sb-tpl:hover .sb-tpl-glyph { color: var(--accent); }
.sb-tpl-glyph svg { width: 18px; height: 18px; }
.sb-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--border); }
.sb-title { flex: 1; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); }
.sb-head button { flex: none; padding: 5px; border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 7px; }
.sb-head button:hover { background: var(--bg-raise); border-color: transparent; color: var(--accent); transform: none; box-shadow: none; }
.sb-tree { flex: 1; overflow: auto; padding: 4px 0 12px; }
.sb-tree.dragover-root { box-shadow: inset 0 0 0 2px rgba(224, 9, 95, 0.18); }
.sb-folder, .sb-file { display: flex; align-items: center; gap: 6px; padding: 5px 8px; font-size: 13px; cursor: pointer; color: var(--ink); white-space: nowrap; user-select: none; }
.sb-folder:hover, .sb-file:hover { background: var(--bg-raise); }
.sb-folder { font-weight: 600; }
.sb-chev, .sb-icon { flex: none; color: var(--dim); display: inline-flex; }
.sb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-file.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.sb-file.active .sb-name { color: var(--accent-deep); font-weight: 600; }
.sb-file.active .sb-icon { color: var(--accent); }
.sb-folder.dragover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(224, 9, 95, 0.4); }
.sb-actions { flex: none; display: inline-flex; gap: 0; opacity: 0; transition: opacity 0.14s ease; }
.sb-folder:hover .sb-actions, .sb-file:hover .sb-actions, .sb-actions:focus-within { opacity: 1; }
.sb-actions button { flex: none; padding: 3px; border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 6px; }
.sb-actions button:hover { background: var(--bg); border-color: transparent; color: var(--accent); transform: none; box-shadow: none; }
.sb-empty { padding: 14px 12px; font-size: 12.5px; color: var(--dim); }
.sb-backdrop { display: none; }
@media (hover: none) { .sb-actions { opacity: 1; } }
/* phones: the rail stays pinned at the left; the panel slides in as a drawer
   beside it, with a backdrop over the editor area. */
@media (max-width: 720px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 52px; z-index: 40; width: min(260px, 74vw); box-shadow: 0 8px 40px rgba(36, 33, 49, 0.28); }
  .sb-backdrop { display: block; position: fixed; top: 0; bottom: 0; right: 0; left: 52px; z-index: 39; background: rgba(36, 33, 49, 0.35); }
}

.status { font: 12px/1.5 var(--mono); padding: 7px 14px; border-top: 1px solid var(--border); color: var(--dim); min-height: 28px; white-space: pre-wrap; background: var(--bg); }
.status.error { color: var(--error); background: rgba(180, 35, 24, 0.06); border-top-color: rgba(180, 35, 24, 0.25); font-weight: 600; }
/* invalid share link: a banner the user can't miss (the status line races with renders) */
.share-error { margin: 14px 14px 0; padding: 11px 14px; border: 1px solid rgba(180, 35, 24, 0.3); background: rgba(180, 35, 24, 0.06); color: var(--error); border-radius: 10px; font-size: 13.5px; font-weight: 500; }

/* ---- loading ---- */
.skeleton { display: inline-block; height: 13px; border-radius: 7px; background: linear-gradient(90deg, var(--bg-raise) 25%, var(--border) 50%, var(--bg-raise) 75%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
.name-skel { width: 110px; height: 14px; vertical-align: middle; }
@keyframes shimmer { to { background-position: -200% 0; } }
.boot { flex: 1; display: grid; place-items: center; background: var(--bg-soft); }
/* Miro-style logo loader: the K's three strokes sweep through the brand tile —
   slide in from the left (hard ease-out), hold, accelerate out to the right. */
.kloader { display: grid; grid-template-rows: 1fr; width: 100px; min-height: 100px; background: var(--accent); border-radius: 18px; overflow: hidden; }
.kloader > div { grid-area: 1 / 1 / -1 / -1; transform: translateX(-120px); }
.kloader > div > svg { display: block; width: 100px; height: 100px; }
.kloader > .k1 { animation: logo-part 2.3s ease 0s infinite; }
.kloader > .k2 { animation: logo-part 2.3s ease 0.05s infinite; }
.kloader > .k3 { animation: logo-part 2.3s ease 0.1s infinite; }
@keyframes logo-part {
  0% { transform: translateX(-150px) scaleX(1.6); animation-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1); }
  28.696% { transform: translateX(0) scaleX(1); animation-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1); }
  57.391% { transform: translateX(0) scaleX(1); animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.335); }
  86.957%, 100% { transform: translateX(150px) scaleX(1.6); }
}
@media (prefers-reduced-motion: reduce) {
  .kloader > div { animation: none !important; transform: none; }
}
button:active, .btn:active, .pill:active { transform: translateY(1px); }

/* ---- diagrams page ---- */
.page { max-width: 880px; margin: 0 auto; padding: 44px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { font-family: var(--font); font-weight: 800; font-size: 32px; letter-spacing: -0.02em; margin: 0; color: var(--ink); }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 600; background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.pill:hover { border-color: var(--dim); background: var(--bg-soft); }
.pill-dark { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pill-dark:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.search { display: flex; align-items: center; gap: 10px; margin: 26px 0 6px; border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 16px; background: var(--bg); }
.search:focus-within { border-color: rgba(224, 9, 95, 0.55); }
.search svg { flex: none; color: var(--dim); }
.search input { border: 0; outline: 0; flex: 1; font: inherit; font-size: 15px; background: transparent; color: var(--ink); }
.search input::placeholder { color: var(--dim); }
.rows { margin-top: 6px; }
.rrow { display: flex; align-items: center; gap: 14px; padding: 18px 10px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--ink); }
.rrow:hover { background: var(--bg-soft); }
.rthumb { flex: none; width: 60px; height: 42px; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; color: var(--border-strong); }
.rthumb.empty { background: var(--bg-soft); }
.rthumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; padding: 3px; }
.rtitle { font-size: 15px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtime { color: var(--dim); font-size: 13.5px; min-width: 110px; text-align: right; flex: none; }
.rdel { opacity: 0; background: transparent; border: 0; color: var(--dim); font-size: 13px; font-weight: 500; cursor: pointer; padding: 4px 9px; border-radius: 7px; flex: none; }
.rrow:hover .rdel, .rdel:focus-visible { opacity: 1; }
.rdel:hover { color: var(--error); background: rgba(180, 35, 24, 0.08); }
.empty { color: var(--dim); padding: 28px 10px; font-size: 15px; }
.signin { display: grid; place-items: center; gap: 14px; padding: 90px 0; }
.login-card { padding: 120px 0 0; text-align: center; }
.login-card .brand img { width: 44px; height: 44px; }
.login-card h1 { font-weight: 800; font-size: 28px; letter-spacing: -0.02em; margin: 6px 0 0; }
.login-card .muted { margin: 0 0 10px; line-height: 1.7; }
.foot { margin-top: 26px; font-size: 13px; color: var(--dim); display: flex; gap: 10px; align-items: center; }
.linklike { background: none; border: 0; padding: 0; color: var(--dim); font-size: 13px; font-weight: 400; cursor: pointer; text-decoration: underline; }
.linklike:hover { color: var(--ink); }

/* workspaces */
.ws-btn { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 9px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.ws-btn:hover { background: var(--bg-soft); }
.ws-menu { left: 0; right: auto; min-width: 235px; }
.ws-head { font-size: 11.5px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 10px 2px; }
.ws-item { display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; text-decoration: none; font-size: 14px; }
.ws-check { width: 16px; display: inline-flex; justify-content: center; flex: none; color: var(--accent); }
.ws-new { color: var(--dim); }
.ws-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.ws-pill { border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); cursor: pointer; }
.ws-pill:hover { border-color: var(--dim); background: var(--bg-soft); }
.ws-pill.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ws-add { display: inline-flex; align-items: center; padding: 6px 9px; color: var(--dim); }
.ws-actions { display: inline-flex; gap: 12px; margin-left: 6px; }
.rmove { opacity: 0; flex: none; border: 1px solid var(--border); background: var(--bg); color: var(--dim); font-size: 12.5px; border-radius: 7px; padding: 3px 6px; cursor: pointer; }
.rrow:hover .rmove, .rmove:focus { opacity: 1; }

/* diagram kind selector (kroki-style) */
.pane-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg); }
/* a quiet caption so the dropdown reads as a format switcher, not a mystery control */
.kind-label { font-size: 11.5px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.kind-select { border: 1px solid var(--border-strong); border-radius: 8px; padding: 5px 9px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--bg); cursor: pointer; }
.kind-select:hover { border-color: var(--dim); }
/* per-kind syntax help — always an exit when the source won't render */
.syntax-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--dim); text-decoration: none; padding: 4px 7px; border-radius: 7px; }
.syntax-link svg { flex: none; }
.syntax-link:hover { color: var(--accent); background: var(--accent-soft); }
/* honest data-flow note: non-Kymo kinds POST the source to kroki.io */
.kroki-note { margin-left: auto; font-size: 11.5px; color: var(--dim); cursor: help; }
/* transient confirmation that a paste switched the kind */
.detect-chip { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2.5px 9px; white-space: nowrap; }

/* ---- "New diagram" template gallery: pick a diagram TYPE, the kind follows ---- */
.tpl-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(36, 33, 49, 0.35); backdrop-filter: blur(2px); }
.tpl-modal { width: min(720px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; background: var(--bg); border-radius: var(--radius); box-shadow: 0 24px 64px rgba(36, 33, 49, 0.28); overflow: hidden; }
.tpl-head { position: relative; padding: 20px 24px 14px; border-bottom: 1px solid var(--border); }
.tpl-head h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.01em; }
.tpl-sub { margin: 0; font-size: 12.5px; color: var(--dim); max-width: 520px; }
.tpl-close { position: absolute; top: 14px; right: 14px; border: none; background: transparent; color: var(--dim); font-size: 14px; padding: 6px 9px; border-radius: 8px; }
.tpl-close:hover { background: var(--bg-soft); color: var(--ink); transform: none; box-shadow: none; }
.tpl-search { display: block; width: 100%; margin-top: 12px; padding: 8px 12px; font: inherit; font-size: 13.5px; color: var(--ink); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px; outline: none; }
.tpl-search:focus { border-color: var(--accent); background: var(--bg); }
.tpl-search::placeholder { color: var(--dim); }
.tpl-empty { grid-column: 1 / -1; margin: 18px 0 26px; text-align: center; font-size: 13px; color: var(--dim); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; padding: 16px 24px 22px; overflow-y: auto; }
.tpl-card { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 8px 11px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); color: var(--ink); }
.tpl-card svg { width: 26px; height: 26px; color: var(--dim); transition: color 0.15s ease; }
.tpl-card:hover { border-color: var(--accent); background: var(--bg); box-shadow: 0 4px 14px rgba(224, 9, 95, 0.12); }
.tpl-card:hover svg { color: var(--accent); }
.tpl-name { font-size: 13px; font-weight: 600; }
.tpl-via { font-size: 10.5px; color: var(--dim); }
@media (max-width: 720px) {
  .tpl-overlay { padding: 0; }
  .tpl-modal { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); padding: 14px 14px 28px; }
}

/* ---- hover polish ----
   Solid buttons lift 1px with a soft shadow; the primary button gets an accent
   glow; flat controls (menu items, avatar, workspace switcher) stay in place
   and only fade. Declared last so it wins the cascade over the base rules. */
button, .btn, .pill, .ws-pill, .kind-select, .rmove, .acct-item, .linklike, .diagram-name.editable {
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    box-shadow 0.18s ease, transform 0.14s ease, opacity 0.14s ease;
}
.chev, .chev-icon, .exp-item svg { transition: color 0.15s ease, transform 0.18s ease; }

button:hover, .btn:hover { border-color: var(--border-strong); background: var(--bg-soft); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(36, 33, 49, 0.1), 0 1px 3px rgba(36, 33, 49, 0.06); }
.btn-primary { box-shadow: 0 1px 2px rgba(224, 9, 95, 0.18); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); box-shadow: 0 5px 16px rgba(224, 9, 95, 0.3), 0 2px 5px rgba(224, 9, 95, 0.18); }

.pill:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(36, 33, 49, 0.1); }
.pill-dark { box-shadow: 0 1px 2px rgba(224, 9, 95, 0.18); }
.pill-dark:hover { box-shadow: 0 5px 16px rgba(224, 9, 95, 0.3); }
.ws-pill:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(36, 33, 49, 0.1); }
.ws-pill.active:hover { box-shadow: 0 4px 12px rgba(36, 33, 49, 0.22); }
.kind-select:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(36, 33, 49, 0.08); }

/* flat controls: no lift, just a clean fade (+ their own accents) */
.acct-btn:hover, .ws-btn:hover, .acct-item:hover, .rdel:hover, .rmove:hover, .linklike:hover { transform: none; box-shadow: none; }
.acct-btn:hover { background: var(--border); box-shadow: 0 0 0 3px var(--accent-soft); }
.ws-btn:hover { background: var(--bg-soft); }
.ws-btn:hover .chev { color: var(--accent); transform: translateY(1px); }
.acct-item:hover { background: var(--bg-raise); }
.ws-item:hover .ws-check { transform: scale(1.12); }
.ws-check { transition: transform 0.15s ease; }
.rdel:hover { color: var(--error); background: rgba(180, 35, 24, 0.08); }
.rmove:hover { border-color: var(--border-strong); color: var(--ink); }
.linklike:hover { color: var(--accent); }

/* press: settle back down, tighter shadow, instant response */
button:active, .btn:active, .pill:active, .ws-pill:active { transform: translateY(0) scale(0.98); box-shadow: 0 1px 2px rgba(36, 33, 49, 0.08); transition-duration: 0.05s; }
.acct-item:active, .ws-btn:active, .acct-btn:active, .linklike:active { transform: scale(0.98); box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  button, .btn, .pill, .ws-pill, .kind-select, .rmove, .acct-item, .linklike, .chev, .chev-icon, .ws-check { transition: none; }
  button:hover, .btn:hover, .pill:hover, .ws-pill:hover, .kind-select:hover, button:active, .btn:active, .pill:active, .ws-pill:active { transform: none; }
}

/* CodeMirror source editor */
.code-editor { flex: 1; min-height: 0; overflow: hidden; }
.code-editor .cm-editor { height: 100%; }

/* draggable pane splitter (dbdiagram-style) */
.splitter { flex: none; width: 7px; cursor: col-resize; background: var(--bg); border-left: 1px solid var(--border); position: relative; z-index: 5; touch-action: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.splitter::after { content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 2px; height: 38px; border-radius: 2px; background: var(--border-strong); transition: background-color 0.15s ease, height 0.15s ease; }
.splitter:hover, body.splitting .splitter { background: var(--accent-soft); border-left-color: rgba(224, 9, 95, 0.35); }
.splitter:hover::after, body.splitting .splitter::after { background: var(--accent); height: 52px; }
body.splitting { user-select: none; cursor: col-resize; }
body.splitting .cm-editor, body.splitting #preview { pointer-events: none; }

/* diagram kind badge on list rows */
.rkind { flex: none; font-size: 11.5px; font-weight: 600; color: var(--dim); background: var(--bg-raise); border-radius: 999px; padding: 2px 9px; letter-spacing: 0.01em; }

/* ---- trash page ---- */
.trash-note { margin: 22px 0 6px; font-size: 13.5px; color: var(--dim); }
.trash-row { cursor: default; }
.trash-row:hover { background: var(--bg-soft); }
.rrestore { flex: none; display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 1px solid var(--border-strong); color: var(--ink); font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 7px; }
.rrestore:hover { border-color: var(--dim); background: var(--bg); transform: none; box-shadow: none; }
.trash-row .rdel { display: inline-flex; align-items: center; opacity: 1; }

/* ---- bulk select / delete on the Diagrams list ---- */
.bulk-bar { display: flex; align-items: center; gap: 14px; min-height: 30px; margin: 12px 0 0; padding: 0 10px; font-size: 13.5px; color: var(--dim); }
.bulk-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.bulk-all input, .rcheck { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex: none; }
.bulk-bar.active { color: var(--ink); }
.bulk-actions { display: inline-flex; align-items: center; gap: 10px; }
.bulk-del { border-color: var(--border-strong); color: var(--error); font-size: 13px; padding: 5px 12px; }
.bulk-del:hover { border-color: var(--error); background: rgba(180, 35, 24, 0.06); color: var(--error); }
.bulk-move { border: 1px solid var(--border-strong); border-radius: var(--radius-btn); padding: 5px 10px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--bg); cursor: pointer; }
/* the row checkbox fades in like the other hover affordances, but stays once anything is selected */
.rcheck { opacity: 0; transition: opacity 0.14s ease; }
.rrow:hover .rcheck, .rcheck:focus-visible, .rrow.selected .rcheck { opacity: 1; }
.rrow.selected { background: var(--accent-soft); }

/* ---- folder tree (VSCode-explorer-style Diagrams list) ---- */
.rows.tree { border-radius: 10px; }
.rows.tree.dragover-root { box-shadow: inset 0 0 0 2px rgba(224, 9, 95, 0.25); }
.frow { display: flex; align-items: center; gap: 9px; padding: 12px 10px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; color: var(--ink); }
.frow:hover { background: var(--bg-soft); }
.frow.dragover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(224, 9, 95, 0.4); }
.fchev { flex: none; display: inline-flex; color: var(--dim); }
.ficon { flex: none; color: var(--dim); }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 650; }
.fcount { flex: none; min-width: 22px; text-align: right; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.factions { flex: none; display: inline-flex; gap: 1px; opacity: 0; transition: opacity 0.14s ease; }
.frow:hover .factions, .factions:focus-within { opacity: 1; }
.factions button { border: 1px solid transparent; background: transparent; color: var(--dim); padding: 5px; border-radius: 7px; }
.factions button:hover { background: var(--bg-raise); border-color: transparent; color: var(--accent); transform: none; box-shadow: none; }
/* draggable rows: a subtle grab affordance */
.frow[draggable="true"], .rrow[draggable="true"] { -webkit-user-drag: element; }
/* touch devices can't hover — keep folder actions visible */
@media (hover: none) { .factions { opacity: 1; } }

/* ---- responsive header ----
   ≤1000px (tablet / narrow window): the single row can't fit the full logged-in
   header (its min-width is ~910px — Share used to get clipped on iPad portrait),
   so the action cluster drops to a second row. All buttons stay visible.
   ≤720px (phones): the second row would wrap into a ragged third, so the
   low-traffic actions collapse into the ⋯ menu instead — see .mob-more. */
@media (max-width: 1000px) {
  header { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  /* designed rows: 1 = identity (brand · title · avatar), 2 = the action cluster */
  .nav-group { order: 10; flex-basis: 100%; justify-content: flex-end; }
  /* a wrapping flex line packs items at their CONTENT width before any shrink,
     so a long title must be capped up front or it evicts row-1 neighbours */
  .diagram-name { max-width: clamp(120px, 40vw, 420px); }
}

/* ---- mobile: share links are mostly opened from chat on phones ---- */
@media (max-width: 720px) {
  .mob-hide { display: none !important; } /* collapsed into the ⋯ menu */
  .mob-more { display: inline-flex; }
  /* status text stays readable when it carries a warning ("Offline") or the
     unsaved-draft state; only the steady-state "Saved" shrinks to its dot.
     Tooltips don't exist on touch. */
  .save-ind:not(.off):not(.unsaved) { font-size: 0; gap: 0; padding: 5px; }
  .save-ind.off, .save-ind.unsaved { font-size: 11px; padding: 2.5px 9px; }
  /* comfortable touch targets (44px) for the two-control action row */
  .nav-group button { padding: 12px 16px; }
  /* row 1 must hold brand · (workspace) · title · status · auth control */
  .diagram-name { max-width: clamp(72px, 24vw, 200px); }
  main { flex-direction: column; }
  /* the source pane carries an inline flex-basis from the drag-splitter — override it */
  .pane { flex: 1 1 50% !important; min-width: 0; min-height: 0; }
  .pane + .pane { border-left: 0; }
  /* diagram first: recipients want to see it, not the source */
  .pane:last-child { order: -1; border-bottom: 1px solid var(--border); }
  .splitter { display: none; }
}

/* touch devices: hover-revealed affordances must be visible up front */
@media (hover: none) {
  .diagram-name .pencil { opacity: 1; }
}
