:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --card-pad: clamp(24px, 7vw, 40px);
  --card-radius: 20px;

  --bg: #eef3f9;
  --surface: #fff;
  --surface-2: #f6f9fd;
  --surface-3: #edf1f5;
  --input-bg: #fff;
  --bar-bg: rgb(255 255 255 / 92%);
  --bar-shadow: rgb(21 49 84 / 10%);

  --text: #13233a;
  --text-sub: #52657d;
  --text-muted: #718299;

  --border: #d7e0ec;
  --border-2: #b8c5d5;

  --chip-bg: #e5edf8;
  --chip-text: #35516f;

  --accent: #155da8;
  --accent-hover: #0e4b8a;
  --focus: #2867b2;
  --focus-ring: rgb(40 103 178 / 20%);

  --warn: #d08a18;
  --warn-deep: #a25e00;
  --warn-bg: #fff8e8;

  --food-border: #e6c99a;
  --food-bg: #fff8e9;
  --food-border-hover: #d5aa67;
  --food-bg-hover: #ffefcf;

  --success: #087847;
  --danger: #b42318;

  --ember: #bd4b18;
  --ember-hover: #9f3d14;
  --ember-bg: #fff2e9;

  --card-shadow: 0 18px 50px rgb(21 49 84 / 12%);
  --dialog-shadow: 0 24px 70px rgb(15 39 67 / 28%);
  --backdrop: rgb(14 31 52 / 52%);

  background: var(--bg);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #06101f;
    --surface: #101f36;
    --surface-2: #16273f;
    --surface-3: #1c2d46;
    --input-bg: #0c1a30;
    --bar-bg: rgb(16 31 54 / 92%);
    --bar-shadow: rgb(0 0 0 / 35%);

    --text: #e4edf8;
    --text-sub: #a5b8cf;
    --text-muted: #7f93ac;

    --border: #263a55;
    --border-2: #3c5474;

    --chip-bg: #1c3050;
    --chip-text: #a9c6e8;

    --accent: #2f6fbe;
    --accent-hover: #3f81d4;
    --focus: #6ea8e8;
    --focus-ring: rgb(110 168 232 / 28%);

    --warn: #e0a344;
    --warn-deep: #e8b45c;
    --warn-bg: #2c2310;

    --food-border: #5a4520;
    --food-bg: #2a2210;
    --food-border-hover: #7a5c28;
    --food-bg-hover: #342a12;

    --success: #55c68f;
    --danger: #f28b7d;

    --ember: #e06a38;
    --ember-hover: #c2551f;
    --ember-bg: #35200f;

    --card-shadow: 0 18px 50px rgb(0 0 0 / 45%);
    --dialog-shadow: 0 24px 70px rgb(0 0 0 / 55%);
    --backdrop: rgb(3 9 18 / 65%);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 20px;
  overscroll-behavior-y: contain;
}

button,
summary,
label {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.comment-card {
  width: min(100%, 520px);
  padding: var(--card-pad);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.local-label {
  display: inline-block;
  margin: 0 0 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 7vw, 36px);
  line-height: 1.2;
}

.description {
  margin: 14px 0 24px;
  color: var(--text-sub);
  line-height: 1.7;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

input[type="text"],
textarea {
  width: 100%;
  min-height: 58px;
  padding: 12px 14px;
  border: 2px solid var(--border-2);
  border-radius: 12px;
  background: var(--input-bg);
  color: inherit;
  font: inherit;
  font-size: 18px;
  line-height: 1.5;
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--focus);
  outline: 3px solid var(--focus-ring);
}

input[type="text"]:disabled,
textarea:disabled {
  background: var(--surface-3);
}

textarea {
  min-height: 86px;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.input-options {
  margin: 7px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-hint {
  margin: 0;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
}

.enter-submit-option {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.enter-submit-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.question-option:has(input:checked) {
  border-color: var(--warn);
  background: var(--warn-bg);
  box-shadow: inset 3px 0 0 var(--warn);
}

.question-option input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--warn-deep);
  flex: none;
}

.question-option span {
  display: grid;
  gap: 3px;
}

.question-option strong {
  color: var(--text);
  font-size: 15px;
}

.question-option small {
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.form-meta {
  min-height: 38px;
  margin: 4px 0 16px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.5;
}

#comment-status[data-state="success"],
.section-status[data-state="success"] {
  color: var(--success);
  font-weight: 700;
}

#comment-status[data-state="error"],
.section-status[data-state="error"],
#comment-counter[data-state="limit"] {
  color: var(--danger);
  font-weight: 700;
}

#comment-counter {
  flex: none;
}

button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background-color 150ms ease, border-color 150ms ease;
}

