:root {
  --bg: #1a1a1a;
  --bg-2: #242424;
  --bg-3: #2e2e2e;
  --fg: #e8e8e8;
  --fg-dim: #888;
  --accent: #5fb3d4;
  --tell: #d4a25f;
  --immortal: #d45f95;
  --pending-ok: #5fd49a;
  --pending-amber: #d4a25f;
  --pending-red: #d45f5f;
  --replay-opacity: 0.6;
  --pad: 8px;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-rows: auto 38fr 28px 62fr 44px 52px;
  height: 100vh;
  height: 100dvh;
}

.hidden { display: none !important; }

#pending-strip {
  padding: 6px var(--pad);
  background: var(--bg-2);
  border-bottom: 1px solid var(--bg-3);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#pending-strip.amber { color: var(--pending-amber); }
#pending-strip.red { color: var(--pending-red); }
#pending-strip .dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 8px;
}

.pane {
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.filters {
  display: flex;
  gap: 4px;
  padding: 4px var(--pad);
  border-bottom: 1px solid var(--bg-3);
  overflow-x: auto;
  flex-shrink: 0;
}
.filters button {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.filters button.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 4px var(--pad);
  -webkit-overflow-scrolling: touch;
}

#comms-list .row,
#text-list .row {
  padding: 2px 0;
  word-wrap: break-word;
  white-space: pre-wrap;
}
#comms-list .row.tell { border-left: 3px solid var(--tell); padding-left: 6px; }
#comms-list .row.immortal { border-left: 3px solid var(--immortal); padding-left: 6px; }
#comms-list .row.replay { opacity: var(--replay-opacity); }
#comms-list .row.outbound { font-style: italic; opacity: 0.85; }
#comms-list .row .char-tag { font-weight: bold; margin-right: 4px; }

#state-strip {
  padding: 4px var(--pad);
  background: var(--bg-2);
  border-top: 1px solid var(--bg-3);
  border-bottom: 1px solid var(--bg-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#input-row {
  display: flex;
  padding: 4px var(--pad);
  background: var(--bg-2);
  border-top: 1px solid var(--bg-3);
  gap: 4px;
}
#cmd-input {
  flex: 1;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 14px;
}
#cmd-send {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: 18px;
  cursor: pointer;
}

#tab-bar {
  display: flex;
  background: var(--bg-2);
  border-top: 1px solid var(--bg-3);
  overflow-x: auto;
  /* iPhone with home-indicator: keep tabs above the indicator. */
  padding-bottom: env(safe-area-inset-bottom);
}
#tab-bar .tab {
  flex: 1;
  text-align: center;
  padding: 14px 4px;
  font-size: 13px;
  background: none;
  color: var(--fg-dim);
  border: none;
  border-top: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
#tab-bar .tab.active {
  color: var(--fg);
  border-top-color: var(--accent);
}
#tab-bar .tab .badge { margin-right: 4px; }
#tab-bar .gear {
  background: none;
  color: var(--fg-dim);
  border: none;
  font-size: 18px;
  padding: 0 14px;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal .inner {
  background: var(--bg-2);
  padding: 16px;
  border-radius: var(--radius);
  width: 92%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 8px var(--pad);
  background: var(--pending-red);
  color: white;
  text-align: center;
  z-index: 50;
}
