/* ==================== Tokeny ==================== */
:root {
  --bg: #0e1015;
  --surface: #151821;
  --surface-2: #1b1f2b;
  --surface-3: #232838;
  --input: #10131a;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .12);
  --text: #e7e9f0;
  --text-2: #aab1c4;
  --muted: #727a91;
  --accent: #6d6af7;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(109, 106, 247, .14);
  --grad: linear-gradient(135deg, #7c7bfa 0%, #7c3aed 100%);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, .14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;

  /* barvy Discordu pro náhled */
  --dc-bg: #313338;
  --dc-embed: #2b2d31;
  --dc-text: #dbdee1;
  --dc-muted: #949ba4;
  --dc-link: #00a8fc;
  --dc-font: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: #a5a3ff; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ic { flex: none; }
::selection { background: rgba(109, 106, 247, .4); }
* { scrollbar-width: thin; scrollbar-color: #2c3244 transparent; }

/* ==================== Layout ==================== */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: linear-gradient(180deg, #121520, #0f1118); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; }
.brand-logo { width: 36px; height: 36px; border-radius: 11px; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: 12px; }

.server-switch { position: relative; margin-bottom: 10px; }
.server-switch .server-card {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.server-icon { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: 13px; overflow: hidden; flex: none; }
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-card .name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-switch select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.server-switch .ic { color: var(--muted); }

.nav-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 10px 10px 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: 0; border-radius: 10px;
  background: none; color: var(--text-2); cursor: pointer; font-weight: 500; text-align: left; position: relative;
}
.nav button:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: #fff; }
.nav button.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.nav button.active .ic { color: #a5a3ff; }
.nav .badge { margin-left: auto; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.usercard { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.usercard img { width: 32px; height: 32px; border-radius: 50%; }
.usercard .name { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usercard small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.version { color: var(--muted); font-size: 11.5px; text-align: center; letter-spacing: .02em; }

.main { min-width: 0; padding: 28px 36px 120px; max-width: 1500px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.mobile-bar { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 60; transform: translateX(-102%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.55); }
  .mobile-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(14,16,21,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
  .main { padding: 18px 16px 120px; }
}

/* ==================== Komponenty ==================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.ic-box { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: #a5a3ff; display: grid; place-items: center; flex: none; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.card-head p { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; }
.card-head .spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 180px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.hint { color: var(--muted); font-size: 13px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-family: var(--mono); font-size: 12.5px; color: #c9c8ff; }

label.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
label.field > .lbl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label.field .count { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
label.field .count.over { color: var(--danger); }

input[type=text], input[type=url], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #545b70; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,106,247,.22); }
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
input.over, textarea.over { border-color: var(--danger); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23727a91' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
select:disabled { opacity: .6; cursor: not-allowed; }
input[type=color] { width: 40px; height: 38px; padding: 3px; background: var(--input); border: 1px solid var(--border-2); border-radius: var(--radius-sm); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* přepínač */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; cursor: pointer; transition: .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #9aa1b5; transition: .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { left: 16px; background: #fff; }

/* tlačítka */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 550; font-size: 13.5px;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s, filter .15s; line-height: 1.3; text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(109,106,247,.3); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.success { background: var(--success); border-color: transparent; color: #04170a; }
.btn.success:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { background: var(--danger-soft); border-color: rgba(239,68,68,.35); color: #fca5a5; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.05); color: var(--text); }
.btn.ghost.danger-hover:hover:not(:disabled) { background: var(--danger-soft); color: #fca5a5; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.icon { padding: 7px; }
.btn.icon.small { padding: 5px; }
.btn.block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.badge.accent { background: var(--accent-soft); color: #b9b7ff; }
.badge.success { background: var(--success-soft); color: #86efac; }
.badge.warn { background: var(--warn-soft); color: #fcd34d; }

/* segmentové záložky */
.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.segmented button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 14px; border-radius: 9px; color: var(--text-2); cursor: pointer; font-weight: 550; }
.segmented button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.segmented button.active { background: var(--surface-3); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }

/* toolbar textu */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border-2); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.toolbar + textarea { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.toolbar button { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; font-size: 12px; font-weight: 700; }
.toolbar button:hover { background: rgba(255,255,255,.07); color: #fff; }
.toolbar .sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }

/* bannery */
.banner { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; flex-wrap: wrap; font-size: 13.5px; }
.banner.info { background: var(--accent-soft); border: 1px solid rgba(109,106,247,.35); color: #d4d3ff; }
.banner.warn { background: var(--warn-soft); border: 1px solid rgba(245,158,11,.35); color: #fde68a; }
.banner.error { background: var(--danger-soft); border: 1px solid rgba(239,68,68,.35); color: #fecaca; }

/* toasty */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 36px); }
.toast { display: flex; gap: 10px; align-items: center; background: #1d2130; border: 1px solid var(--border-2); padding: 11px 14px; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.45); max-width: 440px; animation: pop .18s ease-out; font-size: 13.5px; }
.toast .ic { color: #a5a3ff; }
.toast.ok .ic { color: var(--success); } .toast.err .ic { color: var(--danger); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* modální okna */
.modal-back { position: fixed; inset: 0; background: rgba(5,6,10,.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 18px; width: min(540px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.6); animation: pop .18s ease-out; }
.modal.wide { width: min(1080px, 100%); height: min(860px, 88vh); }
.modal header { padding: 18px 20px 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal header h3 { margin: 0; font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.modal .body { padding: 4px 20px 20px; overflow: auto; flex: 1; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* výběr zmínek */
.pick-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.pick-tabs button { border: 0; background: var(--surface-2); color: var(--text-2); padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 550; }
.pick-tabs button.active { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px var(--accent); }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow: auto; margin-top: 10px; }
.pick-list button { display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; color: var(--text); }
.pick-list button:hover { background: var(--surface-3); }
.pick-list .kind { color: var(--muted); font-size: 12px; margin-left: auto; }
.pick-list img { width: 22px; height: 22px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #99aab5; flex: none; }

/* ==================== Editor ==================== */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.preview-col { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1240px) { .editor-layout { grid-template-columns: 1fr; } .preview-col { position: static; } }

.tpl-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.tpl-bar .info { flex: 1; min-width: 180px; }
.tpl-bar .name { font-weight: 600; display: block; }
.tpl-bar .state { font-size: 12.5px; color: var(--muted); }
.tpl-bar .state.dirty { color: #fcd34d; }

.block-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; padding: 16px; box-shadow: var(--shadow); }
.block-card > .lbl-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 600; }
.block-card > .lbl-row .ic { color: #a5a3ff; }

.embed-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
.embed-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 14px; cursor: pointer; user-select: none; border-left: 4px solid var(--c, #4e5058); }
.embed-head .chev { color: var(--muted); transition: transform .15s; }
.embed-card.open .embed-head .chev { transform: rotate(90deg); }
.embed-head .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embed-head .title small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.embed-body { padding: 0 16px 6px; border-top: 1px solid var(--border); }

.section { border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 13px 2px; cursor: pointer; user-select: none; color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.section-head:hover { color: var(--text); }
.section-head .chev { margin-left: auto; transition: transform .15s; color: var(--muted); }
.section.open .section-head .chev { transform: rotate(180deg); }
.section-head .filled { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.section-body { padding: 0 2px 10px; }

.field-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.field-item .top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.field-item .top b { flex: 1; font-size: 13px; }
.color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.color-row input[type=text] { width: 110px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatches button { width: 22px; height: 22px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.swatches button.active { border-color: #fff; }
.errors { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.errors li { display: flex; gap: 8px; align-items: flex-start; color: #fca5a5; font-size: 13px; background: var(--danger-soft); padding: 8px 10px; border-radius: 9px; }
.add-embed { width: 100%; border: 1.5px dashed var(--border-2); background: transparent; color: var(--text-2); border-radius: var(--radius); padding: 14px; display: flex; gap: 8px; align-items: center; justify-content: center; cursor: pointer; font-weight: 550; margin-bottom: 14px; }
.add-embed:hover:not(:disabled) { border-color: var(--accent); color: #fff; background: var(--accent-soft); }
.add-embed:disabled { opacity: .4; cursor: not-allowed; }

/* ==================== Náhled (vzhled Discordu) ==================== */
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.preview-card > .bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.preview-card > .bar .dots { display: flex; gap: 5px; margin-right: 4px; }
.preview-card > .bar .dots i { width: 9px; height: 9px; border-radius: 50%; background: #2c3142; }
.preview-card > .bar .spacer { flex: 1; }
.preview { background: var(--dc-bg); padding: 16px 16px 18px 0; font-family: var(--dc-font); font-size: 15px; line-height: 1.375; color: var(--dc-text); }
.preview-card .foot { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.dmsg { display: flex; gap: 16px; padding-left: 16px; }
.dmsg .avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; margin-top: 2px; background: #1e1f22; }
.dmsg .body { min-width: 0; flex: 1; }
.dmsg .head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.dmsg .uname { font-weight: 500; color: #f2f3f5; }
.dmsg .apptag { background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; padding: 0 4.5px; border-radius: 3px; line-height: 15px; align-self: center; }
.dmsg .time { font-size: 12px; color: var(--dc-muted); }
.dmsg .content { word-wrap: break-word; }
.dmsg .empty { color: var(--dc-muted); font-style: italic; }

.md-mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.md-timestamp { background: rgba(255,255,255,.06); border-radius: 3px; padding: 0 2px; }
.md-code { background: #2b2d31; border: 1px solid #1e1f22; border-radius: 4px; padding: 0 .2em; font-family: Consolas, "Andale Mono WT", monospace; font-size: 85%; color: inherit; }
.md-codeblock { background: #2b2d31; border: 1px solid #1e1f22; border-radius: 4px; padding: 7px; margin: 6px 0 0; font-family: Consolas, "Andale Mono WT", monospace; font-size: 13px; white-space: pre-wrap; overflow-x: auto; }
.dembed .md-code, .dembed .md-codeblock { background: #1e1f22; }
.md-quote { margin: 0; padding: 0 8px 0 12px; border-left: 4px solid #4e5058; }
.md-h { margin: 8px 0 0; line-height: 1.375; color: #f2f3f5; font-weight: 700; }
h1.md-h { font-size: 1.5em; } h2.md-h { font-size: 1.25em; } h3.md-h { font-size: 1em; }
.md-subtext { font-size: 12px; color: var(--dc-muted); }
.md-list { margin: 4px 0 0; padding-left: 20px; }
.md-link { color: var(--dc-link); text-decoration: none; }
.md-link:hover { text-decoration: underline; }
.md-emoji { width: 22px; height: 22px; vertical-align: -0.35em; object-fit: contain; }
.md-spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; transition: .1s; }
.md-spoiler * { visibility: hidden; }
.md-spoiler:hover, .md-spoiler:focus { background: rgba(255,255,255,.1); color: inherit; }
.md-spoiler:hover *, .md-spoiler:focus * { visibility: visible; }

.dembed { display: grid; max-width: 520px; background: var(--dc-embed); border-left: 4px solid #1e1f22; border-radius: 4px; margin-top: 4px; }
.dembed .grid { display: grid; grid-template-columns: auto; padding: 8px 16px 16px 12px; overflow: hidden; }
.dembed.has-thumb .grid { grid-template-columns: auto min-content; }
.dembed .author { grid-column: 1/2; display: flex; align-items: center; margin-top: 8px; font-size: 14px; font-weight: 600; color: #f2f3f5; }
.dembed .author img { width: 24px; height: 24px; border-radius: 50%; margin-right: 8px; object-fit: contain; }
.dembed .author a { color: inherit; text-decoration: none; }
.dembed .title { grid-column: 1/2; margin-top: 8px; font-weight: 600; color: #f2f3f5; font-size: 16px; }
.dembed .title a { color: var(--dc-link); text-decoration: none; }
.dembed .desc { grid-column: 1/2; margin-top: 8px; font-size: 14px; line-height: 1.125rem; word-wrap: break-word; }
.dembed .fields { grid-column: 1/2; display: grid; grid-gap: 8px; margin-top: 8px; grid-template-columns: repeat(12, 1fr); }
.dembed .dfield { font-size: 14px; line-height: 1.125rem; min-width: 0; }
.dembed .dfield .fname { font-weight: 600; color: #f2f3f5; margin-bottom: 2px; }
.dembed .dfield .fval { word-wrap: break-word; }
.dembed .thumb { grid-row: 1/8; grid-column: 2/3; margin: 8px 0 0 16px; justify-self: end; }
.dembed .thumb img { max-width: 80px; max-height: 80px; border-radius: 4px; object-fit: contain; display: block; }
.dembed .image { grid-column: 1/3; margin-top: 16px; }
.dembed .image img { max-width: 100%; max-height: 300px; border-radius: 4px; display: block; }
.dembed .footer { grid-column: 1/3; display: flex; align-items: center; margin-top: 8px; font-size: 12px; color: #b5bac1; font-weight: 500; }
.dembed .footer img { width: 20px; height: 20px; border-radius: 50%; margin-right: 8px; object-fit: contain; }
.dbuttons { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dbutton { height: 32px; padding: 2px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #fff; display: inline-flex; align-items: center; gap: 6px; }
.dbutton.primary { background: #5865f2; } .dbutton.secondary { background: #4e5058; }
.dbutton.success { background: #248046; } .dbutton.danger { background: #da373c; }

/* ==================== Šablony (popup) ==================== */
.tpl-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tpl { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; transition: border-color .15s; }
.tpl:hover { border-color: var(--border-2); }
.tpl.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tpl .mini { padding: 10px 10px 10px 0; background: var(--dc-bg); height: 180px; overflow: hidden; position: relative; font-family: var(--dc-font); font-size: 13px; color: var(--dc-text); cursor: pointer; }
.tpl .mini > * { pointer-events: none; }
.tpl .mini .dembed { max-width: 100%; }
.tpl .mini::after { content: ""; position: absolute; inset: auto 0 0 0; height: 50px; background: linear-gradient(transparent, var(--dc-bg)); }
.tpl .meta { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tpl .meta .title { display: flex; align-items: center; gap: 8px; }
.tpl .meta b { font-size: 14.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl .actions { display: flex; gap: 4px; align-items: center; }
.tpl .actions .btn.primary { flex: 1; }
.empty-state { text-align: center; color: var(--text-2); padding: 48px 16px; }
.empty-state .ic-box { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 12px; }
.empty-state b { color: var(--text); font-size: 15px; display: block; margin-bottom: 4px; }

/* ==================== Tabulky, role, statistiky ==================== */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.list td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: rgba(255,255,255,.015); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-3); border-radius: 20px; padding: 3px 4px 3px 10px; margin: 2px; font-size: 12.5px; }
.chip button { display: grid; place-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 50%; }
.chip button:hover { color: #fff; background: var(--danger); }
.role-list { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 20px; cursor: pointer; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--border-2); transition: .15s; user-select: none; }
.role-chip input { display: none; }
.role-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); min-width: 0; }
.stat > div { min-width: 0; }
.stat b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat small { color: var(--muted); font-size: 12.5px; }

/* ==================== Login a start ==================== */
.boot { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(600px 400px at 50% 0%, rgba(109,106,247,.18), transparent), var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--border-2); border-radius: 20px; padding: 36px 32px; width: min(420px, 100%); text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.login-logo { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 14px; }
.login-box h1 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.login-box p { color: var(--text-2); margin: 0 0 18px; }
.login-box .btn { margin-top: 6px; padding: 11px; }
.login-box .version { margin-top: 18px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
