@import "https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap";

/* client/style.css */
:root {
  --bg: #f4f2e9;
  --ink: #1f1a14;
  --paper: #fffdf7;
  --line: #d3c9b8;
  --primary: #0e7a59;
  --primary-ink: #ecfff7;
  --danger: #a53131;
  --danger-bg: #ffe8e8;
  --success: #1b6a4d;
  --success-bg: #e6f8ef;
  --muted: #665f52;
  --shadow: 0 12px 30px #21180f14;
}

* {
  box-sizing: border-box;
}

body {
  color: var(--ink);
  background: radial-gradient(circle at 85% 15%, #e5d8b8 0, #e5d8b800 35%), radial-gradient(circle at 10% 90%, #d8efe4 0, #d8efe400 38%), var(--bg);
  min-height: 100vh;
  margin: 0;
  font-family: Space Grotesk, Avenir Next, Segoe UI, sans-serif;
}

.page {
  width: min(920px, 92vw);
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.page.workspace-root {
  width: min(1480px, 96vw);
}

.workspace-root .topbar {
  align-items:  flex-start;
}

.workspace-root .menu {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .02em;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 700;
}

.menu {
  display: flex;
  align-items:  center;
  gap: .75rem;
}

.langswitch {
  display: inline-flex;
  color: var(--muted);
  align-items:  center;
  gap: .4rem;
  font-size: .9rem;
}

.langswitch select {
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  background: #fff;
  border-radius: .48rem;
  padding: .32rem .44rem;
}

.menu a, .linklike {
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  opacity: .84;
  background: none;
  border: 0;
}

.menu a:hover, .linklike:hover {
  opacity: 1;
}

.banner {
  border: 1px solid #0000;
  border-radius: .7rem;
  margin: 0 0 1rem;
  padding: .72rem .95rem;
  font-size: .95rem;
}

.banner.success {
  color: var(--success);
  background: var(--success-bg);
  border-color: #a9e2c8;
}

.banner.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #efbaba;
}

.content {
  animation: reveal .22s ease-out;
}

.panel {
  background: linear-gradient(170deg, var(--paper) 0%, #fef9ef 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 1rem;
  padding: 1.2rem;
}

.panel h1, .panel h2 {
  margin-top: 0;
  margin-bottom: .7rem;
}

.panel p {
  color: var(--muted);
  margin-top: .35rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 1rem;
}

.button {
  display: inline-flex;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  text-decoration: none;
  cursor: pointer;
  border-radius: .66rem;
  justify-content: center;
  align-items:  center;
  padding: .55rem .9rem;
  transition: transform .14s, opacity .14s, background .14s;
  font-family: Space Grotesk, Avenir Next, sans-serif;
  font-weight: 600;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: .66;
  cursor: not-allowed;
}

.button.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: none;
}

.button.danger {
  color: var(--danger);
  background: none;
  border-color: #d9a1a1;
}

.asset-page {
  display: grid;
  gap: 1.15rem;
}

.asset-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  align-items:  start;
  gap: 1.5rem;
}

.asset-upload-form {
  display: grid;
  gap: .7rem;
}

.asset-upload-form label {
  display: grid;
  color: var(--muted);
  gap: .3rem;
  font-size: .9rem;
}

.asset-upload-form input {
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  background: #fff;
  border-radius: .62rem;
  width: 100%;
  padding: .58rem .65rem;
}

.asset-list-heading {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
}

.asset-list-heading h3 {
  margin: 0;
}

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

.asset-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: .85rem;
  min-width: 0;
  box-shadow: 0 6px 18px #21180f0f;
}

