/*
 *  Auto Roll Tables - application shell
 *  Muted-blue theme, dark by default with a light option in Settings.
 */

/* ============================================================
   Tokens
   ============================================================ */
:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;

  /* dark (default) */
  --bg: #131d25;
  --bg-panel: #18232d;
  --bg-raised: #20303d;
  --bg-hover: #294050;
  --border: #2e475c;
  --text: #e1e9ef;
  --text-dim: #a8bccb;
  --text-faint: #74899a;
  --accent: #7fb0d8;
  --accent-soft: rgba(127, 176, 216, 0.15);
  /* the panel fill at 75%, so the background mark reads through the chrome */
  --bg-panel-75: rgba(24, 35, 45, 0.75);
  --accent-text: #0f1922;
  --danger: #e08a7d;
  --success: #86b98a;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.5);

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 244px;
  --sidebar-collapsed-w: 58px;
  --tabbar-h: 58px;
}

:root[data-theme="light"] {
  --bg: #e1e9ef;
  --bg-panel: #f1f6f9;
  --bg-raised: #ffffff;
  --bg-hover: #d2e0ea;
  --border: #abc2d4;
  --text: #131d25;
  --text-dim: #4a6076;
  --text-faint: #7b93a6;
  --accent: #2a6291;
  --accent-soft: rgba(42, 98, 145, 0.12);
  --bg-panel-75: rgba(241, 246, 249, 0.75);
  --accent-text: #ffffff;
  --danger: #a8402f;
  --success: #4f7238;
  --shadow: 0 6px 22px rgba(46, 71, 92, 0.16);
}

/* ============================================================
   Reset / base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { height: 100%; }
body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; font-weight: 600; }
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { color: var(--text); font-weight: 600; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   App shell
   ============================================================ */
/* ---------- Background mark ---------- */
/* The ampersand sits between the body fill and the app, so every panel above
   it can be translucent and let it through. The artwork is near-black ink on
   transparent, which would vanish against the dark theme, so it is inverted
   there rather than being given a second colour. */
.bgimage {
  margin: -10em;
  position: fixed;
  z-index: 0;
  /* opacity by design */
  opacity: 0.03;
  pointer-events: none;
}
.bgimage img {
  max-width: none;
  filter: invert(1);
}
:root[data-theme="light"] .bgimage img { filter: none; }

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}
#app.sidebar-collapsed { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }

/* ---------- Sidebar ---------- */
#sidebar {
  background: var(--bg-panel-75);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-head .logo {
  width: 30px;
  height: 30px;
  flex: none;
  object-fit: contain;
}
.sidebar-head .title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.sidebar-head .collapse-btn { margin-left: auto; }

#nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 12px 10px 5px;
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-top: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.92rem;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ic { width: 18px; height: 18px; flex: none; }
.nav-item .ext { margin-left: auto; width: 12px; height: 12px; color: var(--text-faint); }
.nav-item .count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.nav-item.active .count { color: var(--accent); }

.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; }

