/* ══════════════════════════════════════════════════════════
   ОСКОЛОК  —  общие стили
   Тёмная фэнтези тема, совпадает с raven-wings-board
   ══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Cinzel:wght@700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0805;
  --bg2:          #13100a;
  --bg3:          #1a1408;
  --border:       #3a2e18;
  --border-gold:  rgba(200,168,75,0.45);
  --gold:         #c8a84b;
  --gold-light:   #e8d898;
  --text:         #c8b888;
  --text-dim:     #8a7850;
  --text-dark:    #1e1608;
  --radius:       10px;
  --shadow:       0 8px 32px rgba(0,0,0,.5);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); text-decoration: underline; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: rgba(200,168,75,.25); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200,168,75,.45); }

/* ── Layout ────────────────────────────────────────────── */
.app-wrap { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display:         flex;
  align-items:     center;
  gap:             14px;
  padding:         0 20px;
  height:          52px;
  background:      linear-gradient(180deg, #1e1810 0%, #13100a 100%);
  border-bottom:   1.5px solid var(--border);
  box-shadow:      0 2px 12px rgba(0,0,0,.4);
  flex-shrink:     0;
  position:        sticky;
  top:             0;
  z-index:         100;
}
.topbar__logo {
  font-family:    'Cinzel', serif;
  font-size:      17px;
  color:          var(--gold);
  letter-spacing: .08em;
  white-space:    nowrap;
}
.topbar__logo span { color: var(--text-dim); font-size: 12px; font-family: 'Montserrat', sans-serif; margin-left: 8px; font-weight: 400; }
.topbar__nav { display: flex; gap: 4px; margin-left: 16px; }
.topbar__nav a {
  padding:       5px 13px;
  border-radius: 6px;
  font-size:     12.5px;
  font-weight:   600;
  color:         var(--text-dim);
  transition:    background .14s, color .14s;
}
.topbar__nav a:hover, .topbar__nav a.active {
  background: rgba(200,168,75,.12);
  color:      var(--gold);
  text-decoration: none;
}
.topbar__spacer { flex: 1; }
.topbar__user {
  display:     flex;
  align-items: center;
  gap:         10px;
  font-size:   12px;
  color:       var(--text-dim);
}
.topbar__user strong { color: var(--gold-light); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  padding:       7px 16px;
  border-radius: 7px;
  font-size:     12.5px;
  font-weight:   600;
  font-family:   'Montserrat', sans-serif;
  cursor:        pointer;
  border:        1.5px solid transparent;
  transition:    background .14s, border-color .14s, color .14s, opacity .14s;
  white-space:   nowrap;
  user-select:   none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold {
  background:   rgba(200,168,75,.12);
  border-color: rgba(200,168,75,.4);
  color:        var(--gold);
}
.btn-gold:hover:not(:disabled) {
  background:   rgba(200,168,75,.22);
  border-color: var(--gold);
  color:        var(--gold-light);
}
.btn-primary {
  background:   linear-gradient(135deg, #7a6030, #3a2e18);
  border-color: var(--gold);
  color:        var(--gold);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #9a8040, #5a4a28);
  color:      var(--gold-light);
}
.btn-danger {
  background:   rgba(180,50,50,.12);
  border-color: rgba(180,50,50,.4);
  color:        #e08080;
}
.btn-danger:hover:not(:disabled) { background: rgba(180,50,50,.22); border-color: #e08080; }
.btn-sm { padding: 4px 10px; font-size: 11.5px; border-radius: 5px; }
.btn-icon { padding: 5px 8px; }

/* ── Forms ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--text-dim); font-weight: 600; letter-spacing: .03em; }
.field input,
.field textarea,
.field select {
  padding:       9px 12px;
  background:    #0d0b07;
  border:        1.5px solid var(--border);
  border-radius: 6px;
  color:         var(--gold-light);
  font-size:     13px;
  font-family:   'Montserrat', sans-serif;
  outline:       none;
  transition:    border-color .15s, box-shadow .15s;
  resize:        vertical;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--gold);
  box-shadow:   0 0 0 3px rgba(200,168,75,.12);
}
.field input::placeholder,
.field textarea::placeholder { color: #6a5a40; }
.field select option { background: #1a1408; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

/* ── Panel ──────────────────────────────────────────────── */
.panel {
  background:    var(--bg3);
  border:        1.5px solid var(--border);
  border-radius: var(--radius);
  overflow:      hidden;
}
.panel__header {
  display:        flex;
  align-items:    center;
  gap:            10px;
  padding:        11px 16px;
  background:     linear-gradient(135deg, rgba(200,168,75,.08), transparent);
  border-bottom:  1.5px solid var(--border);
  font-size:      13px;
  font-weight:    700;
  color:          var(--gold);
  letter-spacing: .04em;
}
.panel__body { padding: 16px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s;
}
.modal-backdrop.visible { opacity: 1; }
.modal {
  background:    var(--bg3);
  border:        1.5px solid var(--border-gold);
  border-radius: 12px;
  box-shadow:    var(--shadow);
  width:         100%;
  max-width:     520px;
  max-height:    90vh;
  display:       flex;
  flex-direction:column;
  transform:     scale(.94) translateY(-8px);
  transition:    transform .18s;
}
.modal-backdrop.visible .modal { transform: scale(1) translateY(0); }
.modal__header {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       14px 18px 12px;
  border-bottom: 1.5px solid var(--border);
  font-size:     14px;
  font-weight:   700;
  color:         var(--gold);
  flex-shrink:   0;
}
.modal__header .modal__close {
  margin-left:   auto;
  background:    transparent;
  border:        none;
  color:         var(--text-dim);
  font-size:     16px;
  cursor:        pointer;
  padding:       0 4px;
  line-height:   1;
  transition:    color .12s;
}
.modal__header .modal__close:hover { color: var(--gold-light); }
.modal__body {
  flex: 1; overflow-y: auto;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal__footer {
  display:     flex;
  gap:         10px;
  padding:     12px 20px 16px;
  justify-content: flex-end;
  border-top:  1.5px solid var(--border);
  flex-shrink: 0;
}

/* ── Notification ───────────────────────────────────────── */
#notifications {
  position: fixed; top: 60px; right: 16px;
  display:  flex; flex-direction: column; gap: 8px;
  z-index:  9999; pointer-events: none;
}
.notif {
  padding:       10px 16px;
  border-radius: 8px;
  font-size:     13px;
  font-weight:   600;
  box-shadow:    0 4px 16px rgba(0,0,0,.4);
  pointer-events:auto;
  animation:     notif-in .2s ease;
}
.notif-ok    { background: #0f2a16; border: 1.5px solid #2a7a40; color: #80e898; }
.notif-err   { background: #2a0e0e; border: 1.5px solid #7a2020; color: #e88080; }
.notif-info  { background: #1a1408; border: 1.5px solid var(--border-gold); color: var(--gold-light); }
@keyframes notif-in { from { opacity:0; transform: translateX(24px); } to { opacity:1; transform:none; } }

/* ── Board card grid ────────────────────────────────────── */
.boards-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap:                   14px;
  padding:               20px;
}
.board-tile {
  background:    var(--bg3);
  border:        1.5px solid var(--border);
  border-radius: 10px;
  padding:       16px;
  cursor:        pointer;
  transition:    border-color .15s, box-shadow .15s;
  display:       flex;
  flex-direction:column;
  gap:           6px;
}
.board-tile:hover { border-color: var(--border-gold); box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.board-tile__name { font-size: 13.5px; font-weight: 700; color: var(--gold-light); }
.board-tile__meta { font-size: 11px; color: var(--text-dim); }
.board-tile__new {
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  align-items: center; justify-content: center;
  flex-direction: row;
  gap: 8px;
}
.board-tile__new:hover { border-color: var(--gold); color: var(--gold); }

/* ── Cards view (inside a board) ───────────────────────── */
.cards-toolbar {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     12px 20px;
  border-bottom: 1.5px solid var(--border);
  flex-wrap:   wrap;
}
.cards-toolbar__title {
  font-size:   15px;
  font-weight: 700;
  color:       var(--gold);
  flex:        1;
}
.cards-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap:                   12px;
  padding:               18px 20px;
  align-items:           start;
}

.card {
  background:    var(--bg3);
  border:        1.5px solid var(--border);
  border-radius: 10px;
  overflow:      hidden;
  display:       flex;
  flex-direction:column;
  cursor:        pointer;
  transition:    border-color .15s, box-shadow .15s, transform .1s;
  position:      relative;
}
.card:hover { border-color: var(--border-gold); box-shadow: 0 4px 20px rgba(0,0,0,.4); transform: translateY(-1px); }
.card--gm-only { opacity: .68; }

/* Type stripe */
.card::before {
  content:     '';
  display:     block;
  height:      3px;
  background:  var(--card-color, #7a6030);
  flex-shrink: 0;
}
.card__image { width: 100%; aspect-ratio: 4/3; object-fit: cover; object-position: top; display: block; }
.card__header {
  display:      flex;
  align-items:  center;
  gap:          6px;
  padding:      8px 10px 4px;
  font-size:    11.5px;
  font-weight:  700;
  color:        var(--gold-light);
  line-height:  1.3;
}
.card__icon   { font-size: 13px; flex-shrink: 0; }
.card__title  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__gm-badge {
  font-size:   9px; font-weight: 700; padding: 1px 5px;
  border-radius: 4px; background: rgba(180,40,40,.3);
  border: 1px solid rgba(180,40,40,.5); color: #e08080;
  flex-shrink: 0;
}
.card__status {
  display:     flex;
  align-items: center;
  gap:         5px;
  padding:     0 10px 4px;
  font-size:   10.5px;
  color:       var(--text-dim);
}
.card__status-dot {
  width:         7px; height: 7px; border-radius: 50%;
  background:    var(--status-color, #808080);
  flex-shrink:   0;
}
.card__summary {
  padding:     0 10px 8px;
  font-size:   11px;
  color:       var(--text-dim);
  line-height: 1.5;
  overflow:    hidden;
  display:     -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.card__tags {
  display:     flex;
  flex-wrap:   wrap;
  gap:         4px;
  padding:     0 10px 8px;
}
.card__tag {
  font-size: 10px; padding: 1px 7px; border-radius: 99px;
  background: rgba(0,0,0,.15); border: 1px solid rgba(255,255,255,.08);
  color: #8a7850;
}
.card__audio {
  display:     flex;
  align-items: center;
  gap:         7px;
  padding:     4px 10px 7px;
  font-size:   11px;
  color:       var(--text-dim);
}
.card__audio-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(200,168,75,.35);
  background: rgba(200,168,75,.08);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  color: var(--gold);
  transition: background .12s, border-color .12s;
}
.card__audio-btn:hover { background: rgba(200,168,75,.2); border-color: var(--gold); }

/* ── Card editor modal ──────────────────────────────────── */
.card-editor .field-row { align-items: flex-start; }
.badge-row { display:flex; flex-wrap:wrap; gap:6px; }
.badge-opt {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; border: 1.5px solid var(--border);
  font-size: 11.5px; cursor: pointer; transition: border-color .12s, background .12s;
  user-select: none;
}
.badge-opt.selected { border-color: var(--gold); background: rgba(200,168,75,.12); color: var(--gold); }
.badge-opt .dot { width:8px;height:8px;border-radius:50%;flex-shrink:0; }

.img-preview {
  width: 100%; max-height: 160px; object-fit: cover; object-position: top;
  border-radius: 6px; border: 1px solid var(--border); display: block;
}

/* ── Connection lines SVG overlay ──────────────────────── */
.connections-view {
  position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 1;
}

/* ── Files page ────────────────────────────────────────── */
.files-wrap { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.files-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(200,168,75,.06);
  color: var(--gold);
}
.drop-zone svg { display: block; margin: 0 auto 10px; opacity: .4; }
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.file-card {
  background: var(--bg3); border: 1.5px solid var(--border); border-radius: 8px;
  overflow: hidden; position: relative;
  display: flex; flex-direction: column;
  transition: border-color .15s;
}
.file-card:hover { border-color: var(--border-gold); }
.file-card__thumb {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  display: block; background: #0d0b07;
}
.file-card__audio-thumb {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: #0d0b07; font-size: 36px; color: var(--text-dim);
}
.file-card__info { padding: 6px 8px; font-size: 10.5px; color: var(--text-dim); }
.file-card__name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.file-card__actions {
  position: absolute; top: 4px; right: 4px;
  display: flex; gap: 4px; opacity: 0; transition: opacity .14s;
}
.file-card:hover .file-card__actions { opacity: 1; }
.file-card__btn {
  width: 24px; height: 24px; border-radius: 5px;
  background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.15);
  color: #ccc; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.file-card__btn:hover { background: rgba(200,168,75,.25); color: var(--gold); }
.file-card__btn.del:hover { background: rgba(180,50,50,.3); color: #e08080; }

/* ── Sync indicator ─────────────────────────────────────── */
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 5px;
}
.sync-dot.ok      { background: #40c060; box-shadow: 0 0 6px #40c060; }
.sync-dot.wait    { background: var(--gold); }
.sync-dot.offline { background: #808080; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar { padding: 0 12px; }
  .topbar__logo span { display: none; }
  .topbar__nav a { padding: 5px 8px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 8px; padding: 12px; }
  .boards-grid { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
}

/* ── Canvas context menu ─────────────────────────────── */
.canvas-ctx-menu {
  position:      fixed;
  background:    var(--bg3);
  border:        1.5px solid var(--border-gold);
  border-radius: 9px;
  box-shadow:    0 8px 28px rgba(0,0,0,.6);
  z-index:       9000;
  min-width:     175px;
  padding:       5px 0;
  font-size:     12.5px;
  animation:     notif-in .12s ease;
}
.canvas-ctx-menu .ctx-header {
  padding:     5px 13px 4px;
  font-size:   10.5px; font-weight: 700;
  color:       var(--text-dim);
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
}
.canvas-ctx-menu .ctx-item {
  padding:     7px 13px;
  cursor:      pointer; color: var(--text);
  display:     flex; gap: 8px; align-items: center;
  transition:  background .1s, color .1s;
}
.canvas-ctx-menu .ctx-item:hover { background: rgba(200,168,75,.12); color: var(--gold-light); }
.canvas-ctx-menu .ctx-item--active { color: var(--gold); }
.canvas-ctx-menu .ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }
.canvas-ctx-menu .ctx-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}

/* ── Body popup (клик по тексту карточки) ─────────────── */
.db-body-popup {
  position:       fixed;
  z-index:        8500;
  width:          300px;
  max-height:     360px;
  display:        flex;
  flex-direction: column;
  background:     #fdf8ee;
  border:         1.5px solid rgba(200,168,75,0.55);
  border-radius:  10px;
  box-shadow:     0 8px 32px rgba(0,0,0,0.40), 0 2px 8px rgba(0,0,0,0.20);
  overflow:       hidden;
  opacity:        0;
  transform:      scale(0.93) translateY(-4px);
  transform-origin: top left;
  transition:     opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  font-family:    'Montserrat', sans-serif;
}
.db-body-popup--visible { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.db-body-popup__header {
  display:       flex;
  align-items:   center;
  gap:           7px;
  padding:       9px 12px 8px;
  background:    linear-gradient(135deg, color-mix(in srgb, var(--type-color,#7a6030) 18%, #2a1e0a), #1e1608);
  border-bottom: 1.5px solid rgba(200,168,75,0.25);
  flex-shrink:   0;
}
.db-body-popup__icon { font-size: 15px; line-height: 1; flex-shrink: 0; }
.db-body-popup__title {
  flex: 1; font-size: 12.5px; font-weight: 700; color: #e8d898;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em;
}
.db-body-popup__close {
  background: transparent; border: none; color: rgba(232,216,152,0.55);
  font-size: 13px; cursor: pointer; padding: 0 2px; line-height: 1;
  flex-shrink: 0; transition: color 0.12s;
}
.db-body-popup__close:hover { color: #e8d898; }
.db-body-popup__body {
  flex: 1; overflow-y: auto;
  padding:     12px 14px 14px;
  font-size:   12.5px; line-height: 1.7;
  color:       #1e1608;
  word-break:  break-word;
  background: #ccc;
}
.db-body-popup__body::-webkit-scrollbar { width: 5px; }
.db-body-popup__body::-webkit-scrollbar-track { background: transparent; }
.db-body-popup__body::-webkit-scrollbar-thumb { background: rgba(200,168,75,0.30); border-radius: 3px; }
.db-body-popup__body p { margin: 0 0 6px; }
.db-body-popup__body h1,
.db-body-popup__body h2 { font-size: 13.5px; font-weight: 700; margin: 8px 0 4px; color: #1e1608; }
.db-body-popup__body h3 { font-size: 12.5px; font-weight: 700; margin: 6px 0 3px; }
.db-body-popup__body ul,
.db-body-popup__body ol { margin: 0 0 6px; padding-left: 18px; }
.db-body-popup__body li { margin-bottom: 3px; }
.db-body-popup__body strong { font-weight: 700; }
.db-body-popup__body em { font-style: italic; }

/* ── Lightbox ─────────────────────────────────────────── */
.db-lightbox {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; align-items: center; justify-content: center;
}
.db-lightbox__backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.85);
  opacity: 0; transition: opacity .22s;
}
.db-lightbox--visible .db-lightbox__backdrop { opacity: 1; }
.db-lightbox__frame {
  position: relative; z-index: 1;
  transform: scale(.9); transition: transform .22s;
}
.db-lightbox--visible .db-lightbox__frame { transform: scale(1); }
.db-lightbox__img {
  max-width:  90vw; max-height: 90vh;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.7);
  display: block;
}
.db-lightbox__close {
  position: absolute; top: -12px; right: -12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.7); border: 1.5px solid rgba(255,255,255,.3);
  color: #fff; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.db-lightbox__close:hover { background: rgba(200,80,80,.8); }

/* ── Board tile delete ───────────────────────────────── */
.board-tile__del { opacity: 0; transition: opacity .14s; }
.board-tile:hover .board-tile__del { opacity: 1; }