:root {
  --accent: #770000;
  --accent-hover: #aa0000;
  --border-color: #ccc;
  --header-bg: #eee;
  --header-fg: #333;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: Arial, Helvetica, sans-serif;
  background: #fff;
  color: #222;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

#toolbar button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}

#toolbar button:hover {
  background: var(--accent-hover);
}

#mode-select {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

#mode-select:hover {
  background: var(--accent-hover);
}

#toolbar button.active {
  background: white;
  color: var(--accent);
}

.tb-label {
  font-size: 11px;
  text-transform: uppercase;
  opacity: 0.6;
  letter-spacing: 0.05em;
}

.tb-sep {
  width: 1px;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}

#cursor-pos {
  font-family: monospace;
  font-size: 12px;
  opacity: 0.7;
}

/* Chromium only - Firefox has no handle to remember, see script.js. */
#reopen-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  flex: 0 0 auto;
}

#reopen-banner[hidden] {
  display: none;
}

#reopen-banner-text {
  font-family: monospace;
}

#reopen-banner button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}

#reopen-banner button:hover {
  background: var(--accent-hover);
}

#reopen-banner-dismiss-btn {
  background: #999;
}

#reopen-banner-dismiss-btn:hover {
  background: #888;
}

/* Same tab look as spreadsheet-editor's sheet tabs, laid out horizontally instead of as a vertical rail. */
#tab-bar {
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
}

.tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-right: 1px solid var(--border-color);
  color: var(--header-fg);
  font-family: monospace;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Set when the tab is showing in either pane - doesn't distinguish which side. */
.tab.active {
  background: #fff;
  color: var(--accent);
  font-weight: bold;
}

.tab-dirty-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.tab-dirty-dot[hidden] {
  display: none;
}

.tab-close-btn {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex: 0 0 auto;
}

.tab-close-btn:hover {
  opacity: 1;
}

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

/* Ace fills each pane edge-to-edge; position:relative is required for its internal layers. */
.pane {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  position: relative;
}

.pane[hidden] {
  display: none;
}

/* The pane last clicked into - Save/Open/etc. act on its tab. */
.pane.focused {
  box-shadow: inset 0 0 0 2px var(--accent);
}

#split-divider {
  flex: 0 0 auto;
  width: 4px;
  background: var(--border-color);
}

#split-divider[hidden] {
  display: none;
}

/* pointer-events:none keeps this purely visual so it never becomes a drag target itself. */
#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(119, 0, 0, 0.15);
  border: 4px dashed var(--accent);
  pointer-events: none;
}

#drop-overlay[hidden] {
  display: none;
}

#drop-overlay span {
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#toast {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 2147483647;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 8px 14px;
  border-radius: 5px;
  font-family: monospace;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
}

.modal-backdrop[hidden] {
  display: none;
}

/* Matches the sibling apps' settings/shortcuts panel look. */
.modal-panel {
  background: #333;
  color: white;
  padding: 24px;
  border-radius: 8px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.modal-panel-wide {
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: bold;
}

.modal-panel label {
  font-size: 13px;
  opacity: 0.85;
}

.modal-note {
  margin: 0;
  font-size: 12px;
  opacity: 0.7;
}

.modal-panel input[type="text"],
.modal-panel input[type="number"],
.modal-panel select {
  font-family: monospace;
  font-size: 13px;
  padding: 6px 8px;
  border: none;
  border-radius: 3px;
  background: white;
  color: #222;
}

.modal-panel input[type="text"]:focus,
.modal-panel input[type="number"]:focus,
.modal-panel select:focus {
  outline: 2px solid var(--accent);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-field input[type="number"] {
  width: 100px;
}

.settings-field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.shortcuts-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
  font-size: 13px;
}

.shortcuts-list kbd {
  background: #222;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: monospace;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
}

.modal-actions button:hover {
  background: var(--accent-hover);
}

#filename-modal-cancel-btn,
#settings-cancel-btn {
  background: #555;
}

#filename-modal-cancel-btn:hover,
#settings-cancel-btn:hover {
  background: #666;
}
