.tm-toolbar,
.tm-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tm-toolbar {
  justify-content: space-between;
  margin: 10px 0 14px;
}

.tm-toolbar-button,
.tm-link,
.tm-draft {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
  min-height: 38px;
  padding: 7px 10px;
  text-align: left;
}

.tm-toolbar-button.is-selected {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.tm-toolbar-button:focus-visible,
.tm-link:focus-visible,
.tm-table-scroll:focus-visible,
.tm-field :is(input, textarea, select):focus-visible,
.tm-disease-option input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tm-comparison,
.tm-detail,
.tm-disease-links,
.tm-editor {
  color: var(--text);
  max-width: 100%;
  min-width: 0;
}

.tm-editor[hidden] {
  display: none !important;
}

.tm-note,
.tm-muted,
.tm-review-date,
.tm-table small {
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
}

.tm-note { margin: 8px 0 12px; }
.tm-message { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }

.tm-table-scroll {
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.tm-table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 920px;
  width: 100%;
}

.tm-table caption {
  color: var(--text2);
  padding: 10px;
  text-align: left;
}

.tm-table th,
.tm-table td {
  border-top: 1px solid var(--border);
  min-width: 100px;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tm-table thead th { background: var(--surface); font-weight: 700; }
.tm-table tbody th { min-width: 135px; }
.tm-table small { display: block; margin-top: 3px; }
.tm-row--missing { opacity: .8; }
.tm-row-state,
.tm-review-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tm-state,
.tm-review,
.tm-missing-link {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: inline-block;
  font-size: 11px;
  line-height: 1.4;
  padding: 2px 6px;
}
.tm-state--warning,
.tm-review--invalid { font-weight: 700; }
.tm-review--verified { color: var(--accent); }
.tm-link { min-height: 30px; margin: 2px; padding: 4px 7px; }
.tm-name { font-weight: 700; }
.tm-table a,
.tm-detail a { color: var(--accent); overflow-wrap: anywhere; }

.tm-editor h3,
.tm-detail h3,
.tm-disease-links h3 { font-size: 15px; margin: 10px 0 6px; }
.tm-editor-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tm-field { display: grid; gap: 5px; min-width: 0; }
.tm-field span { color: var(--text2); font-size: 12px; font-weight: 600; }
.tm-field input,
.tm-field textarea,
.tm-field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-sizing: border-box;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 9px;
  width: 100%;
}
.tm-field textarea { min-height: 68px; resize: vertical; }
.tm-diseases { border: 1px solid var(--border); border-radius: 8px; margin: 14px 0; min-width: 0; padding: 10px; }
.tm-diseases legend { color: var(--text2); font-size: 12px; padding: 0 5px; }
.tm-disease-grid { display: grid; gap: 7px; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 230px; overflow-y: auto; }
.tm-disease-option { align-items: flex-start; display: flex; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.tm-disease-option input { flex: none; margin-top: 3px; }
.tm-detail { border: 1px solid var(--border); border-radius: 10px; margin-top: 14px; padding: 12px; }
.tm-detail dl { margin: 0; }
.tm-detail-row { border-top: 1px solid var(--border); display: grid; gap: 8px; grid-template-columns: 120px minmax(0, 1fr); padding: 8px 0; }
.tm-detail-row dt { color: var(--text2); font-size: 12px; font-weight: 600; }
.tm-detail-row dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.tm-original { white-space: pre-wrap; }
.tm-disease-links { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }

@media (max-width: 767px) {
  .tm-toolbar { align-items: stretch; flex-direction: column; }
  .tm-toolbar-group { width: 100%; }
  .tm-toolbar-button { flex: 1 1 auto; }
  .tm-editor-grid,
  .tm-disease-grid { grid-template-columns: minmax(0, 1fr); }
  .tm-detail-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .tm-table { min-width: 850px; }
}
