:root {
  --side-bg: #f3f5f7;
  --side-w: 272px;
  --surface: #ffffff;
  --ink: #1a2129;
  --muted: #6b7682;
  --line: #e2e7ec;
  --hover: #e8ecf0;
  --active: #dfe5ea;
  --accent: #0e6b5c;
  --accent-soft: #e3f0ec;
  --danger: #a1302a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  display: flex;
  background: var(--surface);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- Sidebar ---------- */

.side {
  width: var(--side-w);
  flex: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
}

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 10px 6px 10px;
}

/* Section menu */

.menu { position: relative; flex: 1; min-width: 0; }

.menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--hover); }
.menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.brand { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.menu-section { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-section::before { content: '/'; margin-right: 6px; color: var(--line); }
.menu-chevron { margin-left: auto; color: var(--muted); line-height: 0.6; }

.menu-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(26, 33, 41, 0.12);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover { background: var(--hover); }
.menu-item[aria-selected="true"] { font-weight: 600; color: var(--accent); }

/* Add buttons */

.adds { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px 10px; }

.add {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.add:hover { background: var(--hover); }
.add:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.add-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 600;
  line-height: 1;
}

/* Lists */

.history { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }

.history-title { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); }

.items { list-style: none; margin: 0; padding: 0; }

.item-row { position: relative; }

.item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 34px 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.item:hover, .item-row:hover .item { background: var(--hover); }
.item[aria-current="true"] { background: var(--active); font-weight: 500; }
.item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.item-soon { font-size: 11px; color: var(--muted); }

/* Delete: appears on hover of the row */
.item-del {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.item-row:hover .item-del, .item-del:focus-visible { opacity: 1; }
.item-del:hover { background: var(--surface); color: var(--danger); }
.item-del svg { width: 15px; height: 15px; }

.history-empty { margin: 4px 10px; color: var(--muted); }

.side-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.status { margin: 0 0 4px; min-height: 1.4em; font-size: 12px; color: var(--muted); }
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--accent); }
.who { margin: 0; font-size: 12px; color: var(--muted); }
.who a { color: inherit; }

/* ---------- Main ---------- */

.main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-actions { display: flex; gap: 6px; }

.btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
}
.btn:hover { background: var(--side-bg); }
.btn[aria-expanded="true"] { background: var(--active); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.icon-btn {
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 7px;
  background: transparent; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--hover); }

/* Versions drawer */

.versions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 12px 16px 16px;
  background: var(--side-bg);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  max-height: 40vh;
  overflow-y: auto;
}
.versions h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.versions ul { list-style: none; margin: 0; padding: 0; }
.versions li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
.versions li:first-child { border-top: 0; }
.versions .v-label { flex: 1; }
.versions .v-when { color: var(--muted); }
.versions .v-open { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.versions .v-open[disabled] { color: var(--muted); text-decoration: none; cursor: default; }
.versions .note { margin: 0; color: var(--muted); }
.versions .files { display: flex; flex-direction: column; gap: 10px; }
.versions .file h4 { margin: 0 0 2px; font-size: 13px; font-weight: 500; }

/* Viewer */

.viewer { flex: 1; position: relative; min-height: 0; }
#frame { width: 100%; height: 100%; border: 0; display: block; background: var(--surface); }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}
.empty-title { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.empty-hint { margin: 0; color: var(--muted); max-width: 52ch; }

/* Drop veil */

.dropveil {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(14, 107, 92, 0.08);
  pointer-events: none;
}
.dropveil-box {
  padding: 18px 28px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Collapsible sidebar ---------- */

body.side-collapsed .side { display: none; }

@media (max-width: 720px) {
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    display: none;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.3);
  }
  body.side-open .side { display: flex; }
  .versions { grid-template-columns: 1fr; }
}