.asset-preview {
  display: grid;
  color: var(--ink);
  text-decoration: none;
  background-color: #ece8de;
  background-image: linear-gradient(45deg, #dfd9ce 25%, #0000 25%), linear-gradient(-45deg, #dfd9ce 25%, #0000 25%), linear-gradient(45deg, #0000 75%, #dfd9ce 75%), linear-gradient(-45deg, #0000 75%, #dfd9ce 75%);
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-size: 18px 18px;
  place-items:  center;
  height: 170px;
}

.asset-preview img {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

.asset-file-icon {
  display: grid;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .45rem .9rem .45rem .45rem;
  place-items:  center;
  width: 72px;
  height: 86px;
  padding: .4rem;
  font-family: IBM Plex Mono, monospace;
  font-size: .78rem;
  font-weight: 700;
}

.asset-info {
  display: grid;
  gap: .2rem;
  padding: .75rem;
}

.asset-info strong, .asset-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-info span {
  color: var(--muted);
  font-size: .82rem;
}

.asset-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  padding: 0 .75rem .75rem;
}

.asset-actions .button {
  padding-inline-start: .45rem;
  padding-inline-end: .45rem;
  font-size: .85rem;
}

.asset-empty {
  text-align: center;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(360px, 1.3fr);
  align-items:  start;
  gap: 1rem;
}

.profile-avatar-panel {
  display: grid;
  text-align: center;
  justify-items: center;
  gap: .85rem;
}

.profile-avatar {
  display: grid;
  overflow: hidden;
  border: 4px solid var(--paper);
  outline: 1px solid var(--line);
  color: var(--primary);
  box-shadow: var(--shadow);
  background: #dcece5;
  border-radius: 50%;
  place-items:  center;
  width: 156px;
  height: 156px;
  font-size: 3rem;
  font-weight: 700;
}

.profile-avatar img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

.profile-picker {
  display: grid;
  color: var(--muted);
  text-align: left;
  gap: .35rem;
  width: 100%;
  font-size: .88rem;
}

.profile-picker select {
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  background: #fff;
  border-radius: .6rem;
  width: 100%;
  padding: .55rem;
}

.profile-password {
  border-top: 1px solid var(--line);
  margin-top: .5rem;
  padding-top: .8rem;
}

.profile-password h3, .profile-password p {
  margin: 0;
}

.danger-text {
  color: var(--danger);
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
}

.form {
  display: grid;
  gap: .78rem;
  max-width: 520px;
}

.form label {
  display: grid;
  color: var(--muted);
  gap: .35rem;
  font-size: .92rem;
}

.form input, .form select, .form textarea {
  border: 1px solid var(--line);
  outline: none;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border-radius: .62rem;
  padding: .6rem .7rem;
}

.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px #0e7a5926;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: .8rem;
}

.rowactions {
  display: flex;
  flex-wrap: wrap;
  align-items:  center;
  gap: .6rem;
}

.muted {
  color: var(--muted);
  margin: .45rem 0 0;
  font-size: .92rem;
}

.userlist {
  list-style: none;
  display: grid;
  gap: .68rem;
  margin: .75rem 0 0;
  padding: 0;
}

.userrow {
  display: flex;
  background: #fff;
  border: 1px solid #e4dccd;
  border-radius: .66rem;
  justify-content: space-between;
  align-items:  center;
  gap: .8rem;
  padding: .7rem;
}

.userrow strong {
  display: block;
  margin-bottom: .2rem;
}

.userrow p {
  margin: 0;
  font-size: .9rem;
}

.pagination {
  display: flex;
  border-top: 1px solid #e7dece;
  flex-wrap: wrap;
  align-items:  center;
  gap: .65rem;
  margin-top: 1rem;
  padding-top: .9rem;
}

.limitcontrol {
  display: inline-flex;
  color: var(--muted);
  align-items:  center;
  gap: .42rem;
  font-size: .9rem;
}

.limitcontrol select {
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  background: #fff;
  border-radius: .52rem;
  padding: .38rem .48rem;
}

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .4rem 1rem;
  margin: 0 0 1rem;
}

.details dt {
  font-weight: 700;
}

