:root {
  --bg: #e7f3f7;
  --surface: rgba(255, 252, 248, 0.92);
  --ink: #0f2f3a;
  --muted: #4a6a75;
  --line: #c5dde6;
  --primary: #0b6e8a;
  --primary-2: #0a8eab;
  --accent: #e07a3d;
  --danger: #9b2226;
  --ok: #1b7a63;
  --warn: #9a6b12;
  --shadow: 0 10px 28px rgba(11, 55, 72, 0.12);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); }
body {
  background-color: #0b4f66;
  background-image:
    linear-gradient(180deg, rgba(231, 243, 247, 0.88), rgba(231, 243, 247, 0.94)),
    url("../img/bg-app.jpg");
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 1.45rem; margin: 0 0 0.8rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 0.7rem; }

.app {
  min-height: 100dvh;
  padding-top: calc(3.4rem + var(--safe-top));
  padding-bottom: calc(5.2rem + var(--safe-bottom));
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.55rem + var(--safe-top)) 1rem 0.55rem;
  background: linear-gradient(120deg, #084c63, #0b6e8a 55%, #117a8f);
  color: #fff;
  box-shadow: 0 6px 18px rgba(8, 50, 70, 0.25);
}
.brand {
  color: #fff;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.brand img {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}
.top-actions { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; }
.top-actions a, .top-actions button { color: #e8f6fa; }
.who { opacity: 0.85; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang { padding: 0.15rem 0.4rem; border-radius: 999px; text-decoration: none; }
.lang.is-active { background: #fff; color: var(--primary); }

.main { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.flashes { max-width: 960px; margin: 0 auto; padding: 0.75rem 1rem 0; }
.flash { padding: 0.7rem 0.85rem; border-radius: 10px; margin-bottom: 0.5rem; backdrop-filter: blur(6px); }
.flash-success { background: rgba(214, 242, 232, 0.95); color: #145c4a; }
.flash-error { background: rgba(253, 232, 232, 0.95); color: #7a1518; }

.hero {
  margin: 0 0 1rem;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.45);
}
.hero img {
  width: 100%;
  height: clamp(120px, 22vw, 200px);
  object-fit: cover;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}
.page-head h1 { margin: 0; }
.page-head .page-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 252, 248, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.4rem calc(0.4rem + var(--safe-bottom));
}
.tabbar a {
  flex: 1 0 auto;
  text-align: center;
  padding: 0.4rem 0.65rem 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-decoration: none;
  border-radius: 12px;
  white-space: nowrap;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}
.tabbar a img {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  opacity: 0.88;
}
.tabbar a.is-active {
  color: var(--primary);
  background: rgba(186, 226, 236, 0.55);
}
.tabbar a.is-active img { opacity: 1; box-shadow: 0 0 0 2px rgba(11, 110, 138, 0.25); }
.tabbar em {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-style: normal;
  font-size: 0.7rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin: 1rem 0;
  backdrop-filter: blur(8px);
}
.stack { display: grid; gap: 0.85rem; }
.stack label, .search-form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(11, 110, 138, 0.25);
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(186, 226, 236, 0.45); color: var(--primary); filter: none; }
.btn-danger { background: var(--danger); box-shadow: none; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}
.inline { display: inline; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.filename { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88rem; word-break: break-all; }
.pre-wrap { white-space: pre-wrap; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.grow { flex: 1; }
.search-form { display: flex; gap: 0.5rem; align-items: end; margin-bottom: 1rem; }
.hint { color: rgba(232, 246, 250, 0.9); font-size: 0.85rem; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.card-media {
  aspect-ratio: 1;
  background: #9fc7d4;
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 0.6rem 0.7rem 0.8rem; }
.card-body .filename { margin: 0 0 0.4rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(186, 226, 236, 0.7);
  color: #0b4f66;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.chip:hover { text-decoration: none; background: rgba(154, 214, 228, 0.9); }
.chip-lg { padding: 0.5rem 0.85rem; font-size: 0.95rem; }
.chip-warn { background: #f8ead0; color: #7a5410; }
.chip.is-on, .chip-correct { background: #c9ebe0; color: #145c4a; }
.chip-missed { background: #f8ead0; color: #7a5410; }
.chip-extra { background: #fde8e8; color: #7a1518; }
.count {
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
}
.sep { opacity: 0.45; font-weight: 400; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 1rem 0 1.5rem; }

.tag-tree {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 1.4rem;
}
.tag-tree .tag-tree {
  margin: 0.1rem 0 0.2rem;
  padding: 0.1rem 0 0.1rem 0.7rem;
  border-left: 2px solid var(--line);
}
.tag-tree li { margin: 0.18rem 0; }
.tag-tree .chip { margin: 0.05rem 0; }
.tag-tree-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0 0.15rem;
  font-size: 0.9rem;
}
.tag-tree-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 2.1rem;
}
.tag-tree-caret,
.tag-tree-leaf-spacer {
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
}
.tag-tree-caret {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(186, 226, 236, 0.45);
  color: var(--primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tag-tree-caret:hover,
.tag-tree-caret:focus-visible {
  background: rgba(154, 214, 228, 0.85);
  outline: none;
}
.tag-tree-caret::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin-left: -2px;
}
.tag-tree li.is-open > .tag-tree-row > .tag-tree-caret::before {
  transform: rotate(45deg);
  margin-left: 0;
  margin-top: -2px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
}
.crumb-sep { color: var(--muted); }

.tag-edit-path {
  margin: 0;
  font-weight: 700;
  color: var(--primary);
}

.check[data-depth="0"] {
  font-weight: 700;
  margin-top: 0.55rem;
  background: rgba(186, 226, 236, 0.5);
}
.check[data-depth="1"] { padding-left: 1.25rem; }
.check[data-depth="2"] { padding-left: 2.1rem; }
.check[data-depth="3"] { padding-left: 2.95rem; }

.photo {
  background: #072636;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}
.photo img { width: 100%; max-height: 75vh; object-fit: contain; margin: 0 auto; }
.photo-game img { max-height: 52vh; }
.meta { display: grid; grid-template-columns: 8rem 1fr; gap: 0.35rem 0.8rem; }
.meta dt { color: var(--muted); font-size: 0.85rem; }
.meta dd { margin: 0; }

.tag-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.45rem; }
.tag-list li { display: flex; gap: 0.6rem; align-items: center; }

.check-grid { display: grid; gap: 0.35rem; max-height: 50vh; overflow: auto; padding: 0.2rem; }
.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  background: var(--surface);
  font-weight: 500;
}
.check.is-hidden { display: none; }
.check small { margin-left: auto; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.filter-input { flex: 1; min-width: 10rem; }
.score { font-size: 1.3rem; font-weight: 700; color: var(--primary); }

.status {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.78rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}
.status-pending { background: #f8ead0; }
.status-approved { background: #c9ebe0; }
.status-rejected { background: #fde8e8; }
.plain { list-style: none; padding: 0; }
.plain li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; color: var(--muted); }

.guest-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
  background-color: #063648;
  background-image:
    linear-gradient(180deg, rgba(6, 54, 72, 0.35), rgba(6, 54, 72, 0.55)),
    url("../img/bg-login.jpg");
  background-size: cover;
  background-position: center;
}
.guest { width: min(26rem, 100%); }
.guest-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: #fff;
}
.guest-head .brand {
  color: #fff;
  font-size: 1.4rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
.guest-head .lang { color: #e8f6fa; }
.guest-head .lang.is-active { background: #fff; color: var(--primary); }
.guest .panel { background: rgba(255, 252, 248, 0.94); }
.guest-logo {
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.dropzone {
  position: relative;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: rgba(186, 226, 236, 0.28);
  padding: 1.25rem 1rem;
  min-height: 9rem;
  display: grid;
  align-content: center;
  gap: 0.75rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.dropzone:hover,
.dropzone:focus-visible {
  background: rgba(186, 226, 236, 0.45);
  outline: none;
  box-shadow: 0 0 0 3px rgba(11, 110, 138, 0.18);
}
.dropzone.is-dragover {
  background: rgba(154, 214, 228, 0.65);
  border-color: var(--accent);
}
.dropzone.has-files {
  border-style: solid;
}
.dropzone.is-invalid {
  border-color: var(--danger);
  background: rgba(253, 232, 232, 0.55);
}
.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.dropzone-ui {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  text-align: center;
  color: var(--ink);
}
.dropzone-ui strong { font-size: 1.05rem; }
.dropzone-ui > span:not(.btn) { color: var(--muted); font-size: 0.9rem; max-width: 28rem; }
.dropzone-browse {
  margin-top: 0.35rem;
  pointer-events: none;
}
.dropzone-list {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 252, 248, 0.9);
  border-radius: 10px;
  max-height: 9rem;
  overflow: auto;
  font-size: 0.85rem;
}
.dropzone-list li {
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--line);
  word-break: break-all;
}
.dropzone-list li:last-child { border-bottom: 0; }
.dropzone-count {
  margin: 0;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
}
.upload-progress {
  display: grid;
  gap: 0.4rem;
}
.upload-progress-bar {
  height: 0.65rem;
  background: rgba(186, 226, 236, 0.55);
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  transition: width 0.2s ease;
}
form.is-uploading .dropzone,
form.is-uploading .btn[data-upload-submit] {
  opacity: 0.7;
  pointer-events: none;
}

@media (min-width: 800px) {
  .app { padding-top: calc(6.4rem + var(--safe-top)); padding-bottom: 1.5rem; }
  .tabbar {
    top: calc(3.15rem + var(--safe-top));
    bottom: auto;
    max-width: none;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.35rem 1rem;
    justify-content: center;
  }
  .tabbar a { flex: 0 0 auto; min-width: 4.8rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
