:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #d7dde5;
  --text: #172033;
  --muted: #667085;
  --accent: #176b87;
  --accent-dark: #105168;
  --danger: #ad2f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(560px, 0.95fr) minmax(420px, 0.75fr);
  gap: 16px;
  padding: 16px;
}

.workbench,
.side {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.workbench {
  grid-template-rows: auto minmax(0, 1fr);
}

.side {
  grid-template-rows: auto minmax(480px, 1fr);
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.panel {
  min-height: 0;
  padding: 14px;
}

.panel-title {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.panel-title a {
  color: var(--accent);
  text-decoration: none;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: #344054;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #101828;
  background: #fff;
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 0;
  resize: none;
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.5;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.form-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.title-field textarea {
  height: 70px;
  margin-bottom: 12px;
  font-weight: 800;
}

.answers-form {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.answer-edit {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.answer-edit .badge {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.answer-edit textarea {
  height: 52px;
}

.badge.a {
  color: #333;
  background: #f1f1ef;
  border: 2px solid #8f8f8f;
}

.badge.b { background: #050505; }
.badge.c { background: #c91812; }
.badge.d { background: #0b4da1; }
.badge.e { color: #111; background: #d6ce00; }
.badge.f { background: #278a4d; }
.badge.g { background: #e8aa5d; }

.controls {
  display: grid;
  gap: 13px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.preview-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f4 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f4 75%),
    #fff;
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

iframe {
  display: block;
  position: absolute;
  flex: none;
  border: 0;
  background: transparent;
  transform-origin: top left;
}

.error {
  color: var(--danger);
}

@media (max-width: 1050px) {
  .app {
    grid-template-columns: 1fr;
  }

  .workbench {
    min-height: 760px;
  }

  .side {
    grid-template-rows: auto 620px;
  }
}

@media (max-width: 580px) {
  .app {
    padding: 10px;
  }

  .topbar {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