.details dd {
  color: var(--muted);
  margin: 0;
  font-family: IBM Plex Mono, ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .88rem;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admin-page {
  display: grid;
  gap: 1rem;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  align-items:  start;
  gap: 1rem;
}

.admin-grid label, .game-shell label {
  display: grid;
  color: var(--muted);
  gap: .3rem;
  margin: .75rem 0;
}

.admin-grid input, .admin-grid textarea, .admin-grid select, .game-shell input {
  border: 1px solid var(--line);
  font: inherit;
  color: var(--ink);
  background: #fff;
  border-radius: .6rem;
  width: 100%;
  padding: .62rem;
}

.admin-grid textarea {
  resize: vertical;
  min-height: 76px;
}

.admin-grid .check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items:  center;
}

.admin-grid .check input {
  width: auto;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
}

.list-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  gap: .7rem;
  padding: .7rem 0;
}

.list-row span {
  display: grid;
  gap: .2rem;
}

.list-row small {
  color: var(--muted);
}

.list-row button, .checkpoint button {
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: 0;
}

.checkpoint {
  display: grid;
  border: 1px dashed var(--line);
  border-radius: .7rem;
  gap: .5rem;
  margin: .6rem 0;
  padding: .8rem;
}

.game-shell {
  position: relative;
  color: #f9f4df;
  text-align: center;
  background: linear-gradient(145deg, #102f35, #07191f);
  border-radius: 1.4rem;
  max-width: 620px;
  margin: 5vh auto;
  padding: clamp(1.4rem, 5vw, 3rem);
  box-shadow: 0 24px 70px #07191f55;
}

.game-shell h1 {
  margin: .7rem 0 1.2rem;
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 1;
}

.game-shell p, .game-shell label {
  color: #c8d8d2;
}

.game-shell form {
  text-align: left;
  max-width: 390px;
  margin: auto;
}

.game-shell .button {
  color: #122227;
  background: #e5ae3d;
  border-color: #e5ae3d;
  width: 100%;
  margin-top: .6rem;
}

.eyebrow {
  color: #e5ae3d;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
  font-weight: 700;
}

.answer-grid {
  display: grid;
  gap: .7rem;
  margin-top: 1.5rem;
}

.answer-grid button {
  color: #fff;
  font: inherit;
  cursor: pointer;
  background: #173e43;
  border: 1px solid #e5ae3d99;
  border-radius: .75rem;
  padding: 1rem;
  font-weight: 600;
}

.answer-grid button:hover {
  background: #20545a;
}

.game-message {
  border: 1px solid #e5ae3d66;
  border-radius: .7rem;
  padding: .75rem;
}

.game-logout {
  position: absolute;
  color: #c8d8d2;
  top: 1rem;
  right: 1rem;
}

.treasure-admin {
  display: grid;
  gap: 1rem;
}

.admin-header {
  display: flex;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--paper), #eef5f2);
  box-shadow: var(--shadow);
  border-radius: 1rem;
  justify-content: space-between;
  align-items:  flex-start;
  gap: 1rem;
  padding: 1.4rem;
}

.admin-header h1 {
  margin: .2rem 0;
}

.admin-header p {
  color: var(--muted);
  margin: 0;
}

.admin-user, .state-label, .state-dot, .status {
  display: inline-flex;
  color: var(--primary);
  background: #e8f2ee;
  border-radius: 999px;
  align-items:  center;
  width: max-content;
  padding: .35rem .65rem;
  font-size: .8rem;
  font-weight: 700;
}

.admin-tabs {
  position: sticky;
  z-index: 10;
  display: flex;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
  overflow-x: auto;
  border-radius: .8rem;
  gap: .35rem;
  padding: .35rem;
  top: .5rem;
  box-shadow: 0 5px 18px #21180f0d;
}

.admin-tabs button {
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: .55rem;
  padding: .65rem 1rem;
  font-weight: 700;
}

