/* Flat, square, dark-only design following laborinth.ch: warm dark grays,
   white as the primary "color", one restrained bronze accent. No rounded
   corners anywhere. */

@font-face {
  font-family: 'LABORinth-Tech';
  src: url('laborinth-tech.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

:root {
  --bg: #1a1a1a;
  --bg-top: #3d3936;        /* warm top of the laborinth.ch gradient */
  --surface: #232323;
  --raised: #2e2e2e;
  --text: #f2f2f2;
  --text-soft: #999;
  --border: #3a3a3a;
  --ink: #111;              /* bars, and text on white fills */
  --paper: #f2f2f2;         /* white fills: primary buttons, my boxes */
  --accent: #c9a35c;        /* bronze — shared markers, selected tags */
  --free: #262626;
  --taken: #4a4541;
  --danger: #e5484d;
  --topbar-h: 48px;
  --tabbar-h: 52px;
}

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

/* The document itself never scrolls — all scrolling happens inside the
   screens/panels. This kills Safari's rubber-band on the whole page and
   keeps the address bar (and with it our footer) from moving around. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* matches the black bars so Safari's own chrome blends into the app */
  background: var(--ink);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }

:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

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

.screen { height: 100dvh; overflow-y: auto; overscroll-behavior-y: contain; }

/* app is a centered phone-width column, looks like an app on desktop too */
#screen-app, #screen-admin, #screen-wifi {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

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

#screen-login, #screen-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(to top, var(--bg), var(--bg-top));
}
#screen-login[hidden], #screen-profile[hidden],
#screen-app[hidden], #screen-admin[hidden], #screen-wifi[hidden] { display: none; }

/* profile form sits directly on the gradient, no box around it */
.profile-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
label.req::after { content: ' *'; color: var(--accent); }
.hub-actions { display: flex; gap: 4px; }

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand-row { display: flex; align-items: center; gap: 14px; }

.brand {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
}

.logo-grid { width: 72px; height: 72px; display: block; flex-shrink: 0; }
.logo-small { width: 44px; height: 44px; }

.hint { color: var(--text-soft); font-size: 14px; }

.lang-row { display: flex; gap: 4px; }
.lang-btn {
  flex: 1;
  padding: 8px 0;
  background: var(--raised);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 13px;
}
.lang-btn.active { background: var(--paper); color: var(--ink); }

form { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--text-soft); }

