:root {
  --bg: #f8f1e6;
  --card: #fffcf6;
  --line: #e8dac3;
  --line-soft: #f0e6d6;
  --dash: #cdb894;
  --ink: #2a211c;
  --muted: #6e6058;
  --red: #d3261a;
  --red-dark: #b81f14;
  --tomato: #e33b2e;
  --leaf: #2e7d32;
  --x: #141414;
  --going-bg: #e3f0df;
  --going-ink: #1f5e23;
  --wait-bg: #f3eadb;
  --wait-ink: #6b4e16;
  --round: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
  --sans: 'Noto Sans JP', 'Hiragino Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
}

a {
  color: var(--red-dark);
}

img {
  max-width: 100%;
}

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

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

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.underline {
  text-decoration: underline;
  text-decoration-color: var(--dash);
  text-underline-offset: 4px;
}

/* ---------- icons ---------- */

.icon {
  flex-shrink: 0;
}

/* <symbol> の中身は <use> 先ではなく定義側の位置でセレクタが当たるので、祖先クラスに頼らない */
.stroke,
.stroke * {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stroke.bold {
  stroke-width: 2.6;
}

/* ---------- page frame ---------- */

.page {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.page > main {
  flex: 1;
}

.page--wide {
  max-width: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.page--wide .site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px max(24px, calc((100% - 1200px) / 2 + 24px));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
}

.brand__name {
  font-family: var(--round);
  font-weight: 800;
  font-size: 20px;
}

.brand__tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.me-menu {
  position: relative;
}

.me-menu summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.me-menu summary::-webkit-details-marker {
  display: none;
}

.me-menu__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid var(--tomato);
  display: block;
  flex-shrink: 0;
}

.me-menu__avatar img,
.me-menu__avatar .avatar-fallback,
.who__avatar img,
.who__avatar .avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  object-fit: cover;
  font-size: 13px;
}

.me-menu__name {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  min-width: 160px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgb(42 33 28 / 0.12);
  display: flex;
  flex-direction: column;
}

