/* Muninn web — a quiet, warm-dark archive. Serif wordmark, amber raven-eye
   accent, hairline borders; the media does the talking. */

:root {
  --bg: #0d0c0a;
  --bg-raised: #14120e;
  --bg-hover: #1b1813;
  --line: #262219;
  --line-strong: #3a342a;
  --ink: #e8e2d3;
  --ink-dim: #938a76;
  --ink-faint: #5e5748;
  --amber: #d9a441;
  --amber-soft: rgba(217, 164, 65, 0.14);
  --danger: #c96a5b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: Seravek, "Avenir Next", Avenir, "Gill Sans", "Trebuchet MS", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(217, 164, 65, 0.05), transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
input { font: inherit; }
[hidden] { display: none !important; }

::selection { background: var(--amber-soft); }

/* ---------- login ---------- */

#login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 50% 20%, rgba(217, 164, 65, 0.06), transparent 65%),
    var(--bg);
}
.login-card {
  width: min(360px, 88vw);
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.login-mark { width: 72px; height: 72px; }
.login-card h1 {
  font-family: var(--serif);
  font-size: 44px; font-weight: 400; letter-spacing: 0.02em;
  margin: 4px 0 6px;
}
.login-sub { color: var(--ink-dim); font-size: 13px; margin: 0 0 28px; }
#loginForm { display: grid; gap: 10px; }
#loginForm input {
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 12px 14px;
  text-align: center;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.2s;
}
#loginForm input:focus { border-color: var(--amber); }
#loginForm button {
  background: var(--amber);
  color: #191305;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: filter 0.15s;
}
#loginForm button:hover { filter: brightness(1.08); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 14px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- shell ---------- */

#app { display: flex; min-height: 100vh; }

#sidebar {
  position: sticky; top: 0;
  width: 232px; flex: 0 0 232px;
  height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(13, 12, 10, 0.6);
  padding: 18px 14px;
  gap: 14px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 8px;
}
.brand svg { width: 34px; height: 34px; }
.brand span {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 0.02em;
}

#searchForm input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}
#searchForm input:focus { border-color: var(--amber); }
#searchForm input::placeholder { color: var(--ink-faint); }

#nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-dim);
  transition: background 0.15s, color 0.15s;
}
#nav a:hover { background: var(--bg-hover); color: var(--ink); }
#nav a.active { background: var(--amber-soft); color: var(--amber); }
.nav-ic { display: inline-flex; width: 17px; height: 17px; }
.nav-ic svg { width: 100%; height: 100%; }
.nav-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.side-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.linkish { color: var(--ink-faint); font-size: 13px; padding: 4px 10px; }
.linkish:hover { color: var(--ink-dim); }

#main { flex: 1; min-width: 0; padding: 26px 30px 80px; }

/* ---------- view header ---------- */

.view-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin: 0 0 18px; }
.view-head h2 {
  font-family: var(--serif);
  font-size: 30px; font-weight: 400;
  margin: 0;
}
.view-head .count { color: var(--ink-faint); font-size: 13px; }
.view-head .spacer { flex: 1; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; font-size: 13px; color: var(--ink-dim); }
.crumbs a:hover { color: var(--amber); }
.crumbs .sep { color: var(--ink-faint); }

/* chips + controls */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  padding: 4px 13px;
  font-size: 13px;
  color: var(--ink-dim);
  transition: all 0.15s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.chip.on { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }

select.ctl {
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-dim);
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
}

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  color: var(--ink-dim);
  transition: all 0.15s;
}
.iconbtn:hover { background: var(--bg-hover); color: var(--ink); }
.iconbtn.on { color: var(--amber); }
.iconbtn svg { width: 19px; height: 19px; }

/* ---------- grids ---------- */

