:root {
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bg: #09090d;
  --bg2: #0f1018;
  --bg3: #14161e;
  --bg4: #1a1c28;
  --border: rgba(255, 255, 255, 0.06);
  --border2: rgba(255, 255, 255, 0.12);
  --gold: #c9a84c;
  --gold-dim: rgba(201, 168, 76, 0.14);
  --text: #e4e6f0;
  --text2: #9298b0;
  --text3: #5a607a;
  --error: #ff4f6d;
  --radius: 10px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.mp-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 12px 20px;
  background: rgba(9, 9, 13, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.mp-brand { display: flex; align-items: center; gap: 12px; }
.mp-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #8a6f2e);
  color: #0d0d0d;
  font-weight: 700;
  font-size: 12px;
}
.mp-title { font-weight: 600; font-size: 15px; }
.mp-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.mp-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.mp-search {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  min-width: 140px;
}
.mp-search { min-width: 200px; flex: 1; max-width: 280px; }
.mp-search:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold-dim);
}
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg4);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.mp-btn:hover:not(:disabled) {
  background: var(--gold-dim);
  border-color: var(--gold);
}
.mp-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mp-btn--ghost { background: transparent; border-color: var(--border); }
.mp-btn--sm { padding: 5px 10px; font-size: 12px; }

.mp-main { max-width: 1600px; margin: 0 auto; padding: 16px 20px 32px; }
.mp-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  font-size: 13px;
}
.mp-crumb {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.mp-crumb:hover { background: var(--gold-dim); }
.mp-crumb--cur { color: var(--text2); cursor: default; }
.mp-crumb-sep { color: var(--text3); user-select: none; }

.mp-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}
.mp-folders {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: calc(100vh - var(--header-h) - 120px);
  overflow-y: auto;
  position: sticky;
  top: calc(var(--header-h) + 12px);
}
.mp-aside-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 8px;
}
.mp-folder-list { list-style: none; }
.mp-folder-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.mp-folder-item:hover { background: var(--bg4); }
.mp-folder-n {
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 999px;
}
.mp-folder-empty { color: var(--text3); font-size: 13px; padding: 8px; }

.mp-gallery {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}
.mp-gallery-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.mp-gallery-head h2 { font-size: 16px; font-weight: 600; }
.mp-count { font-size: 12px; color: var(--text2); }
.mp-status { color: var(--text2); padding: 8px 0; font-size: 13px; }
.mp-status--err { color: var(--error); }
.mp-empty { color: var(--text3); padding: 24px; text-align: center; }

.mp-list { display: flex; flex-direction: column; gap: 8px; }
.mp-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.mp-item:hover {
  border-color: var(--gold-dim);
  background: var(--bg4);
}
.mp-item-thumb-wrap {
  display: block;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}
.mp-item-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  background: var(--bg2);
}
.mp-item-thumb-wrap--doc {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg4);
}
.mp-item-doc-icon { font-size: 28px; line-height: 1; }
.mp-item-body { min-width: 0; }
.mp-item-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
  line-height: 1.3;
}
.mp-item-path {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
  word-break: break-all;
  line-height: 1.35;
}
.mp-item-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mp-item-url {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-item-url:hover { text-decoration: underline; color: var(--gold2, #e8c96a); }
.mp-btn--copy { flex-shrink: 0; }

.mp-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}

.mp-detail {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: min(420px, 100vw);
  height: calc(100vh - var(--header-h));
  background: var(--bg2);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  z-index: 30;
  overflow-y: auto;
  padding: 16px;
}
.mp-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
}
.mp-detail-close:hover { background: var(--bg4); }
.mp-detail-img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--bg4);
}
.mp-detail-name { font-size: 16px; margin-bottom: 6px; padding-right: 36px; }
.mp-detail-meta { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
.mp-detail-note {
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
}
.mp-detail-note pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
  font-family: inherit;
  color: var(--text2);
}
.mp-detail-field { margin-bottom: 12px; }
.mp-detail-field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin-bottom: 6px;
}
.mp-field-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.mp-field-row input,
.mp-field-row textarea {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  padding: 8px 10px;
  font-size: 12px;
  resize: vertical;
}
.mp-detail-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.mp-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg4);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.mp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 1100px) {
  .mp-layout {
    grid-template-columns: 220px 1fr;
  }
  .mp-detail:not([hidden]) ~ .mp-main .mp-layout,
  body:has(.mp-detail:not([hidden])) .mp-layout {
    /* panel fixed — gallery full width */
  }
}

@media (max-width: 900px) {
  .mp-layout { grid-template-columns: 1fr; }
  .mp-folders {
    position: static;
    max-height: 200px;
  }
  .mp-detail {
    width: 100%;
    top: auto;
    bottom: 0;
    height: 70vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
}

@media (max-width: 700px) {
  .mp-item { grid-template-columns: 56px 1fr; gap: 10px; padding: 10px 12px; }
  .mp-item-thumb { width: 56px; height: 56px; }
  .mp-item-url-row { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .mp-header { padding: 10px 12px; }
  .mp-header-actions { width: 100%; }
  .mp-search { max-width: none; flex: 1 1 100%; }
  .mp-main { padding: 12px; }
}
