body {
  font-family: system-ui, sans-serif;
  margin: 24px;
}

/* ===== ログイン画面 ===== */
.loginScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  /* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loginCard {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.loginError {
  background: #fee2e2;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 24px;
  font-size: 14px;
  border: 1px solid #fecaca;
}
.card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  cursor: pointer;
}
.btn.outline {
  background: #fff;
  color: #111;
}
.btn.ghost {
  background: #fff;
  color: #111;
  border-color: #e5e7eb;
}
.btn.danger {
  background: #b91c1c;
  border-color: #b91c1c;
}
.log {
  white-space: pre-wrap;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 10px;
  height: 160px;
  overflow: auto;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.wrap {
  white-space: pre-wrap;
  word-break: break-word;
}
label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
input[type="text"] {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

/* ===== テーブル ===== */
.tableCard .toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.sheet {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow-x: hidden;
}
.sheetHeader {
  display: grid;
  grid-template-columns: 64px 1.1fr 1.9fr 96px 136px;
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.headerCellNo {
  text-align: center;
  padding-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheetBody {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
}
.sheetRow {
  display: grid;
  grid-template-columns: 64px 1.1fr 1.9fr 96px 136px;
  padding: 16px;
  border-top: 1px solid #eef2f7;
  align-items: flex-start;
}
.cellNo {
  text-align: center;
  color: #6b7280;
  padding-right: 8px;
}
.cellTitle,
.cellContent {
  white-space: pre-wrap;
  word-break: break-word;
}
.cellActions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex-direction: column;
}
.iconBtn {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
}
.iconBtn:hover {
  background: #f3f4f6;
  border-color: #e5e7eb;
}
.muted {
  color: #6b7280;
  font-size: 12px;
}
.hidden {
  display: none !important;
}
.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
}

/* ===== ハイライト ===== */
mark.highlight {
  background: #fff59d;
  padding: 0 0.1em;
}
.highlight-edit {
  background: #c8e6c9;
  transition: background 2s ease-out;
}
.highlight-replace {
  background: #ffe082;
  animation: pulse 1s ease-in-out 2;
}
@keyframes pulse {
  0% {
    background: #ffe082;
  }
  50% {
    background: #ffd54f;
  }
  100% {
    background: #ffe082;
  }
}

/* 差分色 */
.diff-del {
  background: #fee2e2;
  color: #b91c1c;
  text-decoration: line-through;
}
.diff-add {
  background: #dcfce7;
  color: #166534;
}

/* ===== モーダル共通 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal.show {
  display: flex;
}
.panel {
  width: min(1200px, 96vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}
.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  border-radius: 10px 10px 0 0;
}
.panel .content {
  padding: 20px 24px;
  overflow: auto;
  flex: 1 1 auto;
}

/* 履歴行 */
.histRow {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 90px 120px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
}
.histHead {
  font-weight: 700;
  color: #374151;
}
.link {
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
}

/* ===== 編集モーダルをより大きく ===== */
#editModal .panel {
  width: min(1400px, 98vw);
  max-height: 92vh;
}

/* 編集フォーム + ライブ差分 */
.fgroup {
  margin: 0 0 24px;
}
.flabel {
  color: #374151;
  font-size: 14px;
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}
.textarea,
.input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.6;
  resize: vertical;
  background: #fff;
}
.textarea {
  min-height: 120px;
}
.counter {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  text-align: right;
}
.over {
  color: #b91c1c;
}
.btnRow {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  /* margin: -20px -24px 0; */
  border-top: 1px solid #eee;
  background: #fafafa;
  border-radius: 0 0 10px 10px;
}

.diffWrap {
  position: relative;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.diffWrap:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.diffGhost {
  position: absolute;
  inset: 2px;
  overflow: hidden;
  padding: 10px 12px;
  border-radius: 6px;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  color: #111;
  background: #fff;
  border: none;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  margin: 0;
  box-sizing: border-box;
  width: 100%;
}
.textarea.diffHost {
  position: relative;
  background: transparent !important;
  color: transparent;
  caret-color: #111;
  border: none;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-word;
  resize: none;
  overflow: auto;
  margin: 0;
}
.addred {
  color: #dc2626;
}

/* グローバル進捗バー */
.gprogress {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3500;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gprogress progress {
  width: 220px;
}
.gprogress .label {
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
}

/* ハルシネーション警告 */
.hl-risk {
  text-decoration: underline wavy #ef4444 2px;
  text-underline-offset: 3px;
}
.hl-warn {
  text-decoration: underline wavy #f59e0b 2px;
  text-underline-offset: 3px;
}
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.red {
  background: #fee2e2;
  color: #b91c1c;
}
.badge.amber {
  background: #fef3c7;
  color: #92400e;
}