@media (hover: hover) {
  button:hover:not(:disabled) {
    background: var(--accent-hover);
  }
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

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

.participant-name-field {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.participant-name-field summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.participant-name-field summary::-webkit-details-marker {
  display: none;
}

.participant-name-field summary::before {
  content: "＋";
  color: var(--text-muted);
}

.participant-name-field[open] summary::before {
  content: "－";
}

.participant-name-field__badge {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.participant-name-field input {
  width: calc(100% - 28px);
  min-height: 46px;
  margin: 0 14px;
  font-size: 16px;
}

.participant-name-hint {
  margin: 6px 14px 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.comment-style-field {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.comment-style-field summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.comment-style-field summary::-webkit-details-marker { display: none; }
.comment-style-field summary::before { color: var(--text-muted); content: "＋"; }
.comment-style-field[open] summary::before { content: "－"; }

.comment-style-field__badge {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.comment-style-field fieldset {
  margin: 0;
  padding: 0 14px 12px;
  border: 0;
}

.comment-style-field legend {
  margin-bottom: 7px;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
}

.comment-style-colors,
.comment-style-sizes {
  display: grid;
  gap: 7px;
}

.comment-style-colors { grid-template-columns: repeat(5, 1fr); }
.comment-style-sizes { grid-template-columns: repeat(3, 1fr); }

.comment-style-field label {
  margin: 0;
  cursor: pointer;
}

.comment-style-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.comment-style-field label span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--border-2);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 800;
}

.comment-style-field input:checked + span {
  border-color: var(--focus);
  outline: 2px solid var(--focus-ring);
}

.comment-style-field input:focus-visible + span {
  outline: 3px solid var(--focus-ring);
}

.comment-style-field span[data-color]::before {
  width: 14px;
  height: 14px;
  border: 1px solid rgb(7 26 51 / 55%);
  border-radius: 50%;
  background: var(--swatch);
  content: "";
}

.comment-style-field span[data-color="white"] { --swatch: #fff; }
.comment-style-field span[data-color="cyan"] { --swatch: #72ddff; }
.comment-style-field span[data-color="green"] { --swatch: #9df59d; }
.comment-style-field span[data-color="pink"] { --swatch: #ff9bd3; }
.comment-style-field span[data-color="orange"] { --swatch: #ffd166; }

.comment-style-field > p {
  margin: -2px 14px 12px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}
.own-history {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.own-history summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.own-history summary::-webkit-details-marker {
  display: none;
}

.own-history summary::before {
  content: "＋";
  color: var(--text-muted);
}

.own-history[open] summary::before {
  content: "－";
}

.own-history summary > :first-child {
  margin-right: auto;
}

.own-history__count {
  color: var(--text-muted);
  font-size: 12px;
}

.own-history__list {
  display: grid;
  max-height: 230px;
  gap: 8px;
  margin: 0;
  padding: 0 12px 12px;
  overflow-y: auto;
  list-style: none;
}

.own-history__hint {
  margin: -2px 14px 10px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.own-history__list[data-empty="true"]::before {
  padding: 4px 2px 8px;
  color: var(--text-muted);
  font-size: 12px;
  content: "このタブから送ったコメントと質問が表示されます";
}

.own-history__list li {
  padding: 9px 11px;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.own-history__list li.is-question {
  border-left: 3px solid var(--warn);
}

.own-history__type {
  margin-right: 6px;
  color: var(--warn-deep);
  font-size: 11px;
  font-weight: 800;
}

.own-history__time {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.own-history__retract {
  display: block;
  width: auto;
  margin-top: 7px;
  padding: 4px 9px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
}

.own-history__list li.is-withdrawn {
  border-style: dashed;
  background: var(--surface-3);
  color: var(--text-muted);
}

.own-history__list li.is-withdrawn .own-history__text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.own-history__withdrawn-label {
  display: inline-block;
  margin: 7px 0 0 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 11px;
  font-weight: 700;
}

.retraction-dialog {
  width: min(360px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
  color: var(--text);
}

.retraction-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(2px);
}

.retraction-dialog__body {
  padding: 26px 24px 22px;
  text-align: center;
}

.retraction-dialog__icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  background: var(--ember-bg);
  color: var(--ember);
  font-size: 23px;
  font-weight: 800;
}

.retraction-dialog h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
}

.retraction-dialog p {
  margin: 10px 0 0;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}

.retraction-dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.retraction-dialog__actions button {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 14px;
}

.retraction-dialog__actions .is-cancel {
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-sub);
}

.retraction-dialog__actions .is-danger {
  border: 1px solid var(--ember);
  background: var(--ember);
  color: #fff;
}

@media (hover: hover) {
  .retraction-dialog__actions .is-cancel:hover:not(:disabled) {
    background: var(--surface-2);
  }

  .retraction-dialog__actions .is-danger:hover:not(:disabled) {
    background: var(--ember-hover);
  }
}

.stamp-section {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 24px calc(var(--card-pad) * -1) calc(var(--card-pad) * -1);
  padding: 12px var(--card-pad) calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  background: var(--bar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 -12px 28px var(--bar-shadow);
}

.section-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--text-sub);
  font-size: 13px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.stamp-hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.stamp-button {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: inherit;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.stamp-button[hidden] {
  display: none;
}

.stamp-button {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 30px;
}

.stamp-button[data-stamp-group="food"] {
  border-color: var(--food-border);
  background: var(--food-bg);
}

@media (hover: hover) {
  .stamp-button:hover:not(:disabled) {
    border-color: var(--border-2);
    background: var(--surface-3);
  }

  .stamp-button[data-stamp-group="food"]:hover:not(:disabled) {
    border-color: var(--food-border-hover);
    background: var(--food-bg-hover);
  }
}

.stamp-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.88);
  transition-duration: 60ms;
}

.stamp-toggle {
  min-height: 40px;
  margin-top: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 14px;
}

@media (hover: hover) {
  .stamp-toggle:hover:not(:disabled) {
    background: var(--surface-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }

  button:active:not(:disabled) {
    transform: none;
  }
}

@media (max-width: 420px) {
  body {
    align-items: start;
    padding: 0;
  }

  .comment-card {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .stamp-section {
    margin-top: auto;
    border-radius: 0;
  }

  .stamp-grid {
    gap: 6px;
  }

  .stamp-button {
    min-height: 52px;
    font-size: 26px;
  }
}
