:root {
  --ink: #050605;
  --panel: rgba(22, 28, 24, 0.72);
  --panel-bright: rgba(37, 48, 40, 0.74);
  --line: rgba(222, 246, 223, 0.13);
  --text: #f2f6ef;
  --muted: #a3afa5;
  --mint: #9ee1bc;
  --leaf: #d5e86b;
  --coral: #ff8069;
}

* { box-sizing: border-box; }
body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;
  background:
    radial-gradient(circle at 88% 10%, rgba(127, 204, 138, 0.16), transparent 23rem),
    radial-gradient(circle at 6% 88%, rgba(230, 129, 90, 0.13), transparent 29rem),
    radial-gradient(circle at 50% 44%, #172019 0, #080a08 48%, var(--ink) 82%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image: radial-gradient(rgba(255,255,255,.55) .55px, transparent .72px);
  background-size: 23px 23px;
  mask-image: radial-gradient(ellipse at center, black, transparent 75%);
}
button, input, select, textarea { font: inherit; }
.auth-locked body { overflow: hidden; }
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text);
  background: rgba(0,0,0,.86);
  backdrop-filter: blur(24px);
}
.auth-gate.is-hidden { opacity: 0; pointer-events: none; transition: opacity .24s ease; }
.auth-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(42,54,45,.86), rgba(8,10,8,.96));
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.auth-eyebrow { margin: 0 0 10px; color: var(--mint); font-size: .72rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.auth-card h1 { margin: 0; font-size: clamp(1.8rem, 6vw, 2.6rem); letter-spacing: -.06em; }
.auth-copy { margin: 10px 0 22px; color: var(--muted); line-height: 1.45; }
.auth-card button { width: 100%; border: 0; border-radius: 999px; padding: 13px 18px; color: #050505; background: #f5f5f7; font-weight: 900; cursor: pointer; }
.auth-status { min-height: 1.2em; margin: 14px 0 0; color: var(--leaf); font-size: .82rem; }
.library-shell { position: relative; width: min(1420px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 52px; }
.library-header { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; align-items: center; padding: 14px 4px 24px; }
.back-link { color: var(--mint); font-size: .86rem; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
.eyebrow, .panel-kicker { margin: 0 0 9px; color: #9fdfb9; font-size: .64rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.category-form button { border: 1px solid rgba(213,232,107,.45); border-radius: 999px; padding: 12px 17px; color: #11170b; background: var(--leaf); box-shadow: 0 0 32px rgba(213,232,107,.18); cursor: pointer; font-size: .75rem; font-weight: 900; }
.library-intro { display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: center; margin-bottom: 22px; padding: 17px 20px; border: 1px solid var(--line); border-radius: 22px; background: rgba(18,23,20,.62); box-shadow: inset 0 1px rgba(255,255,255,.05); backdrop-filter: blur(18px); }
.library-intro > p { margin: 0; max-width: 48rem; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.category-form { display: flex; gap: 8px; }
.category-form input, .category-form select, #rag-context { border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; color: var(--text); outline: none; background: rgba(255,255,255,.06); }
.category-form input:focus, .category-form select:focus, #rag-context:focus { border-color: rgba(158,225,188,.65); box-shadow: 0 0 0 3px rgba(158,225,188,.1); }
.category-form input, .category-form select { min-width: 135px; }
.library-grid { display: grid; grid-template-columns: minmax(260px, .76fr) minmax(0, 2fr); gap: 22px; }
.category-panel, .asset-panel { border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(140deg, rgba(42,54,45,.66), rgba(12,15,13,.82)); box-shadow: inset 0 1px rgba(255,255,255,.06), 0 26px 70px rgba(0,0,0,.22); backdrop-filter: blur(20px); }
.category-panel { max-height: calc(100dvh - 250px); overflow: auto; padding: 22px 13px; scrollbar-color: rgba(158,225,188,.4) transparent; }
.category-row { display: flex; align-items: center; gap: 4px; padding-left: calc(var(--depth) * 16px); }
.category-row > button:first-child { flex: 1; border: 0; border-radius: 11px; padding: 9px 10px; color: #d8e5d8; background: transparent; text-align: left; cursor: pointer; font-size: .8rem; }
.category-row > button:first-child:hover { background: rgba(158,225,188,.09); }
.category-row.is-selected > button:first-child { color: #071009; background: linear-gradient(100deg, #a9ebc5, #d5e86b); font-weight: 900; }
.tree-file { display: block; padding: 5px 8px 5px calc(var(--depth) * 16px + 10px); overflow: hidden; color: #84988a; font-size: .66rem; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.tree-file:hover { color: var(--mint); text-decoration: underline; }
.remove-category, .remove-asset { border: 0; color: #ff9987; background: transparent; cursor: pointer; font-size: .65rem; }
.asset-panel { min-height: 650px; padding: 25px; }
.asset-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.asset-panel h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.45rem); letter-spacing: -.06em; }
.file-picker { border: 1px solid rgba(158,225,188,.45); border-radius: 999px; padding: 9px 13px; color: var(--mint); background: rgba(158,225,188,.06); cursor: pointer; font-size: .73rem; font-weight: 800; }
.file-picker:hover { background: rgba(158,225,188,.15); }
.file-picker input { display: none; }
.drop-zone { position: relative; display: grid; place-content: center; min-height: 168px; margin: 24px 0 17px; overflow: hidden; border: 1px dashed rgba(158,225,188,.52); border-radius: 24px; color: var(--mint); background: radial-gradient(circle at center, rgba(158,225,188,.14), transparent 66%); text-align: center; cursor: pointer; transition: background .2s, border-color .2s, transform .2s; }
.drop-zone::before { content: "+"; display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 9px; border: 1px solid rgba(213,232,107,.52); border-radius: 50%; color: var(--leaf); font-size: 1.3rem; }
.drop-zone strong { font-size: .93rem; }
.drop-zone span { margin-top: 7px; color: var(--muted); font-size: .68rem; }
.drop-zone.is-dragging { border-color: var(--leaf); background: radial-gradient(circle at center, rgba(213,232,107,.26), transparent 69%); transform: scale(1.008); }
.rag-context-label { display: block; margin: 0 0 7px; color: #a6dabb; font-size: .7rem; font-weight: 800; }
#rag-context { display: block; width: 100%; min-height: 82px; margin-bottom: 22px; resize: vertical; font-size: .8rem; line-height: 1.45; }
#rag-context::placeholder { color: #738077; }
.upload-save-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -6px 0 24px; }
.upload-save-row p { display: grid; gap: 3px; margin: 0; color: var(--muted); font-size: .72rem; }
#upload-destination { color: var(--mint); font-size: .68rem; font-weight: 800; }
.upload-save-row button { border: 1px solid rgba(213,232,107,.45); border-radius: 999px; padding: 10px 15px; color: #11170b; background: var(--leaf); box-shadow: 0 0 22px rgba(213,232,107,.14); cursor: pointer; font-size: .73rem; font-weight: 900; }
.upload-save-row button:disabled { cursor: not-allowed; opacity: .36; box-shadow: none; }
.pending-upload-list { display: flex; flex-wrap: wrap; gap: 7px; margin: -12px 0 24px; padding: 0; list-style: none; }
.pending-upload-list li { max-width: 100%; overflow: hidden; border: 1px solid rgba(158,225,188,.28); border-radius: 999px; padding: 5px 9px; color: var(--mint); background: rgba(158,225,188,.07); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.pending-upload-list li.is-image-preview,
.pending-upload-list li.is-video-preview { display: grid; align-items: end; width: 112px; height: 64px; border-radius: 11px; padding: 6px; color: white; background-color: #26332a; background-position: center; background-size: cover; box-shadow: inset 0 -30px 25px rgba(0,0,0,.58); }
.pending-upload-list li.is-video-preview { border-radius: 16px; background-image: radial-gradient(circle at 50% 42%, rgba(255,255,255,.22), transparent 28%), linear-gradient(135deg, rgba(213,232,107,.24), rgba(25,43,34,.85)); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; }
.asset-card { position: relative; min-height: 278px; padding: 14px; overflow: hidden; border: 1px solid rgba(255,255,255,.08); border-radius: 23px; background: linear-gradient(155deg, rgba(255,255,255,.09), rgba(255,255,255,.025)); box-shadow: inset 0 1px rgba(255,255,255,.07), 0 13px 30px rgba(0,0,0,.18); }
.asset-card::after { content: ""; position: absolute; inset: auto -25% -45% 20%; height: 70%; border-radius: 50%; background: radial-gradient(circle, rgba(158,225,188,.14), transparent 66%); pointer-events: none; }
.asset-media { position: relative; z-index: 1; display: grid; place-items: center; width: 116px; height: 116px; margin: 3px auto 17px; overflow: hidden; border: 1px solid rgba(213,232,107,.52); border-radius: 50%; color: white; background: conic-gradient(from 30deg, #537e61, #173e31, #b6964f, #537e61); background-position: center; background-size: cover; box-shadow: inset 0 4px 13px rgba(255,255,255,.22), inset 0 -16px 24px rgba(0,0,0,.34), 0 0 34px rgba(158,225,188,.18); text-decoration: none; cursor: pointer; font-size: .78rem; font-weight: 900; }
.asset-document .asset-media { border-color: rgba(255,128,105,.62); background: conic-gradient(from 30deg, #e57961, #792f34, #ba8c5d, #e57961); }
.asset-document .asset-media.has-document-preview { width: 100%; height: 124px; border-radius: 14px; background-color: #f5f5f1; background-repeat: no-repeat; background-size: cover; box-shadow: 0 11px 24px rgba(0,0,0,.28); }
.media-icon { position: absolute; top: 8px; left: 8px; display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; color: white; background: rgba(0,0,0,.46); backdrop-filter: blur(5px); }
.media-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.play-mark { padding: 8px 10px; border-radius: 999px; background: rgba(0,0,0,.46); backdrop-filter: blur(4px); }
.asset-info { position: relative; z-index: 1; }
.asset-info p { margin: 0 0 5px; color: #9fdfb9; font-size: .61rem; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.asset-info h3 { margin: 0 0 7px; font-size: .88rem; line-height: 1.12; }
.asset-info small { color: var(--muted); font-size: .67rem; }
.asset-card .remove-asset { position: absolute; z-index: 2; top: 11px; right: 10px; }
.asset-move { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr auto; gap: 5px; margin-top: 13px; }
.asset-move select { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px; color: var(--text); background: rgba(0,0,0,.24); font-size: .64rem; }
.asset-move button { border: 1px solid rgba(158,225,188,.38); border-radius: 8px; padding: 5px 7px; color: var(--mint); background: rgba(158,225,188,.08); cursor: pointer; font-size: .63rem; font-weight: 800; }
.asset-context { position: relative; z-index: 2; margin-top: 9px; color: var(--muted); font-size: .64rem; }
.asset-context summary { cursor: pointer; color: #b6c7b7; }
.asset-context textarea { width: 100%; min-height: 64px; margin-top: 7px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 6px; color: var(--text); background: rgba(0,0,0,.22); font: inherit; }
.asset-context button { margin-top: 5px; border: 0; border-radius: 7px; padding: 5px 7px; color: #11170b; background: var(--leaf); cursor: pointer; font-size: .61rem; font-weight: 900; }
.empty-state { color: var(--muted); font-size: .93rem; }
.video-dialog { width: min(800px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 25px; padding: 20px; color: var(--text); background: #111713; box-shadow: 0 24px 80px rgba(0,0,0,.5); }
.video-dialog::backdrop { background: rgba(2,5,3,.8); backdrop-filter: blur(8px); }
.video-dialog video { width: 100%; border-radius: 15px; background: #000; }
.video-dialog h2 { margin: 15px 0 8px; font-size: 1.3rem; }
.video-dialog p { max-height: 140px; overflow: auto; color: var(--muted); line-height: 1.5; }
.dialog-close { float: right; margin-bottom: 8px; border: 0; color: #ff9987; background: none; cursor: pointer; }

@media (max-width: 820px) {
  .library-shell { width: min(100% - 22px, 680px); padding-top: 18px; }
  .library-header, .library-intro, .library-grid { grid-template-columns: 1fr; }
  .library-header { padding-bottom: 28px; }
  .category-form { flex-wrap: wrap; }
  .category-form input, .category-form select { flex: 1 1 135px; }
  .category-panel { max-height: 330px; }
  .asset-panel { min-height: 500px; padding: 18px; }
}