.section-label {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 26px 0 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.18s, box-shadow 0.18s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.card .ph {
  aspect-ratio: 1;
  display: block;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.card img {
  position: relative; /* paint above the absolutely-positioned kind glyph */
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.card img.ok { opacity: 1; }
.card .ph .glyph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint);
}
.card .ph .glyph svg { width: 34%; height: 34%; }

.badge {
  position: absolute; right: 7px; bottom: 7px;
  background: rgba(10, 9, 7, 0.72);
  backdrop-filter: blur(3px);
  color: var(--ink);
  border-radius: 6px;
  font: 11px/1 var(--mono);
  padding: 4px 6px;
  letter-spacing: 0.03em;
}
.fav-dot {
  position: absolute; left: 7px; top: 7px;
  color: var(--amber);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.fav-dot svg { width: 15px; height: 15px; }

.card .cap {
  padding: 8px 10px;
  font-size: 12.5px;
  border-top: 1px solid var(--line);
}
.card .cap .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cap .s { color: var(--ink-faint); font-size: 11.5px; }

/* dir card variant: caption always shown */
.card.dir .ph { aspect-ratio: 16/10; }

.empty {
  color: var(--ink-faint);
  text-align: center;
  padding: 80px 0;
  font-family: var(--serif);
  font-size: 18px;
}
.more-sentinel { height: 1px; }
.loading { color: var(--ink-faint); text-align: center; padding: 30px; font-size: 13px; }

/* ---------- trash rows ---------- */

.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.row .thumb {
  width: 56px; height: 56px; flex: 0 0 56px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint);
  cursor: pointer;
}
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .thumb svg { width: 22px; height: 22px; }
.row .body { flex: 1; min-width: 0; }
.row .body .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .body .s { color: var(--ink-faint); font-size: 12.5px; }
.row .acts { display: flex; gap: 6px; }
.btn {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--ink-dim);
  transition: all 0.15s;
}
.btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn.warm { color: var(--amber); border-color: rgba(217, 164, 65, 0.4); }
.btn.warm:hover { background: var(--amber-soft); }
.btn.danger { color: var(--danger); border-color: rgba(201, 106, 91, 0.35); }
.btn.danger:hover { background: rgba(201, 106, 91, 0.12); }

/* ---------- viewer ---------- */

#viewer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8, 7, 5, 0.97);
  display: flex; flex-direction: column;
  animation: vfade 0.18s ease both;
}
@keyframes vfade { from { opacity: 0; } to { opacity: 1; } }

.v-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
  background: linear-gradient(rgba(8, 7, 5, 0.85), transparent);
}
.v-title {
  flex: 1; min-width: 0;
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-dim);
}
.v-top .iconbtn { color: var(--ink-dim); }
.v-top .iconbtn:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.v-top .iconbtn.on { color: var(--amber); }

.v-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.v-stage img, .v-stage video {
  max-width: 100vw; max-height: 100vh;
  object-fit: contain;
  outline: none;
}
.v-stage video { width: 100vw; height: 100vh; }
/* controlslist=nofullscreen only grays the native fullscreen button out in
   Chrome — remove it entirely; the viewer owns fullscreen (F / ⛶ / dblclick). */
.v-stage video::-webkit-media-controls-fullscreen-button { display: none; }

.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 46px; height: 74px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
  background: rgba(10, 9, 7, 0.4);
  border-radius: 10px;
  transition: all 0.15s;
  opacity: 0.65;
}
.v-nav:hover { opacity: 1; color: var(--ink); background: rgba(20, 18, 14, 0.75); }
.v-nav svg { width: 26px; height: 26px; }
.v-nav.prev { left: 14px; }
.v-nav.next { right: 14px; }
.v-nav[disabled] { opacity: 0.12; pointer-events: none; }

