/* banca — dark, mobile-first. Safe areas + dvh + 16px inputs throughout.
   Tokens follow the suite look; retheme by editing :root (or swap in the
   shared theme kit from cdn.ardegazu.ro/theme/v1/theme.css). */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #262c36;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb68b;
  --accent-2: #2ea043;
  --mine: #1f3d33;
  --danger: #f85149;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app,
.app {
  height: 100dvh;
}

.app {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* header */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.room-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peers {
  color: var(--muted);
  font-size: 12.5px;
  flex: none;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  flex: none;
}
.dot.on {
  background: var(--accent);
  opacity: 1;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  min-width: 40px;
  min-height: 40px;
  cursor: pointer;
  border-radius: 10px;
}
.icon-btn:active {
  background: var(--panel-2);
}
.icon-btn.small {
  min-width: 38px;
  min-height: 38px;
  font-size: 15px;
  color: var(--muted);
}
.icon-btn.small.armed {
  color: #fff;
  background: var(--danger);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* the bank: tabs + a stack of cards */

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 14px 0;
  flex: none;
}
.tabs.hide {
  display: none;
}
.tab {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13.5px;
  cursor: pointer;
}
.tab.on {
  color: var(--text);
  border-color: var(--accent);
}

.pane {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hide {
  display: none !important;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card + .card {
  margin-top: 12px;
}
.view .card + .card {
  margin-top: 0;
}
.card-title {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}
.warn {
  color: var(--text);
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}
.err:not(:empty) {
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
}

/* fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-label {
  font-size: 12px;
  color: var(--muted);
}
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 16px; /* <16px zooms the page on iOS focus */
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field select:disabled {
  color: var(--muted);
}
.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-row .primary {
  flex: 1;
}
button.primary:disabled {
  background: var(--panel-2);
  color: var(--muted);
  cursor: default;
}
button.small {
  padding: 7px 11px;
  font-size: 13px;
  border-radius: 9px;
  flex: none;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
  align-self: flex-start;
}

/* the balance card */

.bal-amt {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.bal-prov {
  font-size: 13px;
  color: var(--muted);
}
.bal-warn {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* lists */

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-head {
  font-size: 12px;
  color: var(--muted);
  padding-top: 4px;
}

.pay-row,
.knock-row,
.acct-row,
.req-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.knock-row,
.acct-row,
.req-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* the left edge says which of the four a row is, before a word is read.
   `unpinned` shares provisional's colour and not final's: both mean money that
   moved and that nothing has pinned. What separates them is whether anything
   ever will, and that is what the chip and its sentence are for. */
.pay-row.final {
  border-left: 3px solid var(--accent);
}
.pay-row.provisional,
.pay-row.unpinned {
  border-left: 3px solid #b8860b;
}
.pay-row.failed {
  border-left: 3px solid var(--danger);
}

.pay-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.pay-who {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.pay-amt {
  font-size: 15px;
  font-weight: 600;
  flex: none;
  white-space: nowrap;
}
.pay-why,
.pay-memo {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chip {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  flex: none;
}
.chip-final,
.chip-open {
  color: var(--accent);
  border-color: var(--accent);
}
.chip-provisional,
.chip-unpinned,
.chip-pending {
  color: #d9a441;
  border-color: #7a5c1e;
}
.chip-failed,
.chip-closed {
  color: var(--danger);
  border-color: #6b2320;
}

/* collapsible tool sections — the header (and its one-line idle summary) stays
   above the fold even when the form does not */

details.tool > summary.tool-head {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
details.tool > summary.tool-head::-webkit-details-marker {
  display: none;
}
details.tool > summary.tool-head::after {
  content: "▸";
  color: var(--muted);
  font-size: 12px;
  flex: none;
}
details.tool[open] > summary.tool-head::after {
  content: "▾";
}
.tool-sum {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
details.tool[open] .tool-sum {
  display: none;
}

/* long lists: filter boxes, date headers, "show more" */

.filter-in {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 16px; /* <16px zooms the page on iOS focus */
  outline: none;
}
.filter-in:focus {
  border-color: var(--accent);
}

.day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 2px;
}

.more-row {
  display: flex;
  gap: 16px;
  padding: 2px 0;
}

/* compact payment rows: the head line (who · state chip · amount) is always
   there — the STATE never collapses — and tapping it opens the sentence and
   the receipt button underneath */

.pay-head {
  cursor: pointer;
}
.pay-detail {
  display: none;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}
.pay-row.open .pay-detail {
  display: flex;
}

/* modal / overlay */

.overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 22px;
  width: min(100%, 360px);
  /* grid items default to min-width:auto — without this the box refuses to
     shrink below its content and drifts off-center on narrow screens */
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.modal h2 {
  font-size: 22px;
  letter-spacing: 1px;
}
.modal p {
  color: var(--muted);
  font-size: 13px;
}
.modal input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  text-align: center;
}
.modal input:focus {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent-2);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}

button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.copy-out {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 16px;
  outline: none;
  text-align: center;
}

/* toast */

.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13.5px;
  z-index: 110;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from {
    transform: translate(-50%, 8px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* empty-room hint */

.empty {
  margin: auto;
  max-width: 340px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 12px;
  font-size: 14px;
}
.empty strong {
  color: var(--text);
}
.empty-lock {
  font-size: 34px;
}

/* lobby (static shell in index.html) */

.lobby {
  background: var(--bg);
  align-items: start;
  padding-top: max(8vh, env(safe-area-inset-top));
}
.lobby-box {
  text-align: center;
  width: min(100%, 400px);
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
}

.room-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.room-open {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  cursor: pointer;
  min-width: 0;
}
.room-open:active {
  border-color: var(--accent);
}
.room-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-ago {
  color: var(--muted);
  font-size: 12px;
  flex: none;
}

.new-room-form {
  display: flex;
  gap: 8px;
}
.new-room-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 16px;
  outline: none;
}
.new-room-form input:focus {
  border-color: var(--accent);
}
.new-room-form .primary {
  padding: 11px 16px;
  white-space: nowrap;
}
.new-room-form .primary.ghosty {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
}

.rename-in {
  flex: 1;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
}

/* versioning */

.ver {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
}

/* created by main.ts setupUpdates() when a new version is waiting */
.update-banner {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.45);
  max-width: 92vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toast-in 0.25s ease-out;
}

.hidden {
  display: none !important;
}

/* scrollbars (desktop) */
.msgs::-webkit-scrollbar,
.room-list::-webkit-scrollbar {
  width: 8px;
}
.msgs::-webkit-scrollbar-thumb,
.room-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