input[type=text], input[type=password], input[type=email], input[type=tel], select {
  padding: 12px;
  border: 1px solid #555;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input::placeholder { color: #777; }

/* selects in forms: flat dark field with a custom chevron */
form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8"><path d="M1 1l5 5 5-5" fill="none" stroke="%23999" stroke-width="2"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-weight: 600;
  text-align: center;
}
.btn-primary { background: var(--paper); color: var(--ink); }
.btn-primary:active { background: #cfcfcf; }
.btn-secondary { background: var(--taken); color: var(--text); }
.btn-ghost { background: none; border: 1px solid #4a4a4a; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.form-error { color: #ff8389; font-size: 14px; font-weight: 600; }

.person-list { display: flex; flex-direction: column; max-height: 40dvh; overflow-y: auto; }
.person-list button {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.person-list button:active { background: var(--raised); }

/* ---- module hub ------------------------------------------------------- */

#screen-hub {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 24px 16px;
  background: linear-gradient(to top, var(--bg), var(--bg-top));
}
#screen-hub[hidden] { display: none; }
.hub-wrap { display: flex; flex-direction: column; gap: 16px; }
.hub-head { display: flex; align-items: center; justify-content: space-between; }
.hub-head .icon-btn { color: var(--text); }
.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.hub-tile {
  aspect-ratio: 1.4;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px;
  text-align: left;
}
/* live tiles are only a touch brighter than the rest */
.hub-tile.live { background: var(--raised); border-color: #4a4a4a; color: var(--text); }
/* author styles override the UA's [hidden] rule, so restate it */
.hub-tile[hidden] { display: none; }
.hub-tile:disabled { cursor: default; }
.hub-icon { width: 34px; height: 34px; flex-shrink: 0; }
.hub-text { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.chip.soon { background: var(--accent); color: var(--ink); }

/* ---- topbar ----------------------------------------------------------- */

.topbar {
  height: var(--topbar-h);
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  flex-shrink: 0;
}
.topbar-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.topbar-user { margin-left: auto; font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar select {
  width: auto; padding: 4px 6px;
  background: var(--raised); color: #fff; border: none;
  font-size: 13px; font-weight: 600;
}
.icon-btn { color: #fff; font-size: 20px; padding: 4px 8px; line-height: 1; }
.icon-btn svg { display: block; }

/* ---- sliding panels --------------------------------------------------- */

/* The track is transformed for tab slides; clipping happens on #screen-app.
   overflow:hidden here would clip panels before the transform and blank them. */
.panels {
  flex: 1;
  min-height: 0; /* without this the flex item grows with content and panels never scroll */
  display: flex;
  transition: transform .25s ease;
  touch-action: pan-y;
}
.panel {
  min-width: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 12px calc(var(--tabbar-h) + 16px);
}
.panel[hidden] { display: none; }

/* ---- tabbar ----------------------------------------------------------- */

.tabbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: var(--ink);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  border-top: 3px solid transparent;
}
.tabbar button[aria-selected="true"] { color: var(--paper); border-top-color: var(--paper); }
.tabbar button[hidden] { display: none; }

/* ---- box grid --------------------------------------------------------- */

.legend { display: flex; gap: 14px; margin-bottom: 12px; font-size: 12px; color: var(--text-soft); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; display: inline-block; }

.box-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.box-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  position: relative;
  background: var(--free);
  border: 1px solid #333;
  color: #8f8f8f;
}
.box-cell.mine { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.box-cell.taken { background: var(--taken); border-color: var(--taken); color: #d6d2cd; }
.box-cell .count { font-size: 10px; font-weight: 400; opacity: .75; line-height: 1.35; }
.box-cell .shared-mark {
  position: absolute; top: -1px; right: -1px;
  width: 12px; height: 12px;
  background: var(--accent);
}

/* ---- cards / lists ---------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 12px;
  margin-bottom: 12px;
}
.card h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.card.compact { padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.card.compact .admin-user-head strong { font-size: 16px; }
.card.compact .item-row { padding: 0; border: none; }
.card.compact .tag-cloud { margin-bottom: 0; }

.panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-soft);
  margin: 0 0 10px 2px;
}
.panel-title:not(:first-child) { margin-top: 18px; }

.thing-search { margin-bottom: 10px; }

/* ---- reveal swipe ----------------------------------------------------- */

.thing-row { position: relative; overflow: hidden; touch-action: pan-y; }
.thing-row .item-row {
  position: relative;
  z-index: 1;
  background: var(--surface);
  transition: transform .18s ease;
}
.thing-row.swiping .item-row { transition: none; }
.swipe-pane {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}
.swipe-pane.left { right: 0; }
.swipe-pane.right { left: 0; }
.swipe-pane.good { background: #2e7d46; color: #fff; }
.swipe-pane.danger { background: var(--danger); color: #fff; }
.swipe-pane.accent { background: var(--accent); color: var(--ink); }
.swipe-pane.armed { filter: brightness(1.3); }

/* on touch devices the things tabs are swipe-driven; the web keeps buttons */
@media (pointer: coarse) {
  #panel-down .item-actions, #panel-up .item-actions,
  #bx-items .item-actions { display: none; }
}


.item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-name { font-weight: 600; }
.item-meta { font-size: 12px; color: var(--text-soft); width: 100%; }
.item-row .chip { margin-left: auto; }
.item-actions { width: 100%; display: flex; gap: 6px; }
.item-actions .btn { padding: 8px; font-size: 13px; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  background: #333;
  color: #ddd;
  font-size: 12px;
  font-weight: 600;
  border: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.chip.accent { background: var(--accent); color: var(--ink); }
.chip.dark { background: var(--paper); color: var(--ink); }
.chip.lent { background: var(--accent); color: var(--ink); }
.chip.shared { background: var(--accent); color: var(--ink); }

.filter-row { display: flex; gap: 6px; margin-bottom: 10px; }

.status-line { font-size: 14px; margin-bottom: 10px; }
.status-line strong { font-weight: 700; }

.empty-note { color: var(--text-soft); font-size: 14px; padding: 8px 0; }

/* ---- tag picker ------------------------------------------------------- */

/* all categories visible at once, wrapping instead of scrolling */
.cat-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.inline-add { display: flex; gap: 6px; margin-bottom: 10px; }
.inline-add input { flex: 1; }
.inline-add .btn { width: auto; padding: 10px 14px; }

/* ---- overlay (box detail) --------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform .22s ease;
}
.overlay.open { transform: translateX(0); }
.overlay[hidden] { display: none; }
.overlay-inner { height: 100%; display: flex; flex-direction: column; }
.overlay-content { flex: 1; overflow-y: auto; overscroll-behavior-y: contain; padding: 16px 12px 32px; }

/* subtle scrollbars matching the dark theme */
.screen, .panel, .overlay-content, .person-list {
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

/* ---- wifi module ------------------------------------------------------ */

/* inverted QR: light modules straight on the dark background — modern
   phone cameras read inverted codes; fall back to a white card if not */
.qr-card {
  max-width: 300px;
  margin: 24px auto 14px;
}
.qr-card svg { display: block; width: 100%; height: auto; }
.wifi-hint { text-align: center; margin-bottom: 16px; }
#panel-wifi .qr-card { margin-top: 14px; }

/* ---- history ---------------------------------------------------------- */

.log-time { font-size: 11px; color: var(--text-soft); display: block; }

/* ---- admin ------------------------------------------------------------ */

.admin-user-head { display: flex; align-items: center; gap: 8px; }

/* tenant data on the admin card */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  font-size: 13px;
  margin: 8px 0 6px;
}
.info-k { color: var(--text-soft); }
.info-v.pw { color: var(--accent); font-weight: 600; }
.card.inactive { opacity: .55; }

/* one-time password cards: big, copyable */
.otp-card { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.otp-big {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
}
.otp-card .btn { width: auto; padding: 8px 12px; font-size: 13px; margin-left: auto; }
.otp-card .item-meta { width: 100%; }
.admin-user-head strong { flex: 1; }
.admin-user-head .btn { width: auto; padding: 8px 12px; font-size: 13px; }
.admin-user-meta { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.admin-user-meta + .item-actions { margin-top: 10px; }

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

.toast {
  position: fixed;
  left: 0; right: 0;
  margin: 0 auto;
  width: calc(100% - 24px);
  max-width: 456px;
  bottom: calc(var(--tabbar-h) + 12px);
  z-index: 40;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
}
.toast.error { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }

/* ---- desktop browser: double the column width ------------------------- */

@media (min-width: 700px) {
  #screen-app, #screen-admin, #screen-wifi, #screen-hub { max-width: 960px; }
  /* keep box cells hand-sized: two letter rows side by side */
  .box-grid { grid-template-columns: repeat(10, 1fr); }
  .hub-grid { grid-template-columns: repeat(3, 1fr); }
  /* optical alignment inside the black bars */
  .topbar-title { position: relative; top: 2px; }
}
