/* クイズ共通ヘッダー（Study Park） */
.app-header--unified {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  grid-template-areas:
    "logo title"
    "logo tools";
  column-gap: 10px;
  row-gap: 6px;
  align-items: start;
  padding: 10px 12px;
  overflow: visible;
  background: var(--surface);
  border-bottom: 2px solid var(--header-border, #d0d9e8);
}

.app-header--with-menu {
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "logo title menu"
    "logo tools tools";
}

.app-header--no-tools {
  grid-template-rows: auto;
  grid-template-areas: "logo title menu";
}

.app-header-logo-link {
  grid-area: logo;
  align-self: start;
  flex-shrink: 0;
  box-sizing: content-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  min-width: 3rem;
  min-height: 3rem;
  overflow: visible;
  background: transparent;
}

.app-header-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
}

.app-header-title {
  grid-area: title;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.app-header-menu {
  grid-area: menu;
  align-self: start;
  justify-self: end;
  z-index: 45;
}

.app-header-menu-placeholder {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
}

.app-header-toolbar {
  grid-area: tools;
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

/* 出題形式ラベル＋プルダウン＋更新・リセット */
.app-header-format-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
}

.format-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}

.format-field-label {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.app-header--unified .format-select {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  flex: 1 1 6.5rem;
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 2rem;
  padding: 5px 22px 5px 6px;
  border-radius: 8px;
  border: 2px solid var(--header-border, #d0d9e8) !important;
  background-color: var(--surface) !important;
  color: var(--ink) !important;
  cursor: pointer;
  -webkit-appearance: menulist;
  appearance: auto;
  box-sizing: border-box;
}

.app-header-format-row .app-header-utils {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.btn-header-util {
  font: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  border: 1px solid transparent;
}

.btn-header-util:active {
  transform: scale(0.97);
}

.btn-update {
  border-color: var(--header-border, #c5cae9);
  background: var(--header-util-bg, #e8eaf6);
  color: var(--accent-dark, #3949ab);
}

.btn-reset-weak {
  border-color: #ffe0b2;
  background: #fff8e1;
  color: #e65100;
}

.app-header-extra {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

/* 答えを見る・やめる を横並び */
.answer-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.answer-actions-row .btn-primary {
  flex: 1 1 8rem;
  min-width: 0;
}

.answer-actions-row .btn-quit {
  flex: 0 0 auto;
  align-self: stretch;
}

.answer-actions .btn-quit {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #ffcdd2;
  background: #fff8f8;
  color: #c62828;
  cursor: pointer;
  white-space: nowrap;
}

.answer-actions .btn-quit:active {
  transform: scale(0.98);
}

.choices-footer {
  display: flex;
  justify-content: center;
  padding: 0 12px 12px;
}

.choices-footer .btn-quit {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid #ffcdd2;
  background: #fff8f8;
  color: #c62828;
  cursor: pointer;
}

.kuku-input-footer {
  display: flex;
  justify-content: center;
  padding: 4px 8px 6px;
  grid-column: 1 / -1;
}

.kuku-input-footer .btn-quit {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 10px;
  border: 2px solid #ffcdd2;
  background: #fff8f8;
  color: #c62828;
  cursor: pointer;
}

@media (max-width: 420px) {
  .app-header-format-row {
    gap: 4px;
  }

  .format-field-label {
    font-size: 0.65rem;
  }

  .app-header--unified .format-select {
    font-size: 0.68rem;
    flex: 1 1 5.5rem;
  }

  .btn-header-util {
    font-size: 0.62rem;
    padding: 4px 6px;
  }
}
