:root {
  --ink: #031D44;
  --muted: #4A5568;
  --paper: #F7F5EF;
  --surface: #ffffff;
  --accent: #8B1E2D;
  --accent-soft: #F3E6E8;
  --line: #E2D8D0;
  --danger: #a33b3b;
  --ok: #2f6b4f;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 10px 28px -18px rgba(23, 16, 20, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(3, 29, 68, 0.10), transparent 60%),
    var(--paper);
  line-height: 1.45;
}

.top, .tabs, main {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px 24px;
  align-items: center;
  padding: 16px 0 12px;
  flex-wrap: wrap;
}

.top-brand {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.top-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}
.top-hint a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.top-hint a:hover { text-decoration: underline; }
.top-hint-sep { color: var(--line); font-weight: 700; }

.top-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 12px;
  margin-left: auto;
}

.top-session {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 10px;
}

h1 {
  font-size: clamp(1.25rem, 2.4vw, 1.45rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h2 { font-size: 1.15rem; font-weight: 650; }

.lede { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }

.who {
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  max-width: min(100%, 280px);
}
.status[hidden] { display: none !important; }
.status.is-err { color: var(--danger); }

/* Light variant of EcoScrap footer “Built by” badge — compact header size */
.built-by {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  border-radius: 999px;
  padding: 1px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 28%, white),
    color-mix(in srgb, var(--line) 80%, white),
    color-mix(in srgb, var(--accent) 12%, white)
  );
  flex-shrink: 0;
  overflow: hidden;
  isolation: isolate;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    background 0.3s ease;
}
.built-by::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 38%,
    color-mix(in srgb, var(--accent) 18%, transparent) 50%,
    transparent 62%
  );
  transform: translateX(-130%);
  transition: transform 0.65s ease;
  pointer-events: none;
  z-index: 2;
}
.built-by:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -12px rgba(23, 16, 20, 0.35);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 40%, white),
    color-mix(in srgb, var(--accent) 18%, white),
    color-mix(in srgb, var(--line) 70%, white)
  );
  color: var(--ink);
}
.built-by:hover::after { transform: translateX(130%); }
.built-by-inner {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--surface);
}
.built-by-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.25s ease;
}
.built-by:hover .built-by-label { color: var(--accent); }
.built-by-divider {
  width: 1px;
  height: 11px;
  flex-shrink: 0;
  background: linear-gradient(180deg, transparent, var(--line), transparent);
}
.built-by-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.built-by-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, white);
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}
.built-by:hover .built-by-icon {
  transform: scale(1.06) rotate(-3deg);
  border-color: color-mix(in srgb, var(--accent) 45%, white);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 20%, transparent);
}
.built-by-icon svg { display: block; }
.built-by-name {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
.built-by-arrow {
  font-size: 0.68rem;
  line-height: 1;
  opacity: 0;
  transform: translate(-4px, 4px);
  color: var(--accent);
  margin-left: -2px;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.built-by:hover .built-by-arrow {
  opacity: 0.95;
  transform: translate(0, 0);
}

.logout {
  padding: 6px 12px;
  font-size: 0.82rem;
}

@media (max-width: 720px) {
  .top { align-items: flex-start; }
  .top-meta {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
  .top-session { justify-content: flex-start; }
  .who { max-width: min(100%, 260px); }
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.file-hint {
  font-size: 0.85rem;
  font-weight: 560;
  color: var(--ink);
  margin-top: -4px;
}
.file-hint[hidden] { display: none !important; }

.logout, .btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
}

.logout {
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface);
}
.logout:hover { color: var(--ink); border-color: var(--accent); }

.btn { background: var(--ink); color: #fff; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn.danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, white);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 650;
}

.panel { display: none; padding-bottom: 56px; }
.panel.is-active { display: block; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.album-head { align-items: center; }
.album-titles { flex: 1; min-width: 180px; }

.card-form {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-form label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.card-form input,
.card-form textarea,
.card-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 420;
  color: var(--ink);
  background: #fff;
}
.card-form textarea { resize: vertical; min-height: 72px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.add-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.edit-folder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.edit-folder summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.edit-folder summary::-webkit-details-marker { display: none; }
.edit-folder[open] summary { margin-bottom: 10px; color: var(--ink); }
.edit-folder .card-form { box-shadow: none; margin: 0; border: 0; padding: 0; }

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

.folder-card {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  text-align: left;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.25s ease;
}
.folder-card.is-flash {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 55%, white);
}
.folder-card .actions-row .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}
.folder-card .body .pos-badge {
  margin-bottom: 8px;
}

.order-hint { margin-top: 6px; font-size: 0.88rem; }

.media-tile {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  text-align: left;
  position: relative;
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, background 0.25s ease;
}
.media-tile.is-flash {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 55%, white);
}
.media-tile .thumb {
  aspect-ratio: 1;
  background: var(--accent-soft);
  overflow: hidden;
  position: relative;
}
.media-tile .pos-chip {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  padding: 3px 7px;
}
.media-tile .tile-tools .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}
.folder-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 45%, white);
}
.folder-card .cover {
  aspect-ratio: 4 / 3;
  background: var(--accent-soft);
  overflow: hidden;
}
.folder-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.folder-card .cover.ph {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.folder-card .body { padding: 12px 14px 14px; }
.folder-card .body h3 { font-size: 1.05rem; margin-bottom: 2px; }
.folder-card .body p { color: var(--muted); font-size: 0.88rem; }
.folder-card .actions-row {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}
.folder-card .actions-row .btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.8rem;
}

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

