:root {
  --bg: #f2f5fb;
  --panel: #ffffff;
  --line: #ccd5e8;
  --text: #1d2840;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "BIZ UDPGothic", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.app { max-width: 1280px; margin: 0 auto; padding: 16px; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button, select, input, textarea {
  font: inherit;
  border: 1px solid #b8c6e3;
  border-radius: 8px;
  padding: 7px 10px;
}
button { background: #eef3ff; color: #173680; cursor: pointer; }
button:hover { filter: brightness(0.97); }
button.danger { background: #ffeaea; border-color: #e5a0a0; color: #8a1f1f; }
.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; min-height: 78vh; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.panel-heading-with-action { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.panel-heading-with-action h2 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.editor-shell {
  border: 1px solid #b8c6e3;
  border-radius: 8px;
  min-height: 420px;
  max-height: 62vh;
  display: grid;
  grid-template-columns: 56px 1fr;
  overflow: hidden;
}
.line-numbers {
  background: #f5f7fc;
  border-right: 1px solid #d4dcee;
  color: #6a7695;
  text-align: right;
  padding: 10px 8px;
  white-space: pre;
  line-height: 1.6;
  user-select: none;
  overflow: hidden;
}
.replay-editor {
  padding: 10px;
  white-space: pre-wrap;
  overflow: auto;
  line-height: 1.6;
  color: #000;
}
.replay-editor:focus { outline: 2px solid #97ace6; }
.counted-range { font-weight: 600; }
.meta-row { margin-top: 8px; display: flex; gap: 16px; }
.participant-counter { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; flex-wrap: wrap; }
.participant-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(78vh - 80px);
}
.participant-card { border: 2px solid; border-radius: 10px; padding: 10px; }
.participant-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.participant-meta { font-size: 0.9rem; }
.playing-text {
  margin-top: 8px;
  max-height: 170px;
  overflow: auto;
  border: 1px solid #c5d0e8;
  border-radius: 8px;
  padding: 8px;
  white-space: pre-wrap;
  line-height: 1.5;
}
.participant-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.count-result, .proofread-result { margin-top: 8px; font-size: 0.92rem; white-space: pre-wrap; }
dialog { border: none; border-radius: 12px; padding: 0; width: min(900px, 92vw); }
dialog::backdrop { background: rgba(10, 14, 24, 0.55); }
dialog article, dialog form { padding: 16px; }
dialog label { display: block; margin: 8px 0; }
dialog h3 { margin: 14px 0 8px; }
.participant-form-list { display: grid; gap: 12px; max-height: 60vh; overflow: auto; margin: 10px 0; }
.participant-row { border: 1px solid #cbd6ee; border-radius: 10px; padding: 10px; display: grid; gap: 8px; }
.participant-row label { display: grid; gap: 6px; }
.participant-row textarea { min-height: 140px; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog-actions > div { display: flex; gap: 8px; }
.preview-body { border: 1px solid #cbd6ee; border-radius: 8px; padding: 12px; min-height: 200px; max-height: 70vh; overflow: auto; white-space: normal; line-height: 1.7; }
.preview-actions { display: flex; gap: 8px; margin-top: 10px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.preview-copy-feedback { margin: 8px 0 0; font-size: 0.9rem; color: #2a5d2a; min-height: 1.2em; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-panel {
  position: relative;
  width: min(540px, calc(100vw - 24px));
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.modal-panel input {
  width: 100%;
  border: 1px solid #d5dae2;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.modal-hint {
  margin: 0 0 10px;
  color: #475569;
  font-size: 0.9rem;
}

.search-results {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 280px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}

.search-result-button {
  width: 100%;
  border: 1px solid #d5dae2;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.search-empty {
  color: #64748b;
  padding: 6px;
}