.me-menu__panel a,
.me-menu__panel button {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.me-menu__panel a:hover,
.me-menu__panel button:hover {
  background: var(--line-soft);
}

.site-footer {
  padding: 48px 16px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.site-footer img {
  border-radius: 50%;
}

.site-footer a {
  color: var(--muted);
  font-weight: 700;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, background-color 0.15s ease;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn--sm {
  min-height: 44px;
  padding: 0 16px;
}

.btn--lg {
  min-height: 56px;
  font-size: 16px;
  padding: 0 22px;
}

.btn--block {
  display: flex;
  width: 100%;
}

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

.btn--primary:hover {
  background: var(--red-dark);
  color: #fff;
}

.btn--x {
  background: var(--x);
  color: #fff;
}

.btn--x:hover {
  color: #fff;
  background: #000;
}

.btn--dark {
  background: var(--ink);
  color: #fff;
}

.btn--dark:hover {
  color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--dash);
}

.btn--ghost:hover {
  color: var(--ink);
  background: var(--card);
}

.btn--going {
  background: var(--going-bg);
  color: var(--going-ink);
  cursor: default;
}

.btn--wait {
  background: var(--wait-bg);
  color: var(--wait-ink);
  cursor: default;
}

.btn--done {
  background: var(--line-soft);
  color: var(--muted);
  cursor: default;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.pill {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill--going {
  background: var(--going-bg);
  color: var(--going-ink);
}

.pill--wait {
  background: var(--wait-bg);
  color: var(--wait-ink);
}

.pill--draft {
  background: #efe3d0;
  color: var(--wait-ink);
  font-size: 11px;
}

/* ---------- common blocks ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.section {
  padding: 28px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section--tight {
  padding-top: 4px;
}

.section-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.section-title {
  margin: 0;
  font-family: var(--round);
  font-weight: 800;
  font-size: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.page-title {
  margin: 0;
  font-family: var(--round);
  font-weight: 800;
  font-size: 30px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.back-row {
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.count {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-family: var(--round);
}

.count__n {
  font-size: 22px;
  font-weight: 800;
}

.count__cap {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.count--big .count__n {
  font-size: 26px;
}

.count--big .count__cap {
  font-size: 15px;
}

.count__n--muted {
  font-family: var(--round);
  font-size: 18px;
  color: var(--muted);
}

.date-block {
  width: 66px;
  height: 74px;
  flex-shrink: 0;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.date-block__m,
.date-block__w {
  font-size: 12px;
  font-weight: 700;
}

/* 赤はカレンダーの上の帯（月）だけ */
.date-block__m {
  align-self: stretch;
  padding: 3px 0;
  background: var(--red);
  color: #fff;
  text-align: center;
}

.date-block__d {
  margin-top: auto;
  font-family: var(--round);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
}

.date-block__w {
  margin-bottom: auto;
  color: var(--muted);
}

.date-block--small {
  width: 44px;
  height: auto;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  overflow: visible;
}

.date-block--small .date-block__m {
  padding: 0;
  background: none;
}

.date-block--small .date-block__d {
  margin-top: 0;
}

.date-block--small .date-block__m,
.date-block--small .date-block__w {
  font-size: 11px;
  color: var(--muted);
}

.date-block--small .date-block__d {
  font-size: 24px;
}

.rich-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.empty-card {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- home ---------- */

.hero {
  padding: 12px 16px 0;
}

.hero h1 {
  margin: 0;
  font-family: var(--round);
  font-weight: 800;
  font-size: clamp(22px, 7vw, 28px);
  line-height: 1.4;
}

.hero__link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.hero-banner {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 390 / 132;
  object-fit: cover;
  object-position: 100% 72%;
  margin-top: 4px;
}

.next-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-radius: 22px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.next-card:hover {
  color: var(--ink);
  box-shadow: 0 6px 20px rgb(42 33 28 / 0.08);
}

/* タイトルのリンクをカード全体に広げる。トマトと下のボタンだけはその上に出す */
.next-card {
  position: relative;
}

.next-card__link {
  color: inherit;
  text-decoration: none;
}

.next-card__link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.next-card__link:focus-visible {
  outline: none;
}

.next-card:has(.next-card__link:focus-visible) {
  outline: 3px solid var(--leaf);
  outline-offset: 2px;
}

.next-card button.tomato,
.next-card__cta {
  position: relative;
  z-index: 2;
}

.next-card__head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.next-card__meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.next-card__title {
  font-family: var(--round);
  font-weight: 800;
  font-size: 22px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.next-card__slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.next-card__slots .count {
  align-self: flex-end;
}

.slot-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  justify-items: center;
  row-gap: 2px;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
}

.event-row:hover {
  color: var(--ink);
}

.event-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-row__title {
  font-weight: 700;
  font-size: 15px;
}

.event-row__sub {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- event ---------- */

.event-head {
  padding: 4px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 15px;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.info-row--link:hover {
  color: var(--ink);
}

.info-row__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-row__text {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.info-row__text .muted {
  font-size: 13px;
}

.cta {
  padding: 22px 16px 0;
}

.cta__joined {
  display: flex;
  gap: 10px;
}

.cta__joined > .btn {
  flex: 1;
}

.join-form,
.goal-edit {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.goal-edit {
  padding-top: 4px;
}

.goal-edit .btn {
  align-self: flex-end;
}

.join-form__note {
  margin: 0;
  font-size: 12px;
  text-align: center;
}

.join-form__note a {
  color: inherit;
  font-weight: 700;
}

.field-group input[name='goal'] {
  font-size: 16px;
}

.field-hint {
  font-size: 12px;
}

.field-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.char-count {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.char-count.is-over {
  color: var(--red);
}

.goal-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.goal-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.goal-item__name {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.goal-item.is-me .goal-item__name {
  color: var(--leaf);
}

.goal-item__text {
  font-size: 15px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.goal-cell {
  min-width: 200px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px 4px;
}

.person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.person__tomato {
  position: relative;
  line-height: 0;
}

.person__name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 17px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.person__name:hover {
  color: var(--ink);
}

.person__name:hover .person__label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.person__label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person__name .icon {
  color: var(--muted);
}

.person--wait .person__name {
  color: var(--muted);
}

.badge {
  position: absolute;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.badge--me {
  right: -4px;
  background: var(--leaf);
}

.badge--order {
  left: -2px;
  background: var(--ink);
}

#me {
  scroll-margin-top: 30vh;
}

/* ---------- about ---------- */

.about-lead {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
}

.flow-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 赤＝トマト（集中）、緑＝ヘタ（休憩） */
.flow-bar {
  display: flex;
  gap: 3px;
  height: 40px;
}

.flow-bar__seg {
  min-width: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--round);
  font-weight: 800;
  font-size: 15px;
}

.flow-bar__seg--focus {
  background: var(--tomato);
  color: #fff;
}

.flow-bar__seg--break {
  background: var(--going-bg);
  color: var(--going-ink);
}

.flow-axis {
  position: relative;
  height: 16px;
  margin-top: -6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.flow-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  line-height: 16px;
  white-space: nowrap;
}

.flow-axis span:first-child {
  transform: none;
}

.flow-axis span:last-child {
  transform: translateX(-100%);
}

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  font-weight: 700;
}

.flow-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.flow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.flow-dot--focus {
  background: var(--tomato);
}

.flow-dot--break {
  background: var(--leaf);
}

.flow-dot--plain {
  background: var(--dash);
}

.flow-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-soft);
}

.flow-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.flow-row__time {
  width: 96px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.flow-row__label {
  flex: 1;
  font-weight: 700;
}

.flow-row--break .flow-row__label {
  font-weight: 500;
  color: var(--going-ink);
}

.flow-row__min {
  font-family: var(--round);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rule-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.rule-big {
  margin: 0;
  text-wrap: balance;
  font-family: var(--round);
  font-weight: 800;
  font-size: 24px;
  line-height: 1.3;
}

.rule-big--must {
  color: var(--red);
}

.rule-big--free {
  color: var(--going-ink);
}

.rule-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  line-height: 1.8;
}

.about-back {
  padding-top: 32px;
}

/* ---------- tomato ---------- */

.tomato {
  --size: 68px;
  position: relative;
  display: inline-block;
  width: var(--size);
  height: calc(var(--size) * 1.08);
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  line-height: 0;
  perspective: 500px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tomato > svg,
.tomato__face > svg {
  width: 100%;
  height: 100%;
  display: block;
}

button.tomato {
  cursor: pointer;
}

button.tomato:focus-visible {
  outline: 3px solid var(--leaf);
  outline-offset: 2px;
  border-radius: 50%;
}

.tomato__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.45, 0.5, 1);
}

.tomato.is-flipped .tomato__inner {
  transform: rotateY(180deg);
}

/* PC：ホバー（キーボードはフォーカス）している間だけ裏返る */
@media (hover: hover) and (pointer: fine) {
  button.tomato:hover .tomato__inner,
  button.tomato:focus-visible .tomato__inner {
    transform: rotateY(180deg);
  }
}

.tomato.is-hop {
  transform: translateY(-10%) scale(1.08);
}

.tomato__face {
  position: absolute;
  inset: 0;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 裏面：トマトの実と同じ位置・大きさの丸に Xアイコン */
.tomato__back {
  inset: auto;
  left: 6%;
  top: 16.67%;
  width: 88%;
  height: 81.48%;
  border-radius: 50%;
  overflow: hidden;
  border: calc(var(--size) * 0.035) solid var(--tomato);
  background: var(--line-soft);
  transform: rotateY(180deg);
}

.tomato__back img,
.tomato__back .avatar-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: flex;
}

.avatar-fallback {
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--round);
  font-weight: 800;
  font-size: calc(var(--size, 68px) * 0.3);
}

.tomato.is-wait {
  opacity: 0.5;
}

/* 参加した直後：上からポンと落ちて弾む */
.tomato.is-pop {
  animation: tomato-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s backwards;
}

@keyframes tomato-pop {
  from {
    transform: translateY(-48px) scale(0.2);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.tomato.is-wait.is-pop {
  animation-name: tomato-pop-wait;
}

@keyframes tomato-pop-wait {
  from {
    transform: translateY(-48px) scale(0.2);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 0.5;
  }
}

/* 吹き出し：裏返したトマトの上に「取り組むこと」を出す。最大20文字なので1行10文字の2行に収まる */
.bubble {
  --dx: 0px;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 1;
  box-sizing: content-box;
  width: max-content;
  max-width: 10em;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(42, 33, 28, 0.14);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(calc(-50% + var(--dx)), 4px) scale(0.92);
  transform-origin: 50% 100%;
  transition:
    opacity 0.15s,
    transform 0.2s,
    visibility 0s 0.2s;
}

/* しっぽは、吹き出しを画面の端でずらしてもトマトの真上に残す */
.bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: calc(50% - var(--dx));
  width: 9px;
  height: 9px;
  margin: -4px 0 0 -5px;
  border: solid var(--line);
  border-width: 0 1.5px 1.5px 0;
  background: #fff;
  transform: rotate(45deg);
}

.tomato.is-talking {
  z-index: 5;
}

.tomato.is-talking .bubble {
  opacity: 1;
  visibility: visible;
  transform: translate(calc(-50% + var(--dx)), 0) scale(1);
  transition:
    opacity 0.15s 0.15s,
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s,
    visibility 0s 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  button.tomato:hover,
  button.tomato:focus-visible {
    z-index: 5;
  }
  button.tomato:hover .bubble,
  button.tomato:focus-visible .bubble {
    opacity: 1;
    visibility: visible;
    transform: translate(calc(-50% + var(--dx)), 0) scale(1);
    transition:
      opacity 0.15s 0.15s,
      transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s,
      visibility 0s 0.15s;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tomato,
  .tomato__inner,
  .bubble,
  .tomato.is-talking .bubble {
    transition: none;
  }
  .tomato.is-pop {
    animation: none;
  }
  .tomato.is-hop {
    transform: none;
  }
}

/* ---------- admin ---------- */

.admin,
.admin-edit {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.admin {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}

.admin__side {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin__label {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.admin__main {
  flex: 999 1 600px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  color: var(--ink);
  text-decoration: none;
}

.admin-event:hover {
  color: var(--ink);
  background: var(--card);
}

.admin-event.is-selected {
  background: var(--card);
  border-color: var(--red);
}

.admin-event__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-event__title {
  font-weight: 700;
  font-size: 14px;
}

.admin-event__sub {
  font-size: 12px;
  color: var(--muted);
}

.admin-head {
  padding: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
}

.admin-head__text {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.admin-head .page-title {
  font-size: 28px;
}

.admin-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.stat {
  padding: 16px 18px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.stat__value {
  font-family: var(--round);
  font-size: 28px;
  font-weight: 800;
}

.stat__value small {
  font-size: 15px;
  color: var(--muted);
}

.table-card {
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.tab:hover {
  color: var(--ink);
  background: var(--line-soft);
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 12px 8px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.table td {
  padding: 8px;
  border-top: 1px solid var(--line-soft);
}

.table th:first-child,
.table td:first-child {
  padding-left: 16px;
}

.table th:last-child,
.table td:last-child {
  padding-right: 16px;
}

.table .num {
  width: 40px;
  color: var(--muted);
}

.empty-row {
  text-align: center;
  padding: 24px !important;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who__avatar {
  --size: 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--tomato);
  flex-shrink: 0;
}

/* ---------- admin form ---------- */

.admin-edit {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
}

.admin-edit .back-link {
  align-self: flex-start;
}

.form {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-error {
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fbe1dd;
  color: #8f170f;
  font-weight: 700;
  font-size: 14px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field-group label {
  font-size: 14px;
  font-weight: 700;
}

.field-group label .muted {
  font-weight: 500;
}

.field-group input,
.field-group textarea {
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid #dccbb0;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  min-width: 0;
  width: 100%;
}

.field-group textarea {
  padding: 12px 14px;
  line-height: 1.8;
  resize: vertical;
}

.field-group input:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgb(211 38 26 / 0.15);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 24px;
}

.with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.with-unit input {
  width: 110px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.check input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--red);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 640px) {
  .admin,
  .admin-edit {
    padding: 20px 16px 40px;
  }
  .page--wide .site-header {
    padding: 10px 16px;
  }
  .form {
    padding: 20px;
  }
  .form-grid--3 {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid--3 > :first-child {
    grid-column: 1 / -1;
  }
  .form-grid--2 {
    grid-template-columns: 1fr;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 12px;
  }
  .stat__value {
    font-size: 22px;
  }
}