#app.sidebar-collapsed .sidebar-head .title,
#app.sidebar-collapsed .nav-group-label,
#app.sidebar-collapsed .nav-item span,
#app.sidebar-collapsed .nav-item .ext,
#app.sidebar-collapsed .nav-item .count { display: none; }
#app.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
#app.sidebar-collapsed .sidebar-head { justify-content: center; }
#app.sidebar-collapsed .sidebar-head .collapse-btn { margin-left: 0; }
#app.sidebar-collapsed .sidebar-head .logo { display: none; }
#app.sidebar-collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ---------- Main ---------- */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px clamp(12px, 2vw, 24px) 16px;
  min-width: 0;
}
.tool-header {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tool-header h1 { font-size: 1.45rem; color: var(--accent); }
.tool-header .sub { color: var(--text-dim); font-size: 0.86rem; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

/* ============================================================
   Roll UI: list pane + results pane
   ============================================================ */
.roll-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 320px) 1fr;
  gap: 14px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel-75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.pane-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.pane-body { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Filter ---------- */
.filter-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.filter-wrap .ic-search {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
#filter {
  width: 100%;
  padding: 7px 30px 7px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
#filter::placeholder { color: var(--text-faint); }
#filter-clear {
  position: absolute;
  right: 4px;
  border: 0;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
#filter-clear:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- Roll list ---------- */
#left-display-list { padding: 6px; }
.list-item {
  position: relative;
  padding: 7px 30px 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
  transition: background 0.1s, color 0.1s;
}
.list-item + .list-item { margin-top: 1px; }
.list-item:hover { background: var(--bg-hover); color: var(--text); }
.list-item.list-selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
/* entries whose title starts with "- " are sub-tables of the entry above */
.list-item.sub-item { padding-left: 22px; }
.list-item .subtext {
  display: block;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 400;
}
.list-item.list-selected .subtext { color: var(--accent); opacity: 0.75; }

.list-item .dofavorite {
  position: absolute;
  right: 3px;
  /* centred on the row rather than pinned to the top, so it still sits in the
     middle of entries that wrap onto a second line */
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.1s, color 0.1s, background 0.1s;
}
.list-item:hover .dofavorite,
.list-item .dofavorite.favorite { opacity: 1; }
.list-item .dofavorite.favorite { color: var(--accent); }
.list-item .dofavorite:hover { color: var(--accent); background: var(--bg-hover); }
.dofavorite:before { content: "\2606"; }
.dofavorite.favorite:before { content: "\2605"; }

.list-empty { padding: 26px 14px; text-align: center; color: var(--text-faint); font-size: 0.86rem; }

/* ---------- Custom tables ---------- */
.list-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 14px 10px 5px;
}
.list-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
#left-display-list > .list-group-label:first-child { padding-top: 6px; }

.badge-custom {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
  white-space: nowrap;
}

.list-item .edit-custom {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  padding: 0;
}
.list-item:hover .edit-custom,
.list-item.list-selected .edit-custom { opacity: 1; }
.list-item .edit-custom:hover { background: var(--bg-hover); color: var(--accent); }
.list-item .edit-custom svg { width: 14px; height: 14px; }

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  /* the map generators put several controls here, which will not fit on one
     line on a phone */
  flex-wrap: wrap;
}

/* ---------- Result tabs ---------- */
.result-tabs { display: flex; gap: 2px; flex: 1; }
.result-tab {
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.result-tab:hover { background: var(--bg-hover); color: var(--text); }
.result-tab.active { background: var(--bg-raised); color: var(--text); font-weight: 600; }
.pane-head .spacer { flex: 1; }

/* ---------- Result body ---------- */
.rightview { padding: 14px 16px; font-size: 0.94rem; }
.rightview[hidden] { display: none; }
#rightview-history-display { padding: 8px; }

.roll-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}
.roll-suggested-use { font-style: italic; color: var(--text-dim); }
.indent { margin-left: 18px; padding-left: 10px; border-left: 2px solid var(--border); }

.result-empty { color: var(--text-faint); text-align: center; padding: 48px 20px; }
.result-empty .big { font-size: 2rem; opacity: 0.5; margin-bottom: 8px; }

/* ---------- History accordion ---------- */
.for-copy { display: none; }

div.accordion {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  padding: 9px 11px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  transition: background 0.1s, border-color 0.1s;
}
div.accordion:first-child { margin-top: 0; }
div.accordion:hover { background: var(--bg-hover); border-color: var(--text-faint); }
div.accordion.active { border-color: var(--accent); }

div.panel {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  display: none;
  margin: -1px 0 0;
}
div.panel.show { display: block; }

div.history-item-menu { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
div.delete-history-item,
div.expand-collapse {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 0.9rem;
  line-height: 1;
}
div.delete-history-item:hover { background: var(--bg-hover); color: var(--danger); }
div.expand-collapse:hover { background: var(--bg-hover); color: var(--text); }

/* icon glyphs (replaces the old icon font) */
.glyphicon { display: inline-block; font-style: normal; line-height: 1; }
.glyphicon-chevron-down:before { content: "\25BE"; }
.glyphicon-chevron-up:before { content: "\25B4"; }
.glyphicon-trash:before { content: "\2715"; }
.glyphicon-ok:before { content: "\2713"; }
.glyphicon-remove:before { content: "\2715"; }

/* the copy-source textareas are never shown to the user, but they must stay
   selectable for document.execCommand('copy') to work */
.display { position: absolute; left: -10000px; top: 0; width: 600px; height: 200px; }

/* ============================================================
   Components
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.icon-btn { padding: 6px; }
.btn.icon-btn svg { width: 16px; height: 16px; }
.btn.small { padding: 4px 9px; font-size: 0.78rem; }
.btn svg { width: 15px; height: 15px; flex: none; }

input[type="text"], input[type="search"], select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav-item:focus-visible,
.result-tab:focus-visible, .tab-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.card {
  background: var(--bg-panel-75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 1.08rem; color: var(--accent); margin-bottom: 10px; }
.card h3 { font-size: 0.95rem; margin: 12px 0 5px; }
.card p + p { margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--text-dim); max-width: 320px; }
.field + .field { margin-top: 14px; }

/* Buttons sitting next to each other need a flex row: as inline-flex siblings
   they align on their text baselines, which differ once one of them has an
   icon, leaving them a few pixels out. */
.row,
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.btn-row { margin-top: 12px; }

/* ---------- Segmented toggle ---------- */
.segmented {
  display: inline-flex;
  align-self: flex-start;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.86rem;
  white-space: nowrap;
}
.seg svg { width: 15px; height: 15px; flex: none; }
.seg:hover { background: var(--bg-hover); color: var(--text); }
.seg.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg.active:hover { background: var(--accent); filter: brightness(1.06); }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 0.83rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; align-items: start; }

/* ---------- Page footer ---------- */
.page-foot {
  flex: none;
  margin-top: 10px;
  padding-top: 8px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-faint);
}
.page-foot a { color: var(--text-dim); }
.page-foot a:hover { color: var(--accent); }
.page-foot .sep { margin: 0 6px; opacity: 0.6; }

