:root {
  --ink: #191916;
  --muted: #71716b;
  --paper: #f6f4ef;
  --card: #fffefa;
  --line: #e4e0d7;
  --accent: #ee5d32;
  --accent-dark: #c73d18;
  --sage: #dfe8dd;
  --shadow: 0 20px 60px rgba(40, 34, 24, .09);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 5vw, 72px); border-bottom: 1px solid var(--line); background: rgba(246,244,239,.94); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: white; font: 800 27px/1 Georgia, serif; background: var(--accent); box-shadow: 0 8px 20px rgba(238,93,50,.25); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.container { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 100px; }
.container.narrow { max-width: 900px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 28px; padding: 18px 0 42px; }
h1 { font: 700 clamp(38px, 6vw, 74px)/1.02 Georgia, "Noto Serif SC", serif; margin: 7px 0 13px; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 19px; line-height: 1.3; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .18em; color: var(--accent); }
.muted { color: var(--muted); line-height: 1.7; }
.primary, .secondary, .ghost { border: 0; border-radius: 12px; cursor: pointer; font-weight: 750; }
.primary { background: var(--accent); color: white; padding: 14px 20px; box-shadow: 0 8px 22px rgba(238,93,50,.18); }
.primary:hover { background: var(--accent-dark); }
.button { display: inline-block; white-space: nowrap; }
.secondary { background: var(--ink); color: white; padding: 12px 18px; }
.ghost { background: transparent; padding: 10px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4,1fr); background: var(--card); border: 1px solid var(--line); border-radius: 18px; margin-bottom: 24px; box-shadow: var(--shadow); }
.stats div { padding: 22px 26px; border-right: 1px solid var(--line); }
.stats div:last-child { border: 0; }
.stats strong { font: 700 28px/1 Georgia, serif; display: block; }
.stats span { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 10px; align-items: center; margin: 24px 0 30px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 12px 13px; color: var(--ink); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,93,50,.11); }
.search { flex: 1; }
.filters select { width: 150px; }
.check { display: flex; align-items: center; white-space: nowrap; gap: 5px; font-size: 13px; }
.check input { width: auto; }
.card { display: inline-block; width: 100%; break-inside: avoid; background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin-bottom: 22px; box-shadow: 0 10px 35px rgba(40,34,24,.06); }
.media-wrap { position: relative; background: #dedbd3; }
.media-wrap img, .media-wrap video { width: 100%; display: block; max-height: 560px; object-fit: cover; }
.type-pill { position: absolute; top: 12px; left: 12px; background: rgba(20,20,17,.75); color: white; padding: 6px 9px; border-radius: 999px; font-size: 11px; backdrop-filter: blur(7px); }
.card-body { padding: 18px; }
.card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.icon-button { border: 0; background: transparent; color: #c8c3b7; font-size: 22px; cursor: pointer; padding: 0; }
.icon-button.active { color: #e9ad28; }
.model { color: var(--accent); font-size: 12px; font-weight: 800; margin: 6px 0 9px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0; }
.tags span { background: var(--sage); padding: 5px 8px; border-radius: 999px; font-size: 11px; }
.description { color: var(--muted); line-height: 1.6; font-size: 13px; }
.prompt { position: relative; margin-top: 12px; padding: 13px 46px 13px 13px; background: #f1eee7; border-radius: 11px; }
.prompt b, details summary { font-size: 11px; letter-spacing: .05em; color: var(--muted); }
.prompt p, details p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; margin: 6px 0 0; }
.copy { position: absolute; right: 8px; top: 8px; border: 0; background: white; border-radius: 7px; padding: 6px; font-size: 10px; cursor: pointer; }
details { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
details summary { cursor: pointer; }
.card-actions { display: flex; gap: 16px; border-top: 1px solid var(--line); margin-top: 15px; padding-top: 13px; font-size: 12px; font-weight: 700; }
.card-actions form { margin: 0; }
.link { border: 0; padding: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.danger { color: #b93f29; }
.visibility-action { color: #785d16; }
.is-hidden-content { border-color: #c7a85a !important; border-style: dashed !important; background-color: #fffaf0 !important; }
.visibility-badge { display: inline-flex; align-items: center; margin-bottom: 8px; padding: 4px 8px; border-radius: 999px; background: #f5e4ad; color: #76530a; font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.visibility-inline { display: inline-block; margin-left: 5px; padding: 3px 6px; border-radius: 999px; background: #f5e4ad; color: #76530a; font: 800 9px/1.2 sans-serif; font-style: normal; vertical-align: middle; }
.empty { text-align: center; padding: 80px 20px; border: 1px dashed #cbc5b8; border-radius: 18px; color: var(--muted); }
.empty div { font-size: 36px; color: var(--accent); }
.upload-panel { margin-top: 70px; display: grid; grid-template-columns: minmax(220px,.7fr) 1.3fr; gap: 55px; padding: clamp(28px, 5vw, 60px); background: #20211d; color: white; border-radius: 24px; }
.upload-panel .muted { color: #b8b9b2; }
.upload-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.upload-form label { color: #d2d2cc; font-size: 12px; font-weight: 700; }
.upload-form input, .upload-form textarea { margin-top: 7px; }
.full { grid-column: 1 / -1; }
.edit-panel { margin-top: 30px; }
.back { display: inline-block; color: var(--muted); margin-bottom: 12px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #fff8e8, transparent 45%), var(--paper); }
.login-card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 44px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 45px; }
.stack { display: grid; gap: 18px; margin-top: 28px; }
.stack label { display: grid; gap: 8px; font-weight: 700; font-size: 13px; }
.flash { padding: 12px 15px; border-radius: 10px; margin: 12px 0; font-size: 13px; }
.flash.error { background: #fce0db; color: #8e2d1c; }
.flash.success { background: #dcedd9; color: #2d6b29; }
@media (max-width: 760px) {
  .container { width: min(100% - 24px, 1440px); padding-top: 30px; }
  .hero { align-items: start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filters { align-items: stretch; flex-direction: column; }
  .filters select { width: 100%; }
  .upload-panel { grid-template-columns: 1fr; gap: 25px; }
  .upload-form { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .login-card { padding: 30px; }
}



/* Compact library layout */
.topbar { height: 56px; padding: 0 clamp(14px, 3vw, 40px); }
.brand { gap: 8px; font-size: 14px; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-actions form { margin: 0; }
.container { width: min(1540px, calc(100% - 24px)); padding: 24px 0 64px; }
.hero { padding: 6px 0 18px; gap: 16px; }
.hero h1, .admin-head h1 { font-size: clamp(30px, 4vw, 50px); margin: 4px 0 7px; }
.hero .muted, .admin-head .muted { margin: 0; font-size: 13px; }
.stats { border-radius: 13px; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(40,34,24,.05); }
.stats div { padding: 12px 18px; }
.stats strong { font-size: 22px; }
.stats span { font-size: 11px; }
.filters { gap: 8px; margin: 14px 0 18px; }
input, textarea, select { border-radius: 9px; padding: 9px 11px; }
.secondary { padding: 9px 15px; border-radius: 9px; }
.card { border-radius: 13px; margin-bottom: 14px; box-shadow: 0 6px 22px rgba(40,34,24,.05); }
.media-wrap img, .media-wrap video { max-height: 420px; }
.type-pill { top: 8px; left: 8px; padding: 4px 7px; font-size: 10px; }
.card-body { padding: 13px; }
.card h2 { font-size: 16px; }
.icon-button { font-size: 19px; }
.model { margin: 4px 0 7px; font-size: 11px; }
.tags { margin: 7px 0; gap: 4px; }
.tags span { padding: 3px 7px; font-size: 10px; }
.description { margin: 8px 0; font-size: 12px; line-height: 1.5; }
.prompt { margin-top: 8px; padding: 10px 40px 10px 10px; border-radius: 9px; }
.prompt p, details p { font-size: 12px; line-height: 1.45; margin-top: 4px; }
.copy { right: 6px; top: 6px; padding: 5px; }
details { margin-top: 8px; padding-top: 8px; }
.card-actions { margin-top: 10px; padding-top: 9px; }
.empty { padding: 52px 20px; border-radius: 13px; }
.admin-shell { max-width: 980px; }
.admin-head { padding: 8px 0 18px; }
.admin-upload { display: block; margin-top: 0; padding: clamp(22px, 4vw, 38px); border-radius: 18px; }
.admin-upload .upload-form { max-width: 820px; margin: 0 auto; gap: 12px; }
.admin-upload .primary { margin-top: 4px; }

@media (max-width: 760px) {
  .topbar { height: 52px; padding: 0 12px; }
  .topbar-actions { gap: 0; }
  .ghost { padding: 8px 7px; font-size: 12px; }
  .container { width: min(100% - 20px, 1540px); padding-top: 18px; }
  .hero { padding-bottom: 14px; }
  .hero h1, .admin-head h1 { font-size: 31px; }
  .stats div { padding: 10px 12px; }
  .filters { gap: 7px; }
  .card { margin-bottom: 10px; }
  .card-body { padding: 11px; }
  .admin-upload { padding: 20px 14px; }
}


/* Row-first masonry and large image preview */
.gallery {
  columns: auto;
  display: block;
  position: relative;
  min-height: 180px;
  visibility: hidden;
}
.gallery .card {
  display: block;
  margin: 0;
  position: absolute;
  left: 0;
  top: 0;
}
.gallery.masonry-ready { visibility: visible; }
.gallery.masonry-settled .card {
  transition: transform .18s ease, width .18s ease;
}
.image-open {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
  color: inherit;
}
.image-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
body.lightbox-open { overflow: hidden; }
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 15, 13, .92);
  backdrop-filter: blur(12px);
}
.lightbox-stage {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: min(94vw, 1600px);
  max-height: 92vh;
}
.lightbox-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 42px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
}
.lightbox-stage figcaption { color: #f3f1eb; font-size: 13px; }
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 101;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: white;
  font: 300 28px/1 sans-serif;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }

@media (max-width: 1100px) {
  .gallery { min-height: 150px; }
}
@media (max-width: 760px) {
  .gallery { min-height: 120px; }
  .lightbox { padding: 14px; }
  .lightbox-close { top: 10px; right: 10px; }
  .lightbox-stage img { max-height: calc(92vh - 36px); }
}
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.pagination > div { display: flex; gap: 8px; }
.upload-form select { margin-top: 7px; }

/* Multiple files in one post */
.media-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  background: #dedbd3;
}
.media-grid.is-multiple { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.media-item { min-width: 0; overflow: hidden; background: #dedbd3; }
.media-grid:not(.is-multiple) video { aspect-ratio: 16 / 9; object-fit: cover; }
.media-grid.is-multiple .media-item { aspect-ratio: 1 / 1; }
.media-grid.is-multiple .image-open,
.media-grid.is-multiple .video-card-preview,
.media-grid.is-multiple img,
.media-grid.is-multiple video {
  width: 100%;
  height: 100%;
}
.media-grid.is-multiple img,
.media-grid.is-multiple video {
  max-height: none;
  object-fit: cover;
}
.lightbox-stage figcaption {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.lightbox-nav {
  position: fixed;
  top: 50%;
  z-index: 101;
  width: 48px;
  height: 60px;
  transform: translateY(-50%);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  color: white;
  font: 300 38px/1 sans-serif;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }
.lightbox-nav[hidden] { display: none; }
@media (max-width: 760px) {
  .lightbox-nav { width: 40px; height: 52px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

/* Collapse prompt text over 300 characters */
.prompt-collapsible { padding-bottom: 10px; padding-right: 102px; }
.prompt-collapsible:not(.expanded) [data-prompt-text] {
  max-height: 13em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
}
.prompt-toggle {
  position: absolute;
  right: 46px;
  top: 6px;
  border: 0;
  border-radius: 7px;
  padding: 5px 9px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(40,34,24,.07);
}
.prompt-toggle:hover { background: #fbf7ee; }

/* Navigation and management */
.topbar { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; }
.main-nav { display: flex; justify-content: center; align-items: center; gap: 4px; min-width: 0; }
.main-nav a { padding: 8px 11px; border-radius: 9px; color: var(--muted); font-size: 13px; font-weight: 750; white-space: nowrap; }
.main-nav a:hover, .main-nav a.active { background: white; color: var(--ink); box-shadow: 0 2px 10px rgba(40,34,24,.06); }
.user-chip { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.admin-page, .edit-page, .tool-page { padding-top: 28px; }
.admin-head, .tool-head { padding: 4px 0 22px; }
.admin-head h1, .tool-head h1 { font-size: clamp(34px, 5vw, 56px); margin: 4px 0 6px; }
.admin-columns { display: grid; grid-template-columns: minmax(320px,.9fr) minmax(440px,1.1fr); gap: 18px; align-items: stretch; }
.management-panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 8px 28px rgba(40,34,24,.05); }
.section-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.section-heading h2 { margin-top: 4px; font-size: 24px; }
.subsection { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.subsection h3 { margin: 0 0 13px; font-size: 14px; }
.user-add-form { display: grid; gap: 10px; }
.user-add-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.user-list { display: grid; gap: 9px; }
.user-row { display: grid; grid-template-columns: minmax(110px,1fr) minmax(210px,1.4fr) auto; gap: 9px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 11px; }
.user-summary { display: grid; min-width: 0; }
.user-summary span, .user-summary small { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.user-role-form { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; align-items: center; }
.user-role-form select { padding: 7px; }
.role-badge { justify-self: start; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.role-badge.super { background: #f9dfb3; color: #7b4b05; }
.small { padding: 7px 9px; border-radius: 8px; font-size: 11px; }
.tiny { font-size: 10px; }
.empty.compact { padding: 28px 16px; }
.upload-side .upload-form { margin-top: 18px; }
.users-panel { min-width: 0; display: flex; flex-direction: column; }
.admin-view-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 22px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #f2efe8; }
.admin-view-tabs a { padding: 10px 12px; border-radius: 8px; color: var(--muted); text-align: center; font-size: 12px; font-weight: 800; }
.admin-view-tabs a:hover { color: var(--ink); }
.admin-view-tabs a.active { background: white; color: var(--ink); box-shadow: 0 3px 12px rgba(40,34,24,.08); }
.user-create-section { margin-top: 0; }
.admin-record-heading { align-items: center; }
.record-count { padding: 6px 9px; border-radius: 999px; background: #f1eee7; color: var(--muted); font-size: 10px; font-weight: 750; }
.login-role-filter { display: grid; grid-template-columns: repeat(3,max-content) 1fr; gap: 9px; align-items: center; margin-bottom: 14px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #faf8f3; }
.login-role-filter label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.login-role-filter input { width: auto; }
.login-role-filter button { justify-self: end; }
.login-record-list { display: grid; gap: 8px; }
.login-record-row { display: grid; gap: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fffefa; }
.login-record-user { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.login-record-user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.login-record-user .role-badge { justify-self: auto; padding: 4px 7px; font-size: 9px; }
.role-ordinary { background: #ece9e1; color: #625e54; }
.role-vip { background: #f8e5b6; color: #78590e; }
.role-admin, .role-superadmin { background: #dfe8dd; color: #3d6a5d; }
.login-record-row time { color: var(--ink); font-size: 10px; font-variant-numeric: tabular-nums; }
.login-record-meta { display: grid; grid-template-columns: minmax(100px,.7fr) minmax(0,1.3fr); gap: 8px; color: var(--muted); font-size: 9px; }
.login-record-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; padding-top: 18px; color: var(--muted); font-size: 10px; }
.record-pagination > div { display: flex; gap: 7px; }
.lightbox-hidden-trigger { display: none; }
.media-item { position: relative; }
.more-media { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,20,17,.58); color: white; font: 800 28px/1 Georgia,serif; pointer-events: none; }

/* Post media editor */
.media-manager { margin: 16px 0 22px; }
.edit-media-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.edit-media-card { position: relative; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 12px; background: #f8f6f1; cursor: grab; }
.edit-media-card.dragging { opacity: .45; }
.edit-media-card.drag-over { outline: 2px solid var(--accent); }
.edit-media-card img, .edit-media-card video { display: block; width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; background: #dedbd3; }
.edit-media-card p { margin: 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--muted); }
.edit-media-card form { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.drag-handle { position: absolute; top: 15px; right: 15px; z-index: 2; padding: 5px 7px; border-radius: 7px; background: rgba(20,20,17,.72); color: white; line-height: 1; }
.replace-file { flex: 1; min-width: 0; padding: 7px; border-radius: 7px; background: white; color: var(--muted); font-size: 10px; overflow: hidden; }
.replace-file input { display: none; }
.media-manager-actions { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 16px; }
.add-media-form { display: flex; gap: 8px; align-items: center; }
.add-media-form input { max-width: 320px; }
.edit-page .edit-panel { margin-top: 0; }

/* Mind maps and quick notes */
.mindmap-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 16px; align-items: start; }
.mindmap-list, .mindmap-workspace, .quick-note-form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 17px; }
.new-map-form { display: grid; gap: 8px; }
.map-links { display: grid; gap: 6px; margin-top: 14px; }
.map-links a { display: grid; gap: 3px; padding: 10px; border-radius: 9px; color: var(--muted); }
.map-links a.active, .map-links a:hover { background: #f1eee7; color: var(--ink); }
.map-links span { font-size: 9px; }
.mindmap-workspace { min-height: 520px; }
.mindmap-editor { display: grid; gap: 10px; }
.map-title { font-size: 20px; font-weight: 800; }
.mindmap-preview { margin: 18px 0; padding: 18px; border-radius: 12px; background: #f1eee7; overflow: auto; }
.mindmap-preview ul { list-style: none; margin: 8px 0 8px 14px; padding-left: 18px; border-left: 2px solid #d7cfc0; }
.mindmap-preview > ul { border-left: 0; margin-left: 0; padding-left: 0; }
.mindmap-preview li > span { display: inline-block; margin: 3px 0; padding: 7px 10px; border-radius: 8px; background: white; box-shadow: 0 2px 8px rgba(40,34,24,.06); font-size: 12px; }
.quick-note-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-bottom: 18px; }
.notes-grid { columns: 3 280px; column-gap: 14px; }
.note-card { break-inside: avoid; display: inline-block; width: 100%; margin-bottom: 14px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff9d9; box-shadow: 0 6px 20px rgba(40,34,24,.05); }
.note-card textarea { border: 0; background: transparent; resize: vertical; box-shadow: none; }
.note-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; }
.note-card > form:last-child { margin-top: 7px; }

/* Refined library toolbar and side-by-side editor */
.main-nav a { font-size: 16px; padding: 8px 14px; }
.manage-link.active { background: white; color: var(--ink); box-shadow: 0 2px 10px rgba(40,34,24,.06); }
.library-toolbar { display: grid; grid-template-columns: auto minmax(420px,1fr); align-items: stretch; gap: 12px; margin: 14px 0 18px; }
.library-toolbar .stats { margin: 0; box-shadow: 0 5px 18px rgba(40,34,24,.04); }
.library-toolbar .stats div { min-width: 78px; padding: 9px 12px; }
.library-toolbar .stats strong { font-size: 19px; }
.library-toolbar .filters { margin: 0; padding: 7px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); }
.description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.edit-layout { display: grid; grid-template-columns: minmax(420px,.9fr) minmax(500px,1.1fr); gap: 18px; align-items: start; margin-top: 16px; }
.edit-layout .media-manager { margin: 0; position: sticky; top: 72px; }
.edit-layout .edit-panel { display: block; margin: 0; padding: 24px; }
.edit-layout .edit-panel > div { margin-bottom: 18px; }
.edit-layout .edit-panel h1 { font-size: 38px; }
.edit-layout .edit-media-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.edit-layout .media-manager-actions { align-items: stretch; flex-direction: column; }
.edit-layout .add-media-form { align-items: stretch; flex-direction: column; }
.edit-layout .add-media-form input { max-width: none; }

@media (max-width: 980px) {
  .user-chip { display: none; }
  .admin-columns { grid-template-columns: 1fr; }
  .edit-media-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .library-toolbar { grid-template-columns: 1fr; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-layout .media-manager { position: static; }
  .edit-layout .edit-media-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 5px; }
  .brand { font-size: 0; }
  .main-nav { justify-content: start; overflow-x: auto; }
  .main-nav a { padding: 7px 8px; font-size: 13px; }
  .edit-media-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .media-manager-actions, .add-media-form { align-items: stretch; flex-direction: column; }
  .add-media-form input { max-width: none; }
  .mindmap-layout { grid-template-columns: 1fr; }
  .quick-note-form { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr; }
  .user-role-form { grid-template-columns: 1fr auto auto; }
  .library-toolbar .filters { flex-direction: column; }
  .edit-layout .edit-media-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .login-role-filter { grid-template-columns: 1fr 1fr; }
  .login-role-filter button { justify-self: stretch; }
  .login-record-meta { grid-template-columns: 1fr; }
}

/* Two-column notes workspace */
.notes-layout { display: grid; grid-template-columns: 230px minmax(0,1fr); gap: 18px; align-items: start; }
.notes-sidebar { position: sticky; top: 76px; display: grid; gap: 14px; }
.new-note-button { display: block; text-align: center; padding: 12px 16px; }
.note-labels { padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); }
.note-labels h2 { margin: 2px 4px 10px; font-size: 15px; }
.note-labels a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); font-size: 12px; }
.note-labels a:hover, .note-labels a.active { color: var(--ink); background: #f1eee7; }
.note-labels b { font-size: 10px; }
.label-empty { padding: 6px 4px; font-size: 10px; line-height: 1.5; }
.notes-main { min-width: 0; }
.notes-quick-form, .note-editor { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 7px 24px rgba(40,34,24,.04); }
.notes-quick-form { grid-template-columns: minmax(0,1fr) auto; }
.note-editor { display: grid; gap: 11px; padding: 18px; }
.note-editor-head, .note-card-head, .note-footer, .notes-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.note-editor-head h2, .notes-section-head h2, .note-card-head h3 { margin: 0; }
.note-editor-head .eyebrow { margin-bottom: 3px; }
.note-title-input { font-size: 20px; font-weight: 750; }
.markdown-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 360px; }
.markdown-workspace > div { display: grid; grid-template-rows: auto 1fr; gap: 6px; min-width: 0; }
.markdown-workspace label { font-size: 10px; color: var(--muted); }
.markdown-workspace textarea { min-height: 340px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.65; }
.markdown-preview { min-height: 340px; padding: 14px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #faf9f6; }
.note-editor-actions { display: flex; justify-content: flex-end; }
.notes-section-head { margin: 23px 2px 12px; }
.notes-section-head h2 { font-size: 18px; }
.notes-section-head span { color: var(--muted); font-size: 11px; }
.notes-feed { display: grid; gap: 12px; }
.note-detail-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: 0 5px 18px rgba(40,34,24,.04); }
.quick-note-card { background: var(--card); }
.quick-note-card textarea { width: 100%; resize: vertical; }
.quick-delete { margin-top: 4px; }
.note-kind { display: inline-block; margin-bottom: 3px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.note-card-head h3 { font-size: 21px; }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.note-tags a { padding: 5px 8px; border-radius: 99px; background: #f1eee7; color: var(--muted); font-size: 10px; }
.note-footer { margin-top: 12px; color: var(--muted); font-size: 9px; }
.note-footer form { margin: 0; }
.markdown-body { color: var(--ink); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 1em 0 .45em; line-height: 1.25; }
.markdown-body p { margin: .55em 0; }
.markdown-body ul, .markdown-body ol { margin: .5em 0; padding-left: 1.7em; }
.markdown-body blockquote { margin: .7em 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: #f5f2eb; color: var(--muted); }
.markdown-body code { padding: 2px 5px; border-radius: 5px; background: #eeeae2; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
.markdown-body pre { overflow: auto; padding: 13px; border-radius: 9px; background: #24231f; color: #f8f5ed; }
.markdown-body pre code { padding: 0; background: transparent; color: inherit; }
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-image-hint { margin-left: 7px; color: var(--muted); font-weight: 400; }
.markdown-body .note-image { margin: 12px 0; }
.markdown-body .note-image img { display: block; width: auto; max-width: 100%; max-height: 560px; object-fit: contain; border-radius: 10px; background: #eeeae2; }
.markdown-body .note-image figcaption { margin-top: 5px; color: var(--muted); font-size: 10px; }
.note-card-actions { display: flex; align-items: center; gap: 7px; }
.note-card-actions form, .simple-map-view-head form { margin: 0; }
.note-content { position: relative; max-height: 250px; overflow: hidden; transition: max-height .22s ease; }
.note-content.expanded { max-height: none; overflow: visible; }
.note-detail-card.has-overflow .note-content:not(.expanded)::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 64px; pointer-events: none; background: linear-gradient(transparent, var(--card)); }
.quick-note-edit-form { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.quick-note-edit-form[hidden], [data-note-content][hidden] { display: none; }
.quick-note-edit-actions { display: flex; justify-content: flex-end; gap: 7px; }
.note-footer .danger { font-size: 10px; }

@media (max-width: 760px) {
  .notes-layout { grid-template-columns: 1fr; }
  .notes-sidebar { position: static; }
  .note-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .note-labels h2 { width: 100%; }
  .markdown-workspace { grid-template-columns: 1fr; }
  .notes-quick-form { grid-template-columns: 1fr; }
}

/* Simple Mind Map editor */
.simple-map-layout { grid-template-columns: 250px minmax(0, 1fr); }
.simple-map-workspace { min-height: 690px; padding: 12px; overflow: hidden; }
.simple-map-workspace:fullscreen { width: 100vw; height: 100vh; padding: 14px; border: 0; border-radius: 0; background: #f7f5ef; }
.simple-map-form { margin-bottom: 10px; }
.simple-map-titlebar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; align-items: center; }
.simple-map-view-head .simple-map-titlebar { grid-template-columns: minmax(220px, 1fr) auto auto auto; }
.simple-map-titlebar .map-title { min-width: 0; border-color: transparent; background: transparent; }
.simple-map-titlebar .map-title:focus { border-color: var(--line); background: white; }
.map-title-actions { display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.map-view-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 22px; }
.view-mode-badge { padding: 6px 9px; border-radius: 999px; background: #e7eee9; color: #487769; font-size: 10px; font-weight: 750; }
.readonly-toolbar { justify-content: flex-end; }
.mindmap-blank-canvas { width: 100%; height: 652px; border: 1px solid var(--line); border-radius: 12px; background-color: #fff; background-image: radial-gradient(#dedbd2 1px, transparent 1px); background-size: 20px 20px; }
.simple-map-workspace.is-blank { min-height: 690px; }
.save-state { color: var(--muted); font-size: 10px; }
.save-state.dirty { color: #b56a1b; font-weight: 750; }
.mindmap-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px; margin-bottom: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #f6f3ec; }
.toolbar-group { display: flex; align-items: center; gap: 5px; }
.mindmap-toolbar button, .mindmap-toolbar select, .map-import { min-height: 32px; padding: 7px 9px; border: 1px solid #d9d3c7; border-radius: 8px; background: white; color: var(--ink); font-size: 10px; line-height: 1; cursor: pointer; }
.mindmap-toolbar button:hover, .map-import:hover { border-color: var(--accent); color: var(--accent); }
.mindmap-toolbar button:disabled { opacity: .55; cursor: wait; }
.mindmap-toolbar .danger-soft { color: #a4473c; }
.toolbar-group [data-map-scale] { min-width: 38px; color: var(--muted); text-align: center; font-size: 10px; }
.map-import { display: inline-flex; align-items: center; }
.map-import input { display: none; }
.simple-map-canvas { position: relative; width: 100%; height: 570px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background-color: #fff; background-image: radial-gradient(#dedbd2 1px, transparent 1px); background-size: 20px 20px; outline: none; }
.simple-map-workspace:fullscreen .simple-map-canvas { height: calc(100vh - 132px); }
.simple-map-canvas * { box-sizing: border-box; margin: 0; padding: 0; }
.simple-map-canvas .smm-richtext-node-wrap, .simple-map-canvas .smm-richtext-node-wrap * { margin: 0; padding: 0; }
.map-color-control { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 5px 8px; border: 1px solid #d9d3c7; border-radius: 8px; background: white; color: var(--ink); font-size: 10px; white-space: nowrap; }
.map-color-control input[type="color"] { width: 24px; height: 22px; padding: 1px; border: 0; border-radius: 5px; cursor: pointer; }
.map-color-control input[type="color"]:disabled { cursor: not-allowed; opacity: .4; }
.map-loading { display: grid; height: 100%; place-items: center; color: var(--muted); font-size: 12px; }
.mindmap-help { display: flex; flex-wrap: wrap; gap: 12px; padding: 9px 4px 2px; color: var(--muted); font-size: 9px; }
.map-delete-form { margin-top: 7px; }
.simple-map-canvas .smm-node { cursor: pointer; }

/* Asset detail modal */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.asset-card { cursor: pointer; transition: box-shadow .18s ease, border-color .18s ease; }
.asset-card:hover { border-color: #d5cec0; box-shadow: 0 13px 35px rgba(40,34,24,.1); }
.asset-card:focus-visible { outline: 3px solid rgba(238,93,50,.42); outline-offset: 3px; }
.video-card-preview { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: #252521; color: white; cursor: pointer; overflow: hidden; }
.video-card-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-grid:not(.is-multiple) .video-card-preview { aspect-ratio: 16 / 9; }
.video-play-icon { position: absolute; top: 50%; left: 50%; display: grid; width: 46px; height: 46px; place-items: center; transform: translate(-50%,-50%); border: 1px solid rgba(255,255,255,.45); border-radius: 999px; background: rgba(20,20,18,.56); color: white; font-size: 17px; line-height: 1; text-indent: 2px; backdrop-filter: blur(7px); box-shadow: 0 8px 24px rgba(0,0,0,.24); transition: transform .18s ease, background .18s ease; }
.video-card-preview:hover .video-play-icon { transform: translate(-50%,-50%) scale(1.08); background: rgba(238,93,50,.82); }

body.asset-modal-open { overflow: hidden; }
.asset-modal[hidden] { display: none; }
.asset-modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 24px; background: rgba(24,23,20,.3); backdrop-filter: blur(10px) saturate(.82); -webkit-backdrop-filter: blur(10px) saturate(.82); }
.asset-modal-panel { position: relative; width: clamp(720px,68vw,1120px); max-width: calc(100vw - 48px); height: min(86vh,900px); overflow: hidden; border: 1px solid rgba(255,255,255,.35); border-radius: 22px; background: #fffefa; box-shadow: 0 38px 110px rgba(0,0,0,.48); }
.asset-modal-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.asset-modal-close { position: absolute; top: 13px; right: 13px; z-index: 8; display: grid; width: 38px; height: 38px; place-items: center; padding: 0 0 3px; border: 1px solid rgba(255,255,255,.38); border-radius: 999px; background: rgba(24,23,20,.62); color: white; font: 300 27px/1 sans-serif; cursor: pointer; backdrop-filter: blur(10px); }
.asset-modal-close:hover { background: rgba(238,93,50,.9); }
.asset-carousel { position: relative; overflow: hidden; background: #1e1e1b; }
.asset-media-toolbar { position: absolute; top: 14px; left: 14px; z-index: 7; display: flex; align-items: center; gap: 8px; }
.asset-media-toolbar span, .asset-media-toolbar button { min-width: 42px; padding: 7px 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(22,22,19,.6); color: white; font-size: 11px; line-height: 1; backdrop-filter: blur(10px); }
.asset-media-toolbar span { text-align: center; }
.asset-media-toolbar button { cursor: pointer; }
.asset-media-toolbar button:hover { background: rgba(255,255,255,.2); }
.asset-media-viewport { width: 100%; aspect-ratio: 16 / 9; max-height: 57vh; overflow: hidden; }
.asset-media-track { display: flex; width: 100%; height: 100%; transition: transform .3s cubic-bezier(.22,.78,.28,1); will-change: transform; }
.asset-media-slide { position: relative; flex: 0 0 100%; width: 100%; height: 100%; overflow: hidden; background: #22221e; }
.asset-media-slide > img, .asset-media-slide > video { position: relative; z-index: 2; display: block; width: 100%; height: 100%; object-fit: contain; }
.asset-media-backdrop { position: absolute; inset: -28px; z-index: 0; background-position: center; background-size: cover; filter: blur(30px) brightness(.58) saturate(.8); transform: scale(1.08); opacity: 1; }
.asset-video-play { position: absolute; top: 50%; left: 50%; z-index: 4; display: grid; min-width: 104px; min-height: 104px; place-items: center; gap: 4px; transform: translate(-50%,-50%); padding: 17px; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; background: rgba(20,20,18,.58); color: white; cursor: pointer; backdrop-filter: blur(12px); box-shadow: 0 14px 40px rgba(0,0,0,.28); }
.asset-video-play span { font-size: 31px; line-height: 1; text-indent: 4px; }
.asset-video-play small { font-size: 10px; }
.asset-video-play:hover { background: rgba(238,93,50,.88); transform: translate(-50%,-50%) scale(1.05); }
.asset-video-play[hidden], .asset-video-poster[hidden] { display: none; }
.asset-carousel-nav { position: absolute; top: 50%; z-index: 6; display: grid; width: 44px; height: 66px; place-items: center; transform: translateY(-50%); padding: 0 0 5px; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; background: rgba(20,20,18,.48); color: white; font: 300 36px/1 sans-serif; cursor: pointer; backdrop-filter: blur(9px); }
.asset-carousel-nav:hover { background: rgba(20,20,18,.76); }
.asset-carousel-prev { left: 14px; }
.asset-carousel-next { right: 14px; }
.asset-carousel-nav[hidden] { display: none; }
.asset-modal-content { padding: 24px 28px 32px; }
.asset-modal-content .description { display: block; overflow: visible; font-size: 13px; }
.asset-modal-content .prompt { padding-right: 58px; }
.asset-modal-content .prompt p { max-height: none; overflow: visible; -webkit-mask-image: none; mask-image: none; }
.asset-modal-content details { padding: 12px 0 2px; }
.asset-modal-content details[open] summary { margin-bottom: 7px; }
.asset-modal-content .card-title-row h2 { font: 700 clamp(25px,3vw,38px)/1.15 Georgia,"Noto Serif SC",serif; }

@media (max-width: 760px) {
  .asset-modal { padding: 8px; }
  .asset-modal-panel { width: 100%; max-width: none; height: calc(100dvh - 16px); border-radius: 16px; }
  .asset-media-viewport { aspect-ratio: 4 / 3; max-height: 48vh; }
  .asset-modal-content { padding: 20px 17px 28px; }
  .asset-modal-close { top: 9px; right: 9px; }
  .asset-media-toolbar { top: 10px; left: 10px; }
  .asset-carousel-nav { width: 36px; height: 54px; }
  .asset-carousel-prev { left: 7px; }
  .asset-carousel-next { right: 7px; }
  .asset-video-play { min-width: 86px; min-height: 86px; }
}

@media (max-width: 1100px) {
  .simple-map-layout { grid-template-columns: 210px minmax(0, 1fr); }
  .toolbar-export { width: 100%; justify-content: flex-end; }
}
@media (max-width: 760px) {
  .simple-map-layout { grid-template-columns: 1fr; }
  .simple-map-titlebar { grid-template-columns: minmax(0, 1fr) auto; }
  .simple-map-titlebar .map-title-actions { grid-column: 1 / -1; }
  .simple-map-view-head .simple-map-titlebar { grid-template-columns: minmax(0, 1fr) auto; }
  .simple-map-titlebar .save-state { display: none; }
  .mindmap-toolbar { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .toolbar-group { flex: 0 0 auto; }
  .toolbar-export { width: auto; }
  .simple-map-canvas { height: 520px; }
}
