:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #00ff41;
  --dim: #1f8f3a;
  --prompt: #00ff41;
  --err: #ff5555;
  --line: #0c3d18;
  --hi: #00ff41;
  --hi-fg: #000000;
  --key: #b6ff4d;
  --title-bg: #00ff41;
  --title-fg: #000000;
  --border: #00ff41;
  --input-bg: #000000;
  --input-fg: #00ff41;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Geeza Pro", monospace;
  font-size: 16px;
  line-height: 1.75;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 8px;
}

#log { flex: 1; overflow-x: auto; }

.row {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

.row[dir="rtl"] { text-align: right; }
.row[dir="ltr"] { text-align: left; }
.row[dir="auto"] { text-align: start; }
.row.err { color: var(--err); }
.row.meta { color: var(--dim); }
.row.cmd { color: var(--dim); }
.row a,
.dos-text[href] {
  color: inherit;
}

#line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  padding: 8px 0 6px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

#prompt {
  color: var(--prompt);
  white-space: nowrap;
}

#cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--fg);
  font: inherit;
  caret-color: var(--prompt);
}

.lock {
  min-height: 100dvh;
  margin: 0;
  padding: 22vh 8vw 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.lock label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  width: min(28rem, 100%);
}

.lock span {
  color: var(--dim);
  user-select: none;
}

.lock input[type="password"],
.lock input[type="text"] {
  flex: 1;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  letter-spacing: 0.42em;
  caret-color: var(--fg);
}

.lock.is-bad span,
.lock.is-bad input[type="password"],
.lock.is-bad input[type="text"] {
  color: var(--err);
  caret-color: var(--err);
}

.lock-key,
.lock-codes {
  margin: 0 0 8px;
  color: var(--fg);
  letter-spacing: 0.18em;
  line-height: 1.8;
  user-select: text;
  white-space: pre-wrap;
}

.lock button {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

label { display: block; margin-top: 18px; }

input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  font: inherit;
  caret-color: var(--prompt);
}

input:focus { outline: none; border-bottom-color: var(--prompt); }

button {
  margin-top: 22px;
  padding: 6px 14px;
  background: transparent;
  color: var(--prompt);
  border: 1px solid var(--prompt);
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
#cmd:focus-visible {
  outline: 1px solid var(--prompt);
  outline-offset: 3px;
}

.err { color: var(--err); }

::selection {
  background: var(--hi);
  color: var(--hi-fg);
}

#mode-hint {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}

html:has(body.mode-dos),
body.mode-dos {
  background: var(--bg);
  color: var(--fg);
}

body.mode-dos #screen { display: none; }

#dos {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom));
}

.dos-box {
  max-width: 46rem;
  margin: 4vh auto 0;
  border: 4px double var(--border);
  background: var(--bg);
  min-height: 22rem;
  display: flex;
  flex-direction: column;
}

.dos-title {
  margin: 0;
  padding: 6px 12px;
  background: var(--title-bg);
  color: var(--title-fg);
  text-align: center;
  font-weight: 400;
  font-size: 1rem;
}

.dos-body {
  flex: 1;
  padding: 14px 8px 8px;
  overflow-x: auto;
}

.dos-preview {
  max-width: 46rem;
  margin: 18px auto 0;
}

.dos-item {
  display: flex;
  direction: inherit;
  gap: 14px;
  margin: 2px 4px;
  padding: 1px 10px;
  width: calc(100% - 8px);
  cursor: pointer;
}

.dos-key {
  width: 2ch;
  color: var(--key);
  flex: none;
}

.dos-swatch {
  width: 1.1rem;
  height: 0.7rem;
  margin-top: 0.45rem;
  border: 1px solid var(--border);
  flex: none;
}

.dos-item.on {
  background: var(--hi);
  color: var(--hi-fg);
}

.dos-item.on .dos-key { color: var(--hi-fg); }

.dos-item.motive-row {
  align-items: flex-start;
  gap: 10px;
  margin: 0 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.dos-item.motive-row .dos-key {
  width: 3ch;
  padding-top: 1px;
}

.dos-line {
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.dos-state {
  color: var(--dim);
  white-space: nowrap;
}

.dos-state.paused { color: var(--err); }

.dos-item.on .dos-state,
.dos-item.on .dos-state.paused { color: inherit; }

.motive-table {
  width: calc(100% - 8px);
  min-width: 0;
}

.motive-table td:not(.num) {
  max-width: none;
  white-space: normal;
}

.list-table {
  width: calc(100% - 8px);
  min-width: 0;
}

.list-table td:not(.num):not(.code) {
  max-width: none;
  white-space: normal;
}

.list-table tbody tr {
  cursor: pointer;
}

.list-table tbody tr.on td {
  background: var(--hi);
  color: var(--hi-fg);
}

.dos-text {
  margin: 0 8px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.dos-recap {
  list-style: none;
  margin: 8px 0 12px;
  padding: 0;
}

.qr-pad {
  display: inline-block;
  background: #fff;
  padding: 8px;
  margin: 8px;
}

.qr-pad svg {
  display: block;
}

.dos-text.err { color: var(--err); }
.dos-text.meta { color: var(--dim); }

.rate-table {
  width: max-content;
  min-width: calc(100% - 8px);
  margin: 4px 4px 14px;
  border-collapse: collapse;
  direction: rtl;
}

.rate-table th,
.rate-table td {
  border: 1px solid var(--line);
  padding: 3px 8px;
  text-align: right;
  white-space: nowrap;
}

.rate-table td:not(.num):not(.code) {
  white-space: normal;
  max-width: 16rem;
}

.rate-table .code {
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}

.rate-table th {
  color: var(--key);
  font-weight: 400;
}

.rate-table .num {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.rate-table .down { color: var(--err); }
.rate-table .flat { color: var(--dim); }

.account-table {
  width: calc(100% - 8px);
  min-width: 0;
}

.account-table th,
.account-table td {
  white-space: normal;
}

.account-table td.code {
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}

.gallery-preview {
  display: block;
  max-width: calc(100% - 16px);
  max-height: 18rem;
  margin: 0 8px 12px;
  object-fit: contain;
}

#dos-file {
  display: block;
  width: 100%;
  margin-top: 8px;
  color: var(--fg);
}

.dos-form { margin: 12px 8px 0; }

.dos-form label { display: block; margin: 0 0 8px; }

#dos-input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--input-bg);
  color: var(--input-fg);
  border: 1px solid var(--border);
  font: inherit;
  caret-color: var(--input-fg);
}

textarea#dos-input {
  min-height: 9rem;
  resize: vertical;
  line-height: 1.45;
}

.dos-status,
.dos-help {
  margin: 0;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 14px;
}

.dos-help {
  direction: ltr;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

.dos-word {
  margin: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
