:root {
  --bg: #fff;
  --fg: #000;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000; --fg: #fff; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #000; --fg: #fff; color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  outline: 0;
}
button { cursor: pointer; text-align: left; }
button:focus-visible { outline: 1px dashed var(--fg); }

#titlebar, kbd, #files .active, #status-text:not(:empty), #status.prompting {
  background: var(--fg);
  color: var(--bg);
}

#titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2ch;
  padding: 0 1ch;
  white-space: pre;
}
#modified { text-align: right; }

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#sidebar {
  display: flex;
  flex-direction: column;
  width: 22ch;
  flex-shrink: 0;
  padding: 0 1ch;
  border-right: 1px solid var(--fg);
}
#files {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
#files button {
  display: block;
  width: 100%;
  padding: 0 0 0 2ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sidebar .actions { margin-top: auto; display: flex; gap: 2ch; }

#editor {
  flex: 1;
  min-width: 0;
  padding: 0 1ch;
  resize: none;
  tab-size: 4;
  background: var(--bg);
}
#empty { flex: 1; padding: 0 1ch; }

#status {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  height: 1.4em;
  padding: 0 1ch;
  overflow: hidden;
  white-space: pre;
}
#status-text { grid-column: 2; }
#status.prompting { grid-template-columns: auto 1fr; }
#status.prompting #status-text { grid-column: auto; background: none; color: inherit; }
#prompt { flex: 1; min-width: 0; }

#shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17ch, 1fr));
  padding: 0 1ch;
}
#shortcuts button { white-space: nowrap; }
kbd { font: inherit; }
