:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --line: #dfe2e8;
  --accent: #4b5bd6;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --warn-bg: #fff3d6;
  --warn-text: #7a5300;
  --ok-bg: #e3f5ea;
  --ok-text: #1d6b3d;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card: #1b1e25;
    --text: #e9ebf0;
    --muted: #9aa1ad;
    --line: #2d313b;
    --accent: #8592ff;
    --accent-text: #0f1120;
    --danger: #ff7b6b;
    --warn-bg: #3a2f12;
    --warn-text: #ffd27a;
    --ok-bg: #143022;
    --ok-text: #8ee0ae;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
}
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0; }
[hidden] { display: none !important; }

.top {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.narrow { max-width: 420px; margin: 8vh auto 0; }

form { display: grid; gap: 14px; margin-top: 12px; }
label { display: grid; gap: 6px; font-weight: 500; }
input:not([type=checkbox]) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;            /* 16px keeps iOS from zooming on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  min-height: 44px;
  padding: 10px 14px;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: currentColor; }
.btn.ghost { border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

.row-head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 400; }
.check input { width: 20px; height: 20px; }
.search { margin-bottom: 12px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.tile { background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.tile b { display: block; font-size: 1.4rem; }
.tile span { color: var(--muted); font-size: .85rem; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.item.flagged { border-color: var(--warn-text); }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; grid-column: 1; }
.item .actions { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1; }
.badge, .chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--bg); color: var(--muted);
}
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.ok { background: var(--ok-bg); color: var(--ok-text); }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .85rem; margin: 12px 0 0; }
.error { color: var(--danger); margin: 0; }
.empty { color: var(--muted); padding: 12px 0; }

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
  padding: 12px 16px;
  background: var(--text); color: var(--bg);
  border-radius: 10px;
  text-align: center;
}

/* Phones: stack each session's actions under its details, full width. */
@media (max-width: 560px) {
  .item { grid-template-columns: 1fr; }
  .item .actions { grid-column: 1; grid-row: auto; order: 10; flex-direction: row; margin-top: 6px; }
  .item .actions .btn { flex: 1 1 0; min-width: 0; }
  .row-head > .btn, .tools { width: 100%; }
  .tools .btn { flex: 1; }
}

a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* Two-factor sign-in */
.steps { margin: 0.5rem 0 0.75rem; padding-left: 1.25rem; line-height: 1.6; }
.secret { display: block; margin: 0.5rem 0; padding: 0.6rem 0.75rem; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); font-size: 1.05rem; letter-spacing: 0.08em;
  word-break: break-all; user-select: all; }
.codes { margin: 0.5rem 0 0.75rem; padding: 0.75rem; border-radius: var(--radius); background: var(--bg);
  border: 1px solid var(--line); font-size: 1rem; line-height: 1.7; user-select: all; }
form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
form.inline input { flex: 1 1 8rem; min-width: 0; min-height: 44px; }
.nudge { margin: 0 0 0.75rem; padding: 0.75rem; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-text); line-height: 1.5; }
