:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1a1d21;
  --muted: #68707a;
  --line: #d8d4cc;
  --strong-line: #9f9589;
  --accent: #245b4f;
  --accent-soft: #e5f0ec;
  --warn: #8a5a00;
  font-family: Arial, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 42px);
}

.brand {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1;
  margin-bottom: 0;
}

h2 {
  font-size: 1.08rem;
  margin-bottom: 6px;
}

p {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

main {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 1300px;
  padding: 18px clamp(12px, 3vw, 30px) 40px;
}

.status {
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  max-width: 420px;
  min-width: 190px;
  padding: 10px 12px;
  text-align: right;
}

.panel,
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.panel {
  padding: 18px;
}

.section-heading {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.judgment-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) auto auto;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
button {
  background: #fff;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 9px 11px;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

button:disabled {
  background: #9aa39f;
  border-color: #9aa39f;
  cursor: progress;
}

.secondary-button {
  background: #fff;
  border-color: var(--strong-line);
  color: var(--ink);
}

input:focus,
button:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.toggle {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 8px;
  min-height: 42px;
  padding: 9px 11px;
}

.toggle input {
  min-height: auto;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.summary-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
}

.summary-card span,
.flow-item span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-card strong {
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.flow-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.flow-item {
  background: #f8f7f4;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 7px;
  padding: 12px;
}

.flow-item strong {
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.params-list {
  display: grid;
  gap: 8px;
}

.param-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: 22px minmax(170px, 0.35fr) minmax(220px, 1fr);
  min-height: 48px;
  padding: 9px 12px;
}

.param-row input {
  min-height: auto;
  padding: 0;
}

.param-row strong {
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.param-value {
  border-radius: 4px;
  cursor: text;
  min-height: 28px;
  padding: 4px 6px;
}

.param-value:hover {
  background: var(--accent-soft);
}

.param-edit {
  min-height: 34px;
  padding: 6px 8px;
  width: 100%;
}

#preview-panel.panel {
  background: rgba(47, 50, 53, 0.58);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  inset: 0;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 950;
}

#preview-panel.hidden {
  display: none;
}

#preview-panel > .section-heading,
#preview-panel > .editor-toolbar,
#preview-panel > .docx-preview {
  max-width: 980px;
  width: min(100%, 980px);
}

.preview-heading {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  margin: 0;
  padding: 18px;
}

.preview-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.editor-toolbar {
  align-items: center;
  background: #f8f7f4;
  border: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  gap: 6px;
  padding: 10px 18px;
}

.editor-tool {
  align-items: center;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  display: inline-flex;
  justify-content: center;
  min-height: 34px;
  min-width: 38px;
  padding: 6px 8px;
}

.docx-preview {
  background: #fff;
  border: 1px solid var(--strong-line);
  border-radius: 0 0 8px 8px;
  color: var(--ink);
  font: 0.98rem/1.55 Georgia, "Times New Roman", serif;
  min-height: min(62vh, 620px);
  max-height: 62vh;
  overflow: auto;
  padding: 22px;
  resize: vertical;
  white-space: pre-wrap;
}

.docx-preview:focus {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.hidden {
  display: none;
}

.loading-overlay {
  align-items: center;
  background: rgba(47, 50, 53, 0.58);
  backdrop-filter: grayscale(0.8) blur(3px);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
  display: grid;
  gap: 16px;
  max-width: 520px;
  padding: 26px;
  width: min(100%, 520px);
}

.loading-animation {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, 1fr);
  height: 74px;
  overflow: hidden;
}

.loading-animation span {
  animation: loading-wave 1.08s ease-in-out infinite;
  background: linear-gradient(180deg, #245b4f 0%, #d7a642 100%);
  border-radius: 6px;
  transform-origin: bottom;
}

.loading-animation span:nth-child(2) {
  animation-delay: 0.12s;
}

.loading-animation span:nth-child(3) {
  animation-delay: 0.24s;
}

.loading-animation span:nth-child(4) {
  animation-delay: 0.36s;
}

.loading-copy {
  display: grid;
  gap: 6px;
}

.loading-kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.loading-copy h2 {
  font-size: 1.45rem;
  margin: 0;
}

.loading-progress {
  background: #e2ded6;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.loading-progress div {
  background: linear-gradient(90deg, #245b4f, #d7a642);
  border-radius: inherit;
  height: 100%;
  transition: width 360ms ease;
  width: 8%;
}

.loading-steps {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.loading-steps li {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  gap: 10px;
  grid-template-columns: 18px 1fr;
}

.loading-steps li::before {
  background: #c8c2b8;
  border-radius: 50%;
  content: "";
  height: 10px;
  justify-self: center;
  width: 10px;
}

.loading-steps li.active {
  color: var(--ink);
  font-weight: 800;
}

.loading-steps li.active::before {
  animation: loading-pulse 900ms ease-in-out infinite;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(36, 91, 79, 0.14);
}

.loading-steps li.done {
  color: #41524c;
}

.loading-steps li.done::before {
  background: #d7a642;
}

body.is-loading {
  overflow: hidden;
}

body.is-modal-open {
  overflow: hidden;
}

@keyframes loading-wave {
  0%,
  100% {
    transform: scaleY(0.34);
  }

  50% {
    transform: scaleY(1);
  }
}

@keyframes loading-pulse {
  0%,
  100% {
    transform: scale(0.88);
  }

  50% {
    transform: scale(1.1);
  }
}

@media (max-width: 900px) {
  .topbar,
  .section-heading {
    display: grid;
  }

  .status {
    max-width: none;
    text-align: left;
  }

  .judgment-form,
  .summary-grid,
  .flow-grid,
  .param-row {
    grid-template-columns: 1fr;
  }
}
