:root {
  --bg: #f7f3ec;
  --card: #fffdf8;
  --text: #2f2b25;
  --muted: #766f65;
  --line: #e4d9c8;
  --accent: #8b5e34;
  --accent-dark: #614024;
  --danger: #9f3a38;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.container {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 20px 14px 40px;
}

.hero {
  padding: 12px 4px 18px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .08em;
}

h1 {
  margin: 4px 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(53, 42, 28, .08);
  padding: 18px;
}

.hidden {
  display: none !important;
}

/* ===== カテゴリ選択カード ===== */
.category-picker {
  margin-top: 8px;
}

.picker-label {
  margin: 0 4px 12px;
  font-weight: 700;
  color: var(--text);
  font-size: 18px;
}

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

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 120px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 18px 10px;
  font: inherit;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(53, 42, 28, .06);
  transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease;
}

.cat-card:hover,
.cat-card:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.cat-card:active {
  transform: scale(0.97);
}

.cat-card.selected {
  border-color: var(--accent);
  background: #fdf3e6;
}

.cat-emoji {
  font-size: 38px;
  line-height: 1;
}

.cat-name {
  font-size: 14px;
}

/* ===== 選択中のバッジ＋やり直しリンク ===== */
.selected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  background: #eee4d6;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 14px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  min-height: 0;
  border-radius: 0;
}

/* ===== 写真ラベル（最上部） ===== */
.photo-label {
  background: #faf3e6;
  border: 1px dashed var(--accent);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 16px;
}

/* v0.3.2: 写真ボタン 2系統（カメラ / ギャラリー） */
.photo-block {
  background: #faf3e6;
  border: 1px dashed var(--accent);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 16px;
}

.photo-block-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.photo-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.photo-btn:hover,
.photo-btn:focus-within {
  border-color: var(--accent);
}

.photo-btn.selected {
  background: #fdf3e6;
  border-color: var(--accent);
}

.photo-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.photo-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.photo-preview {
  margin-top: 10px;
}

.photo-preview img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.photo-preview-source {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 6px;
}

/* v0.4-A: 複数写真 + 役割 + メイン指定 */
.photo-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  background: var(--card);
  border: 2px dashed var(--accent);
  border-radius: 14px;
  padding: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
  text-align: center;
  margin-bottom: 10px;
}

.photo-add-btn:hover { background: #fdf3e6; }

.photo-add-btn input[type="file"] {
  position: absolute;
  width: 1px; height: 1px; opacity: 0; overflow: hidden;
  margin: 0; padding: 0; pointer-events: none;
}

.photo-counter {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.photo-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.photo-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.photo-card.is-main {
  border-color: var(--accent);
  background: #fdf3e6;
}

.photo-thumb {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  background: #eee4d6;
}

.photo-file-input {
  display: none;
}

.photo-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 700;
}

.role-label {
  min-width: 38px;
  font-size: 12px;
  color: var(--muted);
}

.role-select {
  flex: 1;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.main-radio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.main-radio {
  width: auto;
  margin: 0;
  transform: scale(1.1);
}

.delete-btn {
  background: #f0e6d4;
  color: var(--danger);
  min-height: 32px;
  border-radius: 8px;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-end;
  width: 60px;
}

/* ===== OCRスタブ ===== */
.ocr-stub {
  margin: 0 0 16px;
}

.ocr-stub button {
  width: 100%;
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== カテゴリ別フィールド ===== */
.cat-fields {
  display: none;
  padding-top: 4px;
  margin-top: 4px;
  border-top: 1px dashed var(--line);
}

.cat-fields.active {
  display: block;
}

/* ===== 入力共通 ===== */
label {
  display: block;
  font-weight: 700;
  margin: 0 0 16px;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 400;
}

.required {
  color: var(--danger);
  font-size: 12px;
  margin-left: 4px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.check input {
  width: auto;
  margin: 0;
  transform: scale(1.25);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

button,
.button-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  border-radius: 999px;
  border: none;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

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

.secondary {
  background: #eee4d6;
  color: var(--accent-dark);
}

.result {
  margin-top: 60px;
  text-align: center;
}

.result ul {
  text-align: left;
}

.note {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin: 4px 0 0;
}

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

/* ===== 日本酒 詳細情報（折りたたみ） ===== */
.sake-details {
  margin: 4px 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf7ef;
  padding: 0;
  overflow: hidden;
}

.sake-details > summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-weight: 700;
  color: var(--accent-dark);
  position: relative;
  user-select: none;
}

.sake-details > summary::-webkit-details-marker {
  display: none;
}

.sake-details > summary::after {
  content: "▾";
  position: absolute;
  right: 16px;
  top: 14px;
  transition: transform .15s ease;
}

.sake-details[open] > summary::after {
  transform: rotate(180deg);
}

.sake-details-title {
  display: block;
}

.sake-details > summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.sake-details-inner {
  padding: 4px 16px 14px;
  border-top: 1px dashed var(--line);
}

.sake-details-inner label {
  margin-bottom: 14px;
}

/* multi_select 用チェックボックス群 */
.multi-select-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px 6px;
  margin: 0 0 16px;
}

.multi-select-group legend {
  font-weight: 700;
  padding: 0 6px;
  font-size: 14px;
  color: var(--accent-dark);
}

/* v0.3.2: S10「香り系統」を S09 等と同じ文字サイズに、「（複数選択可）」だけ小さく */
.ms-legend-main {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-dark);
}

.ms-legend-note {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.multi-check {
  margin: 6px 0;
  font-weight: 400;
}

.multi-check input {
  width: auto;
  margin: 0;
  transform: scale(1.15);
}

@media (min-width: 430px) {
  .container {
    padding-top: 28px;
  }
}