.media-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-tile .cap {
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 2.2em;
}
.media-tile .play {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(184, 77, 122, 0.92);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  pointer-events: none;
}
.media-tile .tile-tools {
  display: flex;
  gap: 4px;
  padding: 0 8px 8px;
}
.media-tile .tile-tools .btn {
  flex: 1;
  padding: 5px;
  font-size: 0.72rem;
}

.doc-list {
  display: grid;
  gap: 10px;
}

.doc-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, background 0.25s ease;
}
.doc-card.is-flash {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 70%, white);
}
.doc-card .doc-main { min-width: 0; flex: 1; }
.doc-card .year {
  font-size: 1.25rem;
  font-weight: 650;
}
.doc-card .sub { color: var(--muted); font-size: 0.9rem; }
.doc-card .doc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-card .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}
.pos-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  margin-bottom: 6px;
}
.pos-badge.is-home {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, white);
}

.empty-note {
  color: var(--muted);
  background: color-mix(in srgb, var(--accent-soft) 55%, white);
  border: 1px dashed color-mix(in srgb, var(--accent) 28%, white);
  border-radius: var(--radius);
  padding: 18px 16px;
  font-size: 0.95rem;
}

.hidden { display: none !important; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(23, 16, 20, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 20px;
  gap: 14px;
}
.lightbox[hidden] { display: none !important; }
.lightbox img,
.lightbox iframe {
  max-width: min(960px, 94vw);
  max-height: 62vh;
  border-radius: 16px;
  background: #000;
}
.lightbox iframe {
  width: min(960px, 94vw);
  aspect-ratio: 16 / 9;
  border: 0;
  max-height: none;
  height: auto;
}
.lb-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}
.lb-panel {
  width: min(560px, 94vw);
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.lb-cap-label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.lb-cap-label input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}
.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.toast[hidden] { display: none !important; }
.toast.is-err { background: var(--danger); }

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(23, 16, 20, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
}
.confirm-overlay[hidden] { display: none !important; }
.confirm-dialog {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
}
.confirm-dialog h3 {
  font-size: 1.15rem;
  font-weight: 650;
  margin-bottom: 8px;
}
.confirm-dialog p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 18px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.sm { padding: 5px 10px; font-size: 0.82rem; }
.btn.ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, white); }

.card-list { display: grid; gap: 10px; }
.row-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.row-main { flex: 1; min-width: 200px; display: grid; gap: 4px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.linkish {
  appearance: none; border: 0; background: transparent; padding: 0;
  font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.linkish:hover { color: var(--accent); }
.meta { font-size: 0.82rem; color: var(--muted); }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.mono textarea, textarea.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.stack { display: grid; gap: 10px; }
.media-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.media-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #eee; }
.media-meta { padding: 8px 10px; display: grid; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.group-block h3 { margin: 0; }

@media (max-width: 640px) {
  .media-grid { grid-template-columns: repeat(2, 1fr); }
}