/* ---------- Alerts ---------- */
#alerts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  box-shadow: var(--shadow);
  font-size: 0.87rem;
  color: var(--text);
  white-space: nowrap;
}
.alert-success { border-left-color: var(--success); }
.alert-success .glyphicon { color: var(--success); }
.alert-danger { border-left-color: var(--danger); }
.alert-danger .glyphicon { color: var(--danger); }

/* ============================================================
   Modal (custom table editor)
   ============================================================ */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: min(86dvh, 760px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.modal form { display: flex; flex-direction: column; max-height: inherit; }
.modal-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal-head h2 { font-size: 1.08rem; color: var(--accent); }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body .field { max-width: none; }
.modal-body .field.wide textarea { width: 100%; resize: vertical; font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.5; }
.modal-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
}
.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex: none;
}
.modal-foot .spacer { flex: 1; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: none; font-weight: 600; }
.danger-text { color: var(--danger); }
.danger-text:empty { display: none; }

/* ============================================================
   Settings view
   ============================================================ */
.settings-view { overflow-y: auto; padding-right: 4px; }
.settings-view .card:last-child { margin-bottom: 0; }
.attrib-names { font-size: 0.84rem; color: var(--text-dim); line-height: 1.7; }

/* ============================================================
   Mobile: bottom tab bar
   ============================================================ */
#tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-panel-75);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.tab-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  /* six tabs share one row, so the labels have to stay narrow */
  font-size: 0.58rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  padding: 0 2px;
}
.tab-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-item svg { width: 20px; height: 20px; }
.tab-item.active { color: var(--accent); }
.tab-item:hover { text-decoration: none; }

#more-sheet {
  display: none;
  position: fixed;
  inset: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  background: var(--bg);
  z-index: 30;
  overflow-y: auto;
  padding: 16px;
}
#more-sheet.open { display: block; }
.more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.more-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: center;
  text-decoration: none;
}
.more-tile svg { width: 23px; height: 23px; color: var(--accent); }
.more-tile:active { background: var(--bg-hover); }
.more-tile:hover { text-decoration: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 899px) {
  /* the collapsed selector has to be repeated here: #app.sidebar-collapsed is
     more specific than #app, so without it a sidebar collapsed on desktop
     would keep its narrow column after the viewport drops to mobile and
     squeeze the whole page into it */
  #app, #app.sidebar-collapsed { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #tabbar { display: flex; }
  #main {
    overflow-y: auto;
    padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px);
  }
  /* #main scrolls here rather than the panes, so the view has to be as tall as
     its content. Left at flex:1 it is squashed to the leftover height, the
     panes spill out of the bottom of it, and the footer is laid out over the
     spill instead of below it. */
  .view { display: block; flex: none; }
  .roll-layout { display: block; }
  /* the mark is drawn at natural size, which swamps a phone screen */
  .bgimage img { width: 500px; }
  .roll-layout .pane + .pane { margin-top: 12px; }
  .pane { max-height: none; }
  #left-display-list { max-height: 46vh; }
  #rightview-current-display, #rightview-history-display { max-height: 62vh; }
  .tool-header h1 { font-size: 1.25rem; }
  /* let the controls use the full width and wrap instead of running off the
     side of the screen */
  .header-actions { margin-left: 0; width: 100%; }
  #alerts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
}

@media (min-width: 900px) {
  .mobile-only { display: none !important; }
}

@media print {
  #sidebar, #tabbar, #more-sheet, .pane-head, #alerts { display: none !important; }
  #app { display: block; height: auto; }
  #main { overflow: visible; display: block; }
  .roll-layout { display: block; }
  .pane { border: 0; }
}