.admin-tabs button.active, .admin-tabs button:hover {
  background: var(--primary);
  color: #fff;
}

.admin-toolbar {
  display: flex;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: .8rem;
  align-items:  end;
  gap: .8rem;
  padding: 1rem;
}

.admin-toolbar label {
  display: grid;
  flex: 1;
  gap: .35rem;
  font-weight: 700;
}

.admin-toolbar select {
  border: 1px solid var(--line);
  font: inherit;
  background: #fff;
  border-radius: .6rem;
  width: 100%;
  padding: .7rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .8rem;
}

.stat {
  display: flex;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  border-radius: .9rem;
  align-items:  center;
  gap: .8rem;
  min-height: 95px;
  padding: 1rem;
}

.stat > i {
  display: grid;
  color: var(--primary);
  background: #e8f2ee;
  border-radius: 50%;
  place-items:  center;
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
  font-style: normal;
}

.stat > div {
  display: grid;
  gap: .15rem;
}

.stat strong {
  font-size: 1.55rem;
}

.stat span {
  color: var(--muted);
  font-size: .85rem;
}

.admin-section {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  border-radius: 1rem;
}

.admin-section > header {
  display: flex;
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
  padding: 1rem 1.2rem;
}

.admin-section h2 {
  margin: 0;
  font-size: 1.15rem;
}

.admin-section-body {
  overflow-x: auto;
  padding: 1.2rem;
}

.admin-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
}

.admin-table th {
  text-align: left;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .78rem;
}

.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--line);
  padding: .8rem;
}

.admin-table tbody tr:hover {
  background: #f5faf8;
}

.table-actions {
  white-space: nowrap;
}

.table-actions button {
  border: 1px solid var(--primary);
  color: var(--primary);
  cursor: pointer;
  background: #fff;
  border-radius: .5rem;
  margin-right: .3rem;
  padding: .45rem .65rem;
}

.table-actions button.danger {
  color: #b94b4b;
  border-color: #b94b4b;
}

.mono {
  color: var(--muted);
  font-family: monospace;
}

.state-dot:not(.on) {
  color: #925050;
  background: #f3eded;
}

.status.finished {
  color: #287346;
  background: #e5f4eb;
}

.status.eliminated {
  color: #a33;
  background: #faeaea;
}

.admin-empty {
  text-align: center;
  color: var(--muted);
  padding: 2.2rem;
}

.admin-form {
  width: 100%;
}

.admin-field {
  display: grid;
  gap: .4rem;
  margin-bottom: 1rem;
}

.admin-field > span {
  font-weight: 700;
}

.admin-field input:not([type="checkbox"]), .admin-field textarea, .admin-field select {
  border: 1px solid var(--line);
  font: inherit;
  background: #fff;
  border-radius: .6rem;
  width: 100%;
  padding: .7rem;
}

.admin-field textarea {
  resize: vertical;
  min-height: 82px;
}

