:root {
  color-scheme: light;
  --paper: #f7f2ea;
  --ink: #25221f;
  --muted: #6b6258;
  --line: #ded2c3;
  --panel: #fffdf9;
  --accent: #2e6b63;
  --accent-2: #9f542c;
  --soft: #eaf2ef;
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
}

.button-link,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}

.status {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.status strong {
  color: var(--accent);
  font-size: 24px;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 104px);
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 44px) 56px;
}

.admin-panel,
.admin-detail {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  max-height: 100vh;
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
  align-self: start;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tab.is-active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.panel {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

.actions {
  display: grid;
  gap: 8px;
}

.admin-actions {
  grid-template-columns: 1fr 1fr;
  margin: 14px 0;
}

.admin-actions .button-link {
  grid-column: 1 / -1;
}

.outline {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
}

.outline button {
  width: 100%;
  min-height: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.outline .done {
  color: var(--accent);
}

.workspace {
  padding: 24px clamp(16px, 4vw, 44px) 56px;
  overflow: auto;
}

.view {
  max-width: 980px;
  margin: 0 auto;
}

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

.section-title h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

.question-section {
  display: grid;
  gap: 14px;
}

.question-section + .question-section {
  margin-top: 18px;
}

.question-section-heading {
  padding: 6px 2px 0;
}

.question-section-heading h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.question-section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.item.intro p,
.empty-state p {
  margin-bottom: 0;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.item h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.55;
}

.helper {
  margin: 10px 0 0;
  border-left: 3px solid var(--line);
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.helper strong {
  display: block;
  color: var(--accent-2);
  font-size: 12px;
}

.badge {
  align-self: flex-start;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

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

.danger {
  min-height: 30px;
  padding: 4px 8px;
  border-color: #e1b6a8;
  color: #8b3f2a;
  background: #fff8f5;
  font-size: 12px;
}

.empty-state {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
}

select {
  min-height: 46px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.65;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label span {
  color: var(--ink);
  font-weight: 700;
}

.snapshot-list {
  display: grid;
  gap: 10px;
}

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

.snapshot p {
  margin-bottom: 2px;
  font-weight: 700;
}

.snapshot small {
  color: var(--muted);
}

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

.respondent {
  display: grid;
  justify-items: start;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  text-align: left;
}

.respondent.is-active {
  background: var(--soft);
  border-color: var(--accent);
}

.respondent span {
  color: var(--muted);
  font-size: 12px;
}

.admin-editor {
  display: grid;
  gap: 14px;
}

.admin-editor textarea {
  min-height: 96px;
}

.family-admin-card {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.family-admin-card + .family-admin-card {
  margin-top: 14px;
}

.preview {
  white-space: pre-wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  line-height: 1.8;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 420px;
  padding: 22px;
}

dialog::backdrop {
  background: rgba(37, 34, 31, 0.38);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 18px 0 0;
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    padding: 20px 16px 16px;
  }

  .status {
    justify-items: start;
  }

  .layout {
    display: block;
  }

  .admin-layout {
    display: block;
    padding: 18px 14px 40px;
  }

  .admin-panel {
    margin-bottom: 18px;
  }

  .sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .actions {
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    grid-template-columns: 1fr 1fr;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: rgba(247, 242, 234, 0.96);
    box-shadow: 0 -8px 24px rgba(37, 34, 31, 0.12);
  }

  .sidebar .actions button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .sidebar .actions #adminBtn {
    display: none;
  }

  .outline {
    max-height: 120px;
    overflow: auto;
  }

  .workspace {
    padding: 18px 14px 128px;
  }

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

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