:root {
  color-scheme: light;
  --ink: #1d2320;
  --ink-2: #5a635f;
  --ink-3: #868d89;
  --line: #e2e3de;
  --line-2: #d2d4ce;
  --bg: #f5f4ef;
  --panel: #ffffff;
  --accent: #17574a;
  --accent-hover: #114539;
  --accent-soft: #e4f0ec;
  --select: #2a6af0;
  --danger: #c0271b;
  --danger-soft: #fdeceb;
  --warn-soft: #fff6df;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29, 35, 32, .08), 0 6px 20px rgba(29, 35, 32, .1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.board-body { overflow: hidden; overscroll-behavior: none; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; margin: 28px 0 12px; }
h3 { font-size: 14px; font-weight: 650; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }

input:where(:not([type="checkbox"], [type="radio"], [type="file"])), select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--select); outline-offset: -1px; border-color: transparent; }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: #f4f4f0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a11f15; }
.btn-danger-text { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(29, 35, 32, .06); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-small.active { background: var(--accent-soft); border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-icon { display: inline-flex; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(29, 35, 32, .07); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }

/* ---- Login, invite and setup pages ---- */

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px 16px; }
main.auth-page { width: 100%; min-height: 100vh; }
#app:has(> .auth-card) { width: 100%; display: flex; justify-content: center; }
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.auth-card-wide { max-width: 520px; }
.auth-card h1 { font-size: 21px; margin-bottom: 10px; }
.auth-card h2 { margin: 22px 0 2px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-lg { font-size: 19px; margin-bottom: 20px; }

.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label, .form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; }
.form-stack p { margin: 0; }
.form-row { display: flex; gap: 10px; }
.form-row .grow { flex: 1; }
.form-row .narrow { width: 90px; }

.alert { padding: 10px 12px; background: var(--danger-soft); color: #8f1d13; border-radius: 8px; font-size: 14px; }
.check-list { list-style: none; margin: 0 0 18px; padding: 0; font-size: 14px; }
.check-list li { padding: 3px 0 3px 22px; position: relative; }
.check-list li::before { position: absolute; left: 2px; font-weight: 700; }
.check-list li.ok::before { content: "\2713"; color: #1d7a4f; }
.check-list li.bad::before { content: "\2715"; color: var(--danger); }
.check-list li.bad { color: #8f1d13; }

/* ---- Dashboard and admin ---- */

.app-top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  background: rgba(245, 244, 239, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.app-top-right { display: flex; align-items: center; gap: 10px; }
.app-main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.app-narrow { max-width: 900px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; }
.tab { height: 34px; padding: 0 12px; background: transparent; border: 0; border-radius: 8px; color: var(--ink-2); font-weight: 550; cursor: pointer; }
.tab:hover { background: rgba(29, 35, 32, .06); }
.tab.active { background: var(--ink); color: #fff; }

.search { position: relative; display: block; width: 240px; max-width: 100%; }
.search input { padding-left: 34px; height: 36px; }
.search-icon { position: absolute; left: 9px; top: 8px; color: var(--ink-3); display: flex; }
.search-icon svg { width: 18px; height: 18px; }

.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.board-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.board-card:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.board-thumb { display: block; aspect-ratio: 360 / 220; background: #fafaf7; border-bottom: 1px solid var(--line); }
.board-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-empty {
  display: block;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#d4d6d0 1.2px, transparent 1.2px);
  background-size: 18px 18px;
}
.board-card-info { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; padding: 10px 8px 12px 14px; }
.board-card-text { min-width: 0; }
.board-card-title { display: block; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-card-title:hover { text-decoration: underline; }
.board-card-meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vis-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px 0 6px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}
.vis-tag.public { color: #8a5a00; background: var(--warn-soft); border-color: #f0dfb0; }
.vis-tag-icon { display: flex; }
.vis-tag-icon svg { width: 14px; height: 14px; }

.empty { grid-column: 1 / -1; padding: 60px 20px; text-align: center; background: var(--panel); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h2 { margin: 0 0 6px; }
.empty-line { grid-column: 1 / -1; }

.panel { padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { margin: 0 0 4px; }
.invite-form { display: grid; grid-template-columns: 1.4fr 1fr 100px auto; gap: 8px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 10px 12px; font-size: 12px; color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.row-disabled td { color: var(--ink-3); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn { margin-left: 6px; }
.you-tag { margin-left: 6px; padding: 1px 6px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; font-size: 12px; font-weight: 600; }

/* ---- Dialogs, menus and toasts ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(29, 35, 32, .38);
}
.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(29, 35, 32, .28);
}
.modal-wide { max-width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 20px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; }
.modal-body h3:first-child { margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }

.popover {
  position: fixed;
  z-index: 40;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.menu { display: flex; flex-direction: column; min-width: 190px; }
.menu-scroll { max-height: 320px; overflow-y: auto; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 9px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: rgba(29, 35, 32, .06); }
.menu-item:disabled { opacity: .4; cursor: default; background: transparent; }
.menu-danger { color: var(--danger); }
.menu-icon { display: flex; }
.menu-icon svg { width: 17px; height: 17px; }
.menu-label { flex: 1; }
.menu-hint { font-size: 12px; color: var(--ink-3); margin-left: 16px; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }

.toast-host { position: fixed; left: 50%; bottom: 74px; z-index: 60; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 9px 14px; background: var(--ink); color: #fff; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .25s; }
.toast-error { background: #a11f15; }
.toast-out { opacity: 0; }

.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; min-width: 0; color: var(--ink-2); font-size: 13px; }

/* ---- Share dialog ---- */

.vis-options { display: flex; flex-direction: column; gap: 6px; }
.vis-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
}
.vis-option:hover:not(:disabled) { background: #f8f8f5; }
.vis-option:disabled { cursor: default; opacity: .7; }
.vis-option.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); opacity: 1; }
.vis-icon { display: flex; margin-top: 1px; }
.vis-text { display: flex; flex-direction: column; }
.vis-text strong { font-weight: 600; }
.vis-text small { color: var(--ink-2); font-size: 13px; }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.person { display: flex; flex-direction: column; min-width: 0; }
.person strong { font-weight: 600; }
.person small { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.person-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.person-actions select { width: 104px; height: 30px; font-size: 13px; }
.role-tag { font-size: 13px; color: var(--ink-2); flex-shrink: 0; }
.add-person { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; margin-top: 12px; }

.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 7px 22px; margin: 0; font-size: 14px; }
.shortcuts dt { color: var(--ink-2); }
.shortcuts dd { margin: 0; font-weight: 550; text-align: right; }

/* ---- The board ---- */

.board-page { position: fixed; inset: 0; overflow: hidden; background: #fafaf7; user-select: none; -webkit-user-select: none; }
.stage { position: absolute; inset: 0; overflow: hidden; }
.board-canvas { display: block; position: absolute; left: 0; top: 0; touch-action: none; }
.text-editor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  margin: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  transform-origin: 0 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.bar {
  position: absolute;
  top: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 8px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.bar-left { left: 10px; max-width: calc(100vw - 20px); }
.bar-right { right: 10px; }
.bar .btn { height: 34px; padding: 0 10px; }

.brand-link { display: flex; padding: 4px; border-radius: 7px; }
.brand-link:hover { background: rgba(29, 35, 32, .06); }
.board-title {
  max-width: 280px;
  height: 32px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.board-title:hover:not(:disabled) { background: rgba(29, 35, 32, .06); }
.board-title:disabled { color: var(--ink); cursor: default; }
.vis-pill {
  height: 24px;
  padding: 0 8px;
  background: #f0f0ec;
  border: 0;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.vis-pill.public { background: var(--warn-soft); color: #8a5a00; }
.vis-pill:disabled { cursor: default; }
.status { padding: 0 6px; font-size: 12px; color: var(--ink-3); white-space: nowrap; min-width: 56px; }
.status-offline, .status-error { color: var(--danger); font-weight: 600; }

.avatars { display: flex; align-items: center; margin-right: 4px; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: -6px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--ink-2); cursor: default; }
.avatar-menu { width: 34px; height: 34px; margin: 0; font-size: 12px; }

.toolbar {
  position: absolute;
  left: 10px;
  top: 50%;
  z-index: 10;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.tool-btn { width: 40px; height: 40px; }
.tool-sep { width: 24px; height: 1px; margin: 4px 0; background: var(--line); }

.mini-bar {
  position: absolute;
  bottom: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.undo-bar { left: 10px; }
.zoom-bar { right: 10px; }
.zoom-label { width: 52px; height: 36px; padding: 0; background: transparent; border: 0; border-radius: 8px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.zoom-label:hover { background: rgba(29, 35, 32, .07); }

.minimap {
  position: absolute;
  right: 10px;
  bottom: 62px;
  z-index: 9;
  width: 200px;
  height: 130px;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: none;
}

.view-pill {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 10;
  transform: translateX(-50%);
  padding: 7px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.board-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fafaf7;
  color: var(--ink-2);
}
.spinner { width: 28px; height: 28px; border: 3px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.denied { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: #fafaf7; }
.denied-card { max-width: 420px; padding: 26px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); text-align: center; }
.denied-card h2 { margin: 0 0 8px; }

/* ---- Floating style bar ---- */

.ctx-bar {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
  max-width: calc(100vw - 16px);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.ctx-group { display: flex; align-items: center; gap: 1px; }
.ctx-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--line); flex-shrink: 0; }
.ctx-icon { width: 32px; height: 32px; flex-shrink: 0; }
.ctx-icon svg { width: 18px; height: 18px; }
.ctx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 32px;
  height: 32px;
  padding: 0 5px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.ctx-btn:hover { background: rgba(29, 35, 32, .07); }
.ctx-text { font-size: 13px; font-weight: 550; white-space: nowrap; }
.caret { display: flex; color: var(--ink-3); }
.caret svg { width: 13px; height: 13px; }
.color-dot { display: block; width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(29, 35, 32, .2); }
.color-ring { background: transparent; border: 4px solid; }
.color-none { background: linear-gradient(135deg, #fff 44%, var(--danger) 44%, var(--danger) 56%, #fff 56%); border: 1px solid var(--line-2); }
.color-letter { padding: 0 2px; font-weight: 700; font-size: 15px; line-height: 19px; border-bottom: 3px solid; }
.flip-x svg { transform: scaleX(-1); }

.swatch-grid { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.swatch { width: 26px; height: 26px; padding: 0; border: 1px solid rgba(29, 35, 32, .18); border-radius: 50%; cursor: pointer; }
.swatch:hover { transform: scale(1.1); }
.swatch.active { outline: 2px solid var(--select); outline-offset: 1px; }
.swatch-none { background: linear-gradient(135deg, #fff 44%, var(--danger) 44%, var(--danger) 56%, #fff 56%); }

.shape-grid { display: grid; grid-template-columns: repeat(4, 38px); gap: 3px; }
.shape-btn { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.shape-btn:hover { background: rgba(29, 35, 32, .07); }
.shape-btn.active { background: var(--accent-soft); }

.pen-panel, .stroke-panel { display: flex; flex-direction: column; gap: 8px; min-width: 172px; }
.pen-panel p { margin: 0; max-width: 190px; }
.pen-row { display: flex; align-items: center; gap: 5px; }
.width-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 30px; padding: 0 6px; background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.width-btn:hover { background: rgba(29, 35, 32, .07); }
.width-btn.active { background: var(--accent-soft); }
.width-btn span { display: block; width: 100%; background: var(--ink); border-radius: 6px; }

/* ---- Small screens ---- */

@media (max-width: 720px) {
  .hide-sm { display: none; }
  .board-title { max-width: 130px; }
  .status, .vis-pill { display: none; }
  .bar-left { max-width: calc(100vw - 150px); }
  .bar { height: 44px; padding: 0 5px; gap: 3px; }
  .toolbar {
    left: 50%;
    top: auto;
    bottom: 58px;
    transform: translateX(-50%);
    flex-direction: row;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
  }
  .tool-sep { width: 1px; height: 24px; margin: 0 4px; flex-shrink: 0; }
  .tool-btn { flex-shrink: 0; }
  .zoom-bar .zoom-label { width: 44px; }
  .ctx-bar { overflow-x: auto; }
  .invite-form { grid-template-columns: 1fr; }
  .add-person { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
  .search { width: 100%; }
}

/* Video, GIF and YouTube controls, laid over the canvas. */
.media-bar {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 6px;
  background: rgba(20, 24, 22, .82);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  user-select: none;
}
.media-bar .icon-btn { width: 32px; height: 32px; color: #fff; flex-shrink: 0; }
.media-bar .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.media-bar .media-seek { flex: 1; min-width: 60px; accent-color: #fff; cursor: pointer; }
.media-bar .media-time { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .9; padding: 0 4px; }
.media-bar .media-label { font-size: 13px; padding: 0 6px 0 2px; white-space: nowrap; }
.media-embed { position: absolute; left: 0; top: 0; z-index: 3; background: #000; transform-origin: 50% 50%; }
.media-embed iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---- Shared documents ---- */

.doc-bar { padding: 0 4px; }
.doc-bar .doc-open-btn { height: 32px; color: #fff; background: transparent; border-color: transparent; gap: 6px; }
.doc-bar .doc-open-btn:hover { background: rgba(255, 255, 255, .14); }
.doc-bar .btn-icon svg { width: 18px; height: 18px; }

.doc-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(29, 35, 32, .32);
  user-select: text;
  -webkit-user-select: text;
}
.doc-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  height: 100%;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(29, 35, 32, .28);
  overflow: hidden;
}
.doc-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 8px 18px; border-bottom: 1px solid var(--line); }
.doc-icon { display: inline-flex; color: var(--select); flex-shrink: 0; }
.doc-icon svg { width: 22px; height: 22px; }
.doc-head .doc-title {
  flex: 1;
  min-width: 60px;
  height: 36px;
  padding: 0 8px;
  font-size: 18px;
  font-weight: 650;
  border-color: transparent;
  background: transparent;
}
.doc-head .doc-title:hover:not(:read-only) { border-color: var(--line-2); }
.doc-head .doc-title:read-only { cursor: default; outline: none; }
.doc-status { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.doc-avatars .avatar { cursor: default; }
.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfbf9;
}
.doc-toolbar .icon-btn { width: 32px; height: 32px; }
.doc-toolbar .icon-btn svg { width: 18px; height: 18px; }
.doc-toolbar .doc-kind { width: auto; height: 32px; padding: 0 6px; font-size: 13px; }
.doc-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line-2); }
.doc-viewnote { padding: 6px 18px; font-size: 13px; color: var(--ink-2); background: var(--warn-soft); border-bottom: 1px solid var(--line); }
.doc-scroll { flex: 1; overflow-y: auto; background: #f3f3ef; padding: 24px 16px 60px; }
.doc-page {
  position: relative;
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  padding: 48px 64px 80px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.doc-loading { display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.doc-body {
  min-height: 300px;
  outline: none;
  font: 15px/1.6 var(--font);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: var(--ink);
}
.doc-body .doc-b { margin: 0 0 8px; min-height: 1.6em; }
.doc-body h1.doc-b { font-size: 28px; line-height: 1.25; margin: 18px 0 10px; font-weight: 700; }
.doc-body h2.doc-b { font-size: 22px; line-height: 1.3; margin: 16px 0 8px; font-weight: 700; }
.doc-body h3.doc-b { font-size: 18px; line-height: 1.35; margin: 14px 0 6px; font-weight: 650; }
.doc-body blockquote.doc-b { margin-left: 0; margin-right: 0; padding-left: 14px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.doc-body .doc-b[data-k="ul"], .doc-body .doc-b[data-k="ol"] { position: relative; margin: 0 0 3px; padding-left: 28px; }
.doc-body .doc-b[data-l="1"] { margin-left: 28px; }
.doc-body .doc-b[data-l="2"] { margin-left: 56px; }
.doc-body .doc-b[data-l="3"] { margin-left: 84px; }
.doc-body .doc-b[data-l="4"] { margin-left: 112px; }
.doc-body .doc-b[data-k="ul"]::before, .doc-body .doc-b[data-k="ol"]::before {
  position: absolute;
  left: 0;
  width: 22px;
  text-align: right;
  color: var(--ink-2);
  user-select: none;
  -webkit-user-select: none;
}
.doc-body .doc-b[data-k="ul"]::before { content: "\2022"; }
.doc-body .doc-b[data-k="ul"][data-l="1"]::before, .doc-body .doc-b[data-k="ul"][data-l="4"]::before { content: "\25E6"; }
.doc-body .doc-b[data-k="ul"][data-l="2"]::before { content: "\25AA"; }
.doc-body .doc-b[data-k="ol"]::before { content: attr(data-n); font-variant-numeric: tabular-nums; }
.doc-body a { color: var(--select); text-decoration: underline; }
.doc-body[contenteditable="true"] a { cursor: text; }
/* Block positions (offsetTop) already count the page's top padding. */
.doc-carets { position: absolute; left: 64px; top: 0; width: 0; height: 0; }
.doc-caret { position: absolute; width: 3px; border-radius: 2px; opacity: .85; }
.doc-caret-name {
  position: absolute;
  right: 6px;
  top: 0;
  padding: 1px 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.doc-caret:hover .doc-caret-name { opacity: 1; }
.doc-link-pop { width: 300px; }
.doc-link-form { display: flex; flex-direction: column; gap: 8px; }
.doc-link-actions { display: flex; justify-content: flex-end; gap: 6px; }
@media (max-width: 720px) {
  .doc-overlay { padding: 0; }
  .doc-panel { border-radius: 0; }
  .doc-scroll { padding: 0; }
  .doc-page { padding: 24px 20px 60px; border: 0; border-radius: 0; }
  .doc-carets { left: 20px; }
}

/* ---- PDFs ---- */

.pdf-bar .media-time { min-width: 52px; text-align: center; }
.pdf-bar .icon-btn:disabled { opacity: .35; }
.pdf-viewer {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: #3b3f3d;
  outline: none;
}
.pdf-viewer-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.pdf-viewer-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-viewer-page, .pdf-viewer-zoom { font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pdf-viewer-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pdf-viewer-tools .btn { margin: 0 6px; gap: 4px; }
.pdf-viewer-scroll { flex: 1; overflow: auto; padding: 24px; }
.pdf-viewer-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; min-width: min-content; }
.pdf-viewer-slot { position: relative; flex-shrink: 0; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.pdf-viewer-slot canvas { display: block; width: 100%; height: 100%; }
.pdf-viewer-num { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--ink-3); font-size: 13px; }
.pdf-viewer-slot canvas + .pdf-viewer-num { display: none; }
.pdf-viewer-error { color: #fff; }
.pdf-import-dialog { max-width: 760px; }
.pdf-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pdf-choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; }
.pdf-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pdf-choice input { margin-top: 3px; }
.pdf-choice-text { display: flex; flex-direction: column; gap: 2px; }
.pdf-pick-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.pdf-pick-head .muted { margin-right: auto; }
.pdf-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px;
}
.pdf-pick-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; }
.pdf-pick-cell.chosen { border-color: var(--accent); background: var(--accent-soft); }
.pdf-pick-thumb { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 3 / 4; background: #f3f3ef; color: var(--ink-3); }
.pdf-pick-thumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.pdf-pick-num { font-size: 12px; display: flex; align-items: center; gap: 4px; }
@media (max-width: 560px) { .pdf-choices { grid-template-columns: 1fr; } }

/* Shared text boxes, written in right on the board. Sizes match drawTextbox() in docs.js. */
.tb-edit { position: absolute; left: 0; top: 0; z-index: 4; transform-origin: 0 0; }
.tb-page { position: relative; padding: 14px; background: #fff; border: 1px solid var(--select); border-radius: 8px; box-sizing: border-box; min-height: inherit; box-shadow: 0 0 0 1px var(--select); }
.tb-page .doc-loading { font-size: 14px; }
.tb-page .doc-body { min-height: 24px; font: 16px/1.5 var(--font); }
.tb-page .doc-body .doc-b { margin: 0 0 6px; min-height: 1.5em; }
.tb-page .doc-body h1.doc-b { font-size: 26px; line-height: 1.25; margin: 0 0 10px; }
.tb-page .doc-body h2.doc-b { font-size: 21px; line-height: 1.3; margin: 0 0 8px; }
.tb-page .doc-body h3.doc-b { font-size: 18px; line-height: 1.35; margin: 0 0 6px; }
.tb-page .doc-body blockquote.doc-b { padding-left: 12px; }
.tb-page .doc-body .doc-b[data-k="ul"], .tb-page .doc-body .doc-b[data-k="ol"] { margin: 0 0 2px; padding-left: 26px; }
.tb-page .doc-body .doc-b[data-l="1"] { margin-left: 26px; }
.tb-page .doc-body .doc-b[data-l="2"] { margin-left: 52px; }
.tb-page .doc-body .doc-b[data-l="3"] { margin-left: 78px; }
.tb-page .doc-body .doc-b[data-l="4"] { margin-left: 104px; }
.tb-page .doc-body .doc-b[data-k="ul"]::before, .tb-page .doc-body .doc-b[data-k="ol"]::before { width: 20px; }
.tb-bar { position: absolute; left: 0; top: 0; z-index: 12; display: flex; align-items: center; gap: 6px; padding: 3px 4px; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); }
.tb-bar .doc-toolbar { border: 0; padding: 0; margin: 0; background: transparent; position: static; }
.tb-bar .avatars { margin-right: 2px; }