.admin-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.admin-form-actions {
  display: flex;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  gap: .6rem;
  padding-top: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.checkpoint-grid article {
  border: 1px solid var(--line);
  border-radius: 0 0 .8rem .8rem;
  padding: 1rem;
}

.checkpoint-grid article > header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.checkpoint-grid article > header button {
  color: #b94b4b;
  cursor: pointer;
  background: none;
  border: 0;
}

.game-root {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.tq-page {
  --tq-primary: #167c68;
  --tq-secondary: #102f35;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(50px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(160deg, var(--tq-secondary), #07191f);
  color: #15211e;
  min-height: 100dvh;
}

.tq-cover {
  position: absolute;
  object-fit: cover;
  opacity: .45;
  mask-image: linear-gradient(#000 55%, #0000);
  width: 100%;
  height: 42vh;
  inset: 0 0 auto;
}

.tq-card {
  position: relative;
  background: #fffdf7;
  border-radius: 24px;
  width: min(620px, 100%);
  margin: 10vh auto 0;
  padding: clamp(24px, 6vw, 48px);
  box-shadow: 0 24px 80px #0005;
}

.tq-card h1 {
  margin: .5rem 0 1rem;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 1;
}

.tq-card h2 {
  font-size: 1.25rem;
}

.tq-card label {
  display: grid;
  gap: 6px;
  margin: 16px 0;
  font-weight: 600;
}

.tq-card input, .tq-card select {
  font: inherit;
  background: #fff;
  border: 1px solid #b9c5c0;
  border-radius: 8px;
  width: 100%;
  padding: 12px;
}

.tq-logo {
  object-fit: contain;
  max-width: 130px;
  max-height: 70px;
}

.tq-lead {
  font-size: 1.2rem;
  font-weight: 600;
}

.tq-button {
  background: var(--tq-primary);
  color: #fff;
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  width: 100%;
  padding: 14px 18px;
  font-weight: 700;
}

.tq-button:disabled {
  opacity: .55;
}

.tq-privacy, .tq-link {
  display: block;
  text-align: center;
  color: var(--tq-primary);
  cursor: pointer;
  background: none;
  border: 0;
  margin: 14px auto 0;
}

.tq-page > footer {
  text-align: center;
  color: #fff;
  margin-top: 28px;
}

.tq-player-head {
  display: flex;
  color: #fff;
  justify-content: space-between;
  width: min(700px, 100%);
  margin: auto;
  padding: 8px;
}

.tq-progressbar {
  background: #fff3;
  width: min(680px, 100% - 32px);
  height: 5px;
  margin: auto;
}

.tq-progressbar i {
  display: block;
  background: var(--tq-primary);
  height: 100%;
  transition: all .3s;
}

.tq-card.stage {
  margin-top: 28px;
}

.tq-clue {
  color: #42534d;
  font-size: 1.25rem;
}

.tq-content {
  border-left: 4px solid var(--tq-primary);
  background: #f0f5f2;
  margin: 20px 0;
  padding: 15px;
}

.tq-action {
  border-top: 1px solid #dce3df;
  margin-top: 24px;
  padding-top: 20px;
}

.tq-options {
  display: grid;
  gap: 10px;
}

.tq-options button, .tq-fallback button {
  border: 1px solid var(--tq-primary);
  color: var(--tq-primary);
  font: inherit;
  cursor: pointer;
  background: #fff;
  border-radius: 8px;
  padding: 13px;
  font-weight: 600;
}

.tq-fallback {
  background: #f4f2e9;
  border-radius: 10px;
  margin-top: 20px;
  padding: 16px;
}

.tq-error {
  color: #8c2020;
  background: #fff0f0;
  border: 1px solid #d55;
  border-radius: 8px;
  padding: 12px;
}

.tq-complete-icon {
  display: grid;
  background: var(--tq-primary);
  color: #fff;
  border-radius: 50%;
  place-items:  center;
  width: 72px;
  height: 72px;
  margin: auto;
  font-size: 38px;
}

.completed {
  text-align: center;
}

.tq-progress {
  color: var(--tq-primary);
  font-weight: 700;
}

.tq-account {
  border-top: 1px solid #ddd;
  margin-top: 24px;
  padding-top: 18px;
}

.tq-account a {
  color: var(--tq-primary);
  font-weight: 700;
}

.checkline {
  align-items:  start;
  grid-template-columns: auto 1fr !important;
}

.checkline input {
  margin-top: 3px;
  width: auto !important;
}

.saved-adventures {
  display: grid;
  gap: 10px;
}

.saved-adventures article {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  justify-content: space-between;
  align-items:  center;
  gap: 16px;
  padding: 14px;
}

.saved-adventures article > div {
  display: grid;
  gap: 4px;
}

.saved-adventures small {
  color: var(--muted);
}

.table-scroll {
  overflow-x: auto;
}

.panel > label {
  display: grid;
  gap: 5px;
  margin: 12px 0;
}

.panel > label select {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 9px;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 15px 0;
}

.mini-stats span {
  display: grid;
  color: var(--muted);
  background: #eef5f2;
  border-radius: 8px;
  min-width: 130px;
  padding: 12px;
}

.mini-stats strong {
  color: var(--primary);
  font-size: 1.5rem;
}

.stage-map-panel {
  border: 1px solid var(--line);
  overflow: hidden;
  background: #f8faf9;
  border-radius: .9rem;
  margin: 1.5rem 0;
}

.stage-map-panel > header {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: #fff;
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
  padding: 1rem;
}

.stage-map-panel h3, .stage-heading h3 {
  margin: 0;
}

.stage-map-panel p, .stage-heading p {
  color: var(--muted);
  margin: .2rem 0 0;
  font-size: .85rem;
}

.stage-map-panel > small {
  display: block;
  color: var(--muted);
  background: #fff;
  padding: .45rem .8rem;
}

.stage-map {
  cursor: grab;
  height: 430px;
}

.stage-map-panel.adding .stage-map {
  cursor: crosshair;
}

.stage-map-marker {
  background: none;
  border: 0;
}

.stage-map-marker span {
  display: grid;
  background: var(--primary);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  place-items:  center;
  width: 32px;
  height: 32px;
  font-weight: 700;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px #0006;
}

.stage-heading {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin: 1.5rem 0 .7rem;
}

.checkpoint-grid.sortable {
  align-items:  start;
}

.sortable-stage {
  position: relative;
  border: 2px solid #0000;
  border-radius: .85rem;
  transition: border-color .15s, opacity .15s;
}

.sortable-stage.selected {
  border-color: var(--primary);
}

.sortable-stage:has(.drag-handle:active) {
  opacity: .55;
}

.drag-handle {
  color: var(--primary);
  text-align: left;
  font: inherit;
  cursor: grab;
  background: #e8f2ee;
  border: 0;
  border-radius: .7rem .7rem 0 0;
  width: 100%;
  padding: .65rem .8rem;
  font-weight: 700;
}

.drag-handle:active {
  cursor: grabbing;
}

.sortable-stage > article {
  border-top: 0;
}

.publish-actions {
  display: flex;
  justify-content: flex-end;
  align-items:  center;
  gap: .7rem;
  margin-top: 1.2rem;
}

.publish-actions a {
  color: var(--primary);
  margin-right: auto;
}

@media (width >= 1200px) {
  .stage-map {
    height: 520px;
  }
}

@media (width <= 680px) {
  .admin-head {
    flex-direction: column;
    align-items:  flex-start;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-header, .admin-toolbar, .stage-heading, .publish-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid, .form-row, .checkpoint-grid {
    grid-template-columns: 1fr;
  }

  .publish-actions a {
    margin-right: 0;
  }

  .tq-page {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .tq-card {
    border-radius: 18px;
    margin-top: 4vh;
    padding: 24px 20px;
  }

  .tq-card.stage {
    margin-top: 18px;
  }

  .tq-button, .tq-options button, .tq-fallback button {
    min-height: 48px;
  }

  .tq-card input, .tq-card select {
    min-height: 48px;
    font-size: 16px;
  }

  .page {
    width: min(980px, 94vw);
    padding-top: 1rem;
  }

  .topbar {
    flex-direction: column;
    align-items:  flex-start;
  }

  .menu {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
  }

  .langswitch {
    justify-content: space-between;
    width: 100%;
  }

  .row, .userrow {
    flex-direction: column;
    align-items:  flex-start;
  }

  .rowactions, .button {
    width: 100%;
  }

  .pagination .button {
    width: auto;
  }

  .asset-upload, .profile-layout {
    grid-template-columns: 1fr;
  }

  .asset-actions .button, .asset-list-heading .button {
    width: auto;
  }
}
