body {
  --button-passive: #e9f1ff;
  --button-passive-border: #c8d8f3;
  --button-passive-hover: #dfeaff;
  --button-active: var(--accent);
  --button-active-border: var(--accent);
  --button-active-text: #fff;
  --chrome-bg: rgba(244, 246, 251, 0.96);
}

.tab-btn {
  background: var(--button-passive);
  border-color: var(--button-passive-border);
  color: var(--accent-strong);
}

.tab-btn.active {
  background: var(--button-active);
  border-color: var(--button-active-border);
  color: var(--button-active-text);
}

#tabEditor.active:not(:focus):not(:active) {
  background: var(--button-passive) !important;
  border-color: var(--button-passive-border) !important;
  color: var(--accent-strong) !important;
}

#tabEditor:focus,
#tabEditor:active {
  background: var(--button-active) !important;
  border-color: var(--button-active-border) !important;
  color: var(--button-active-text) !important;
}

.topbar {
  z-index: 30;
}

.topbar-actions {
  position: relative;
  z-index: 31;
}

.project-switcher,
#currentProjectSelect {
  pointer-events: auto;
  touch-action: manipulation;
}

.project-switcher {
  position: relative;
  z-index: 32;
}

#currentProjectSelect {
  min-height: 2.75rem;
}

/* Make the editable text the primary element of the editor view. */
#editorView .editor-layout {
  display: grid;
  grid-template-columns: minmax(13rem, 0.8fr) minmax(0, 2.4fr) minmax(13rem, 0.8fr);
  grid-template-areas: "tasks text person";
  gap: 1rem;
  align-items: start;
}

#editorView .editor-task-panel {
  grid-area: tasks;
}

#editorView .editor-text-panel {
  grid-area: text;
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

#editorView .editor-person-panel {
  grid-area: person;
}

#editorView .editor-textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: clamp(28rem, 62vh, 52rem);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
}

#editorView .editor-textarea:disabled {
  background: #f7f9fc;
  color: var(--muted);
}

/* Tablet upload fallback: after file selection the user must be able to submit the DOCX upload. */
#homeView button[type="submit"][data-i18n="project.loadDocx"] {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  width: fit-content;
}

@media (max-width: 1100px) {
  #editorView .editor-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "text"
      "tasks"
      "person";
  }

  #editorView .editor-textarea {
    min-height: clamp(24rem, 58vh, 46rem);
  }
}

@media (max-width: 1024px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
  }

  .project-switcher {
    display: grid;
    flex: 1 1 100%;
    gap: 0.25rem;
    width: 100%;
  }

  #currentProjectSelect {
    font-size: 1rem;
    min-height: 3rem;
    min-width: 0;
    width: 100%;
  }

  .mode-tabs {
    z-index: 5;
  }

  #projectForm {
    gap: 0.9rem;
  }

  #homeView .field-inline {
    grid-template-columns: minmax(0, 1fr) 3.25rem;
    align-items: stretch;
  }

  #pickDocxFile,
  #docxPicker,
  #homeView button[type="submit"][data-i18n="project.loadDocx"] {
    min-height: 3.25rem;
    touch-action: manipulation;
  }

  #homeView button[type="submit"][data-i18n="project.loadDocx"] {
    display: inline-flex !important;
    width: 100%;
  }
}

@media (max-width: 620px) {
  #editorView .editor-textarea {
    min-height: 55vh;
    padding: 0.85rem;
    font-size: 0.95rem;
  }
}