.v-spin {
  position: absolute; z-index: 1;
  width: 34px; height: 34px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.v-info {
  position: absolute; right: 14px; top: 60px; z-index: 4;
  width: min(320px, calc(100vw - 28px));
  background: rgba(18, 16, 12, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 13px;
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.v-info h3 {
  font-family: var(--serif); font-weight: 400;
  font-size: 17px; margin: 0 0 10px;
  word-break: break-all;
}
.v-info dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.v-info dt { color: var(--ink-faint); }
.v-info dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12px; }
.v-info .toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
}

.v-osd {
  position: absolute; left: 50%; bottom: 96px; z-index: 5;
  transform: translateX(-50%);
  background: rgba(10, 9, 7, 0.82);
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  padding: 6px 15px;
  font: 12px var(--mono);
  letter-spacing: 0.05em;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.v-osd.show { opacity: 1; }

/* ---------- selection ---------- */

body.selecting .card { cursor: copy; }
.card.selected {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber), 0 10px 28px rgba(0, 0, 0, 0.45);
}
.card.selected::after {
  content: '✓';
  position: absolute; right: 7px; top: 7px; z-index: 2;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--amber);
  color: #191305;
  font-size: 13px; font-weight: 700;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.row.selected { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.rows.picking .row { cursor: copy; }

#selbar {
  position: fixed; left: 50%; bottom: 22px; z-index: 35;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(24, 21, 16, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  width: min(560px, calc(100vw - 32px));
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.sel-count { font-size: 14px; white-space: nowrap; }
#selbar .btn[disabled] { opacity: 0.35; pointer-events: none; }

/* ---------- context menu ---------- */

#ctxmenu {
  position: fixed; z-index: 45;
  min-width: 210px;
  background: rgba(22, 19, 15, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  animation: vfade 0.12s ease both;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(201, 106, 91, 0.12); }
.ctx-ic { display: inline-flex; width: 16px; height: 16px; flex: 0 0 16px; }
.ctx-ic svg { width: 100%; height: 100%; }
.ctx-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------- modals ---------- */

#modal {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(8, 7, 5, 0.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
  animation: vfade 0.15s ease both;
}
.m-card {
  width: min(440px, calc(100vw - 36px));
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 20px 22px;
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.m-card h3 {
  font-family: var(--serif); font-weight: 400;
  font-size: 20px; margin: 0 0 14px;
  overflow-wrap: break-word;
}
.m-body { color: var(--ink-dim); font-size: 13.5px; margin: 0 0 14px; }
.m-err { color: var(--danger); }
.m-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  padding: 9px 12px;
  outline: none;
}
.m-input:focus { border-color: var(--amber); }
.m-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.m-cliprow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.m-cliprow .m-input { flex: 1; font-family: var(--mono); font-size: 13px; }
.m-cliplabel { width: 42px; color: var(--ink-dim); font-size: 13px; }

/* folder picker */
.m-picker { width: min(520px, calc(100vw - 36px)); }
.m-crumb {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12.5px; color: var(--ink-dim);
  margin-bottom: 10px;
}
.m-crumb a { cursor: pointer; }
.m-crumb a:hover { color: var(--amber); }
.m-crumb .sep { color: var(--ink-faint); }
.m-list {
  max-height: 44vh; overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.m-list-label {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
  padding: 8px 10px 2px;
}
.m-entry {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--ink);
}
.m-entry:hover { background: var(--bg-hover); }
.m-entry-ic { display: inline-flex; width: 17px; height: 17px; flex: 0 0 17px; color: var(--ink-dim); }
.m-entry-ic svg { width: 100%; height: 100%; }
.m-entry-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-entry-t .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.m-entry-t .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--ink-faint); }
.m-entry-go { display: inline-flex; width: 14px; height: 14px; color: var(--ink-faint); }
.m-entry-go svg { width: 100%; height: 100%; }
.m-newrow { display: flex; gap: 8px; padding: 6px; }
.m-newrow .m-input { flex: 1; }
.m-actions .btn[disabled] { opacity: 0.35; pointer-events: none; }

/* ---------- duplicates ---------- */

.dup-groups { display: flex; flex-direction: column; gap: 22px; }
.dup-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(20, 18, 14, 0.4); }
.dup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13.5px; color: var(--ink-dim); }
.dup-row { cursor: default; }
.dup-row input[type='radio'] { accent-color: var(--amber); width: 16px; height: 16px; flex: 0 0 16px; }
.dup-fav { color: var(--amber); }

/* ---------- progress (re-encode) ---------- */

.progress {
  height: 5px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 7px;
}
.progress-fill {
  height: 100%;
  background: var(--amber);
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ---------- viewer info actions ---------- */

.v-info-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.v-act { display: flex; align-items: center; gap: 8px; justify-content: flex-start; }

/* ---------- sidebar footer ---------- */

.scan-line { color: var(--ink-faint); font-size: 11.5px; padding: 0 10px 6px; font-family: var(--mono); }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: rgba(24, 21, 16, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  animation: rise 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  max-width: min(520px, calc(100vw - 40px));
}
#toast .msg { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toast button.undo {
  color: var(--amber); font-weight: 600; font-size: 14px;
  flex: 0 0 auto;
}

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar {
    position: static;
    width: auto; flex: none; height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  #main { padding: 18px 14px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
}
