:root {
  color: #1f2937;
  background: #f3f4f6;
  font-family: Arial, sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid #1d4ed8;
  border-radius: 4px;
  color: white;
  background: #2563eb;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  border-color: #9ca3af;
  color: #1f2937;
  background: white;
}

.page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  margin: 0 auto;
  padding: 10px;
  overflow: hidden;
}

h1 {
  margin: 0 0 8px;
  font-size: 21px;
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.page-title span {
  color: #6b7280;
  font-size: 13px;
}

h2 {
  margin: 0;
  font-size: 17px;
}

.import-panel,
.panel {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
}

.import-panel {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.section-heading,
.panel-heading,
.import-actions,
.navigation,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-heading,
.panel-heading {
  justify-content: space-between;
}

#json-input {
  width: 100%;
  height: 56px;
  margin: 0;
  padding: 7px;
  resize: vertical;
  border: 1px solid #9ca3af;
  border-radius: 4px;
  font-family: Consolas, monospace;
  font-size: 14px;
}

#import-status.error {
  color: #b91c1c;
}

#import-status.success {
  color: #166534;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.workspace-toolbar button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
}

.review-layout {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(250px, 0.82fr) minmax(0, 1.12fr);
  gap: 8px;
}

#source-panel {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 5;
  width: min(520px, 100%);
  box-shadow: 8px 0 20px rgb(17 24 39 / 18%);
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 10px;
}

.text-view {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: auto;
  margin-top: 8px;
  overflow: auto;
  padding: 9px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  font-size: 15px;
  line-height: 1.5;
}

.text-view p {
  margin: 0 0 14px;
}

.text-view p:last-child {
  margin-bottom: 0;
}

.muted {
  color: #6b7280;
  font-size: 13px;
}

.sentence-token {
  display: inline;
  padding: 1px 0;
  border-radius: 2px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.sentence-token:hover {
  box-shadow: inset 0 -2px 0 #9ca3af;
}

.sentence-token.active {
  position: relative;
  z-index: 1;
  outline: none;
  box-shadow: inset 0 -3px 0 #2563eb;
}

.sentence-token.operation-replace {
  background: #fef08a;
}

.sentence-token.operation-insert {
  background: #dbeafe;
}

.sentence-token.operation-delete {
  color: #991b1b;
  background: #fee2e2;
  text-decoration: line-through;
}

.sentence-token.accepted {
  color: inherit;
  background: #dcfce7;
  text-decoration: none;
}

.sentence-token.source-insertion-marker {
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.suggestion-card {
  flex: 1;
  min-height: 0;
  margin-top: 8px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
}

.suggestion-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.field-label {
  display: block;
  margin: 8px 0 3px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

.quote,
.replacement-input {
  width: 100%;
  padding: 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.replacement-input {
  min-height: 74px;
  resize: vertical;
  background: white;
}

.paragraph-option {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 13px;
}

.paragraph-option input {
  width: 17px;
  height: 17px;
}

.button-row {
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.suggestion-card .button-row button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
}

.button-row .keep-button {
  border-color: #6b7280;
  color: #1f2937;
  background: white;
}

.button-row .delete-button {
  border-color: #b91c1c;
  background: #b91c1c;
}

.button-row .insert-button {
  border-color: #2563eb;
  color: #1d4ed8;
  background: white;
}

.editor-error {
  margin-top: 7px;
  color: #b91c1c;
  font-size: 12px;
}

.decision-note {
  margin-top: 7px;
  color: #166534;
  font-size: 13px;
}

.navigation {
  justify-content: space-between;
  margin-top: 5px;
}

.navigation button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border: 1px solid #9ca3af;
  border-radius: 2px;
}

.replace-color {
  background: #fef08a;
}

.delete-color {
  background: #fee2e2;
}

.insert-color {
  background: #dbeafe;
}

.accepted-color {
  background: #dcfce7;
}

.prompt-dialog {
  width: min(820px, calc(100vw - 24px));
  height: min(720px, calc(100vh - 24px));
  padding: 12px;
  border: 1px solid #9ca3af;
  border-radius: 7px;
  background: white;
}

.prompt-dialog::backdrop {
  background: rgb(17 24 39 / 45%);
}

.prompt-heading,
.prompt-actions {
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.prompt-action-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-heading button,
.prompt-actions button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.prompt-text {
  width: 100%;
  height: calc(100% - 82px);
  margin: 10px 0;
  padding: 10px;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .page {
    padding: 6px;
  }

  h1 {
    margin-bottom: 5px;
    font-size: 18px;
  }

  .import-panel {
    grid-template-columns: auto minmax(80px, 1fr) auto;
    gap: 5px;
    padding: 5px;
  }

  .import-actions {
    max-width: 150px;
    flex-wrap: wrap;
  }

  .import-actions button {
    min-height: 32px;
    padding: 5px 8px;
  }

  #import-status {
    display: none;
  }

  .workspace {
    margin-top: 5px;
  }

  .review-layout {
    gap: 5px;
  }

  .panel {
    padding: 6px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .panel-heading #copy-button {
    min-height: 30px;
    padding: 4px 7px;
  }

  .text-view,
  .suggestion-card {
    padding: 6px;
  }

  .button-row button,
  .navigation button {
    min-height: 28px;
    padding: 3px 6px;
    font-size: 12px;
  }
}
