/*
 * Nokkete 主催者ポータル（/admin/）専用スタイル
 * site.css（共通のトークン・フォーム・ボタン・フッター）の後に読み込む。
 * 外部フォント・外部画像・@import は使わない（CSP: style-src 'self'）。
 * admin.js が見た目を変えるのは classList / hidden / style.setProperty("--…") だけ
 * （--accent, --swatch, --dot-color, --avatar-color, --art-color, --category-color, --chip-color, --chip-text, --usage, --progress）。
 * 半透明のガラスは浮いている層（上部のバー・タブ・通知・印刷のツールバー）だけに使い、カードは不透明の面にする。
 */

/* ---------- デザイントークン（ポータル専用） ---------- */
:root {
  /* 主催者のテーマカラー（admin.js が <html> に setProperty で上書きする） */
  --accent: var(--brand-indigo);
  --accent-soft: rgb(94 92 230 / 0.14);
  --accent-line: rgb(94 92 230 / 0.36);
  --accent-ink: var(--accent-text); /* 文字・細い線に使うテーマカラー（下の @supports で背景に対して読める濃さに寄せる） */

  --demo: #00B4D8;
  --demo-soft: rgb(0 180 216 / 0.14);
  --demo-line: rgb(0 180 216 / 0.4);
  --demo-ink: #00718b;    /* 白地で 5.6:1 */
  --demo-strong: #007a94; /* 白文字で 4.9:1 */
  --demo-strong-hover: #006880;
  --on-demo: #ffffff;

  --ok: var(--success-text);
  --warn: #c7750b;
  --danger: var(--error-text);

  --warn-text: #8f5304;   /* #fff6e6 に対し 5.8:1 */
  --warn-bg: #fff6e6;
  --warn-border: #f2d39f;
  --info-text: #2450b8;
  --info-bg: #eef3ff;
  --info-border: #c9d8fb;

  /* 塗りの色と、その上に載せる文字・記号の色 */
  --ok-fill: #1e8a4c;
  --on-ok: #ffffff;
  --warn-fill: var(--warn);
  --on-warn: #ffffff;
  --danger-fill: #c4281f;
  --danger-fill-hover: #a11f18;
  --on-danger: #ffffff;
  --info-fill: #2f6fe4;
  --on-info: #ffffff;
  --badge-red: #d4194f;

  /* 公式バッジのグラデーション文字（白地で読める濃さ） */
  --official-from: #d81b55;
  --official-mid: #9b3fd0;
  --official-to: #4b49d6;

  --surface-raised: #ffffff;
  --thumb: #ffffff;
  --skeleton-base: #eeedf2;
  --skeleton-shine: #f9f8fb;
  --hairline-strong: rgb(0 0 0 / 0.14);
  --desk: #e4e3ea;

  /* 浮いている層だけに使う半透明の面 */
  --glass-bar: rgb(255 255 255 / 0.72);
  --glass-page: rgb(251 250 252 / 0.8);
  --glass-border: rgb(28 28 30 / 0.08);
  --glass-filter: saturate(180%) blur(20px);

  --shadow-card: 0 1px 2px rgb(28 22 48 / 0.04), 0 6px 20px -12px rgb(28 22 48 / 0.14);
  --shadow-raised: 0 2px 6px rgb(28 22 48 / 0.06), 0 18px 40px -18px rgb(28 22 48 / 0.3);
  --shadow-float: 0 2px 8px rgb(16 12 32 / 0.08), 0 16px 40px -14px rgb(16 12 32 / 0.32);

  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius-sm: 10px;

  /* 動き（prefers-reduced-motion: reduce で 0 にする） */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1.2);
  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 250ms;

  --portal-max: 960px;
  --app-bar-h: 60px;
  --app-bar-offset: calc(var(--app-bar-h) + env(safe-area-inset-top, 0px));
  --pad-start: max(var(--gutter), env(safe-area-inset-left, 0px));
  --pad-end: max(var(--gutter), env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root {
    --demo-ink: #5fd3ec;
    --demo-strong: #00b4d8;
    --demo-strong-hover: #33c6e3;
    --on-demo: #00161c;

    --warn: #f0a33a;
    --warn-text: #ffc978;
    --warn-bg: #2a2010;
    --warn-border: #5c4416;
    --info-text: #9dbbff;
    --info-bg: #141b2c;
    --info-border: #2c3c62;

    --ok-fill: #7fdc9f;
    --on-ok: #072012;
    --on-warn: #2a1700;
    --danger-fill: #ff9b92;
    --danger-fill-hover: #ffb8b1;
    --on-danger: #2b0906;
    --info-fill: #8fb0ff;
    --on-info: #0a1630;

    --official-from: #ff7a9a;
    --official-mid: #d08cff;
    --official-to: #a5a4ff;

    --surface-raised: #23232b;
    --thumb: #3a3a45;
    --skeleton-base: #24242c;
    --skeleton-shine: #30303a;
    --hairline-strong: rgb(255 255 255 / 0.18);
    --desk: #0b0b0e;

    --glass-bar: rgb(26 26 32 / 0.72);
    --glass-page: rgb(15 15 19 / 0.76);
    --glass-border: rgb(255 255 255 / 0.08);

    --shadow-card: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 10px 28px -18px rgb(0 0 0 / 0.7);
    --shadow-raised: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 18px 44px -18px rgb(0 0 0 / 0.8);
    --shadow-float: 0 0 0 1px rgb(255 255 255 / 0.06), 0 16px 40px -14px rgb(0 0 0 / 0.75);
  }
}

/* テーマカラーの淡い面・文字色（color-mix が使えるブラウザだけ。使えなければ上の既定の色のまま） */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 36%, transparent);
    --accent-ink: color-mix(in srgb, var(--accent) 70%, var(--text));
    --demo-soft: color-mix(in srgb, var(--demo) 14%, transparent);
    --demo-line: color-mix(in srgb, var(--demo) 40%, transparent);
  }
}

/*
 * 相対色が使えるブラウザでは、文字用のテーマカラーの明るさを抑えて（暗い表示では持ち上げて）、
 * 黄・緑・水色などの明るいテーマカラーや濃い灰色でも、タブ・手順・選択中の文字が読める濃さにする。
 */
@supports (color: oklch(from red min(l, 0.5) c h)) {
  :root {
    --accent-ink: oklch(from var(--accent) min(l, 0.5) c h);
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --accent-ink: oklch(from var(--accent) max(l, 0.78) c h);
    }
  }
}

/* ---------- ベース ---------- */
html {
  scroll-padding-top: calc(var(--app-bar-offset) + 16px);
}

/* ポータルでは上部のバー＋タブの下に見出しや欄が隠れないようにする */
html:has(body[data-view="portal"]) {
  scroll-padding-top: calc(var(--app-bar-offset) + 84px);
}

body.admin-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 520px at 50% -260px, var(--accent-soft), transparent 72%) no-repeat,
    var(--bg);
  overflow-wrap: anywhere;
}

/* キーボード操作のフォーカスの輪（部品ごとの指定で上書きできるよう詳細度を低くしておく） */
.admin-page :where(button, summary, [role="button"], [role="tab"], [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 読み上げのためにプログラムからフォーカスを移す見出しには輪を出さない */
.admin-page :is(h1, h2, h3)[tabindex="-1"]:focus {
  outline: none;
}

.admin-page :where(code) {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.admin-page ::placeholder {
  color: var(--text-secondary);
  opacity: 0.65;
}

/* 段落の既定の余白は、余白を gap で決める入れ物の中では使わない */
:is(.card, .stack-form, .tab-panel, .view, .modal-body, .disclosure-card-body, .inspector-result, .setup-aside) > p {
  margin: 0;
}

/* 中身の無い補足文は詰める。読み上げ領域（role="status" など）は、通知を逃さないよう見た目だけ畳む */
.admin-page :is(.small, .field-hint, .card-subtitle, .modal-text, .account-description, .event-when, .event-where):empty:not([role]):not([aria-live]) {
  display: none;
}

.admin-page p:empty:is([role="status"], [aria-live]) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- ユーティリティ ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* クリップボードの代わりに選択してコピーする欄（画面の外。iOS が拡大しない大きさ） */
.clipboard-fallback {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}

.is-hidden-soft {
  opacity: 0.5;
  transition: opacity var(--dur) var(--ease-out);
}

.text-danger {
  color: var(--danger);
}

.text-ok {
  color: var(--ok);
}

.text-warn {
  color: var(--warn-text);
}

/* ---------- 上部のバー ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 1px solid var(--border);
  background: var(--glass-bar);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--app-bar-h) - 1px);
  max-width: calc(var(--portal-max) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--pad-start) var(--pad-end);
}

.app-bar .wordmark {
  flex: none;
  font-size: 1.25rem;
}

.app-bar .wordmark:focus-visible {
  outline-offset: 4px;
  border-radius: 10px;
}

.app-bar-title {
  flex: 0 1 auto;
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 狭い画面のポータルでは、主催者メニューに幅を譲る（ワードマークは印だけにする。名前は aria-label で読まれる） */
@media (max-width: 519px) {
  body[data-view="portal"] .app-bar-title {
    display: none;
  }

  body[data-view="portal"] .app-bar .wordmark {
    gap: 0;
    font-size: 0;
  }
}

/* 主催者メニュー */
.organizer-menu {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}

.organizer-menu-button {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.organizer-menu-button:hover {
  border-color: var(--accent-line);
}

.organizer-menu-button:active {
  transform: scale(0.97);
}

.organizer-menu-button[aria-expanded="true"] {
  background: var(--surface-muted);
}

.organizer-menu-name {
  min-width: 0;
  max-width: 16em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.organizer-menu-name:empty,
.organizer-menu-badges:empty {
  display: none;
}

.organizer-menu-badges {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

.organizer-menu-chevron {
  flex: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  transition: transform var(--dur) var(--ease-out);
}

.organizer-menu-button[aria-expanded="true"] .organizer-menu-chevron {
  transform: rotate(180deg);
}

/* ドロップダウン（主催者メニューとイベントの「その他」で共通） */
.menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 25;
  display: grid;
  gap: 2px;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-float);
  transform-origin: top right;
  animation: menu-in var(--dur) var(--ease-out) backwards;
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.menu-item:hover {
  background: var(--surface-muted);
}

.menu-item:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
  background: var(--surface-muted);
}

.menu-item-danger {
  color: var(--danger);
}

.menu-item-danger:hover {
  background: var(--error-bg);
}

.menu-item[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-item[disabled]:hover {
  background: transparent;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
}

/* ---------- 通知（画面上部のトースト） ---------- */
.notice-stack {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

/* ポータルではタブの下に出して、タブの操作をふさがない */
body[data-view="portal"] .notice-stack {
  top: calc(var(--app-bar-offset) + 66px);
}

.toast {
  --toast-fill: var(--info-fill);
  --toast-on: var(--on-info);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background: var(--glass-bar);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-float);
  color: var(--text);
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur-slow) var(--ease-spring);
  pointer-events: auto;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
}

.toast[data-style="success"] {
  --toast-fill: var(--ok-fill);
  --toast-on: var(--on-ok);
}

.toast[data-style="warning"] {
  --toast-fill: var(--warn-fill);
  --toast-on: var(--on-warn);
}

.toast[data-style="error"] {
  --toast-fill: var(--danger-fill);
  --toast-on: var(--on-danger);
  border-color: var(--error-border);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--toast-fill);
  color: var(--toast-on);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 800;
  line-height: 1;
}

.toast-text {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.55;
}

.toast-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.toast-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* ---------- レイアウト ---------- */
.portal {
  flex: 1 0 auto;
  width: 100%;
  max-width: calc(var(--portal-max) + var(--gutter) * 2);
  margin-inline: auto;
  padding-block: 24px 64px;
  padding-inline: var(--pad-start) var(--pad-end);
  overflow-x: clip; /* 横にはみ出さない（clip はスクロール領域を作らないので sticky は効いたまま） */
}

.view {
  display: grid;
  gap: 20px;
  min-width: 0;
  animation: view-in var(--dur-slow) var(--ease-out) backwards;
}

.view > *,
.tab-panel > *,
.card > *,
.stack-form > *,
.modal-body > * {
  min-width: 0;
}

@keyframes view-in {
  from {
    opacity: 0;
  }
}

/* 起動中 */
.view-launching {
  min-height: min(62vh, 560px);
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.launch-mark {
  display: block;
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 25%, rgb(255 255 255 / 0.45) 0 18%, transparent 19%),
    linear-gradient(135deg, var(--brand-pink) 0%, #c04bd0 50%, var(--brand-indigo) 100%);
  box-shadow:
    inset 0 0 0 4px rgb(255 255 255 / 0.6),
    0 14px 30px -12px rgb(94 92 230 / 0.55);
  transform: rotate(-8deg);
  animation: launch-breathe 1.8s var(--ease-out) infinite alternate;
}

@keyframes launch-breathe {
  from {
    transform: rotate(-8deg) scale(1);
  }

  to {
    transform: rotate(-4deg) scale(1.06);
  }
}

.launch-title {
  margin: 6px 0 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.launch-status {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.skeleton-stack {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(320px, 100%);
  margin-top: 10px;
}

/* 見出し（未ログイン・本登録） */
.portal-hero {
  display: grid;
  justify-items: center;
  padding-block: 8px 4px;
  text-align: center;
}

.portal-hero .hero-mark {
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  border-radius: 22px;
}

.portal-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.875rem, 1.5rem + 1.6vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.portal-hero p {
  max-width: 36em;
  margin: 0;
  color: var(--text-secondary);
}

.setup-hero p + p {
  margin-top: 8px;
}

.setup-email {
  font-size: 0.875rem;
}

/* 未ログインの画面は読みやすい幅にまとめる */
#view-signed-out {
  width: 100%;
  max-width: 600px;
  margin-inline: auto;
}

.view-header {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.back-button {
  margin-left: -12px;
}

.view-title {
  margin: 0;
  font-size: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  font-weight: 800;
}

.view-lead {
  max-width: 42em;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.page-note {
  margin: 0;
  text-align: center;
}

/* 本登録: フォーム＋プレビュー */
.setup-layout {
  display: grid;
  gap: 20px;
  align-items: start;
}

.setup-aside {
  display: grid;
  gap: 12px;
}

@media (min-width: 720px) {
  .setup-layout {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  }

  .setup-aside {
    position: sticky;
    top: calc(var(--app-bar-offset) + 16px);
  }
}

.aside-title {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.setup-aside .small {
  font-size: 0.8125rem;
  line-height: 1.7;
}

.setup-footer {
  display: flex;
  justify-content: center;
}

/* ---------- カード ---------- */
.card {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text);
}

@media (max-width: 419px) {
  .card {
    padding: 18px 16px;
  }
}

/* <details> を grid にすると崩れるブラウザがあるので block にする */
details.card {
  display: block;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 14px;
}

.card-header > .card-heading {
  flex: 1 1 12rem;
}

.card-header > button {
  flex: none;
}

.card-heading {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 1.375rem;
  line-height: 1;
}

.card-icon-demo {
  background: var(--demo-soft);
}

.card-icon-danger {
  background: var(--error-bg);
}

.card-title {
  display: block;
  margin: 0;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 1.1875rem;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.card-subtitle {
  display: block;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.65;
}

/* カード全体が 1 つのボタン */
.card-button {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.card-button:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-raised);
}

.card-button:active {
  transform: scale(0.985);
}

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

.card-button-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.card-button-chevron {
  color: var(--text-secondary);
  font-size: 1.75rem;
  line-height: 1;
  transition: transform var(--dur) var(--ease-spring);
}

.card-button:hover .card-button-chevron {
  transform: translateX(3px);
}

/* カードの種類 */
.auth-card {
  box-shadow: var(--shadow-raised);
}

.demo-card {
  border-color: var(--demo-line);
  background: linear-gradient(160deg, var(--demo-soft), transparent 55%), var(--surface);
}

.demo-status-card {
  background: linear-gradient(160deg, var(--demo-soft), transparent 75%), var(--surface);
}

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

.error-card {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px 14px;
  border-color: var(--error-border);
  background: linear-gradient(160deg, var(--error-bg), transparent 60%), var(--surface);
}

.error-card > .card-icon {
  background: var(--error-bg);
}

.error-card > .form-actions {
  grid-column: 1 / -1;
}

.welcome-card {
  border-color: rgb(255 59 107 / 0.28);
  background: linear-gradient(135deg, rgb(255 59 107 / 0.1), rgb(94 92 230 / 0.12)), var(--surface);
}

.issue-card {
  gap: 12px;
}

.result-card {
  border-color: var(--success-border);
  background: linear-gradient(180deg, var(--success-bg), transparent 160px), var(--surface);
}

/* 折りたたみのカード（<details>） */
.disclosure-card-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: -8px -10px;
  padding: 8px 10px;
  border-radius: 14px;
  list-style: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.disclosure-card-summary::-webkit-details-marker {
  display: none;
}

.disclosure-card-summary::after {
  content: "";
  width: 9px;
  height: 9px;
  margin: 0 6px 4px 0;
  border: solid var(--text-secondary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease-out), margin var(--dur) var(--ease-out);
}

.disclosure-card[open] > .disclosure-card-summary {
  margin-bottom: 8px;
}

.disclosure-card[open] > .disclosure-card-summary::after {
  margin-bottom: -4px;
  transform: rotate(-135deg);
}

.disclosure-card-summary:hover {
  background: var(--surface-muted);
}

.disclosure-card-summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
}

.disclosure-card-body {
  display: grid;
  gap: 16px;
  animation: panel-in var(--dur-slow) var(--ease-out) backwards;
}

/* カードの中の折りたたみ（署名した JSON・すべてのコード） */
.disclosure {
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

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

.disclosure > summary::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-left: 2px;
  border: solid var(--text-secondary);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease-out);
}

.disclosure[open] > summary::before {
  transform: rotate(45deg);
}

.disclosure > summary:hover {
  background: var(--surface-muted);
}

.disclosure > summary:focus-visible {
  outline-offset: 0;
}

.disclosure > :not(summary) {
  margin-top: 8px;
}

/* ---------- 手順・チェックリスト・項目の一覧 ---------- */
.step-track {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-track-item {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 12px 7px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.35;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.step-track-dot {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.step-track-item[aria-current="step"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.step-track-item[aria-current="step"] .step-track-dot {
  background: var(--accent-ink);
  box-shadow: none;
  color: var(--surface);
}

.step-track-item.is-done {
  color: var(--ok);
}

.step-track-item.is-done .step-track-dot {
  background: var(--ok-fill);
  box-shadow: none;
  color: var(--on-ok);
}

/* 本登録の 3 段階: 丸を線でつなぐ */
.step-track-wide {
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  gap: 0;
}

.step-track-wide .step-track-item {
  position: relative;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
  border-radius: 0;
  background: none;
  font-size: 0.8125rem;
  text-align: center;
}

.step-track-wide .step-track-item[aria-current="step"] {
  background: none;
}

.step-track-wide .step-track-dot {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}

.step-track-wide .step-track-item + .step-track-item::before {
  content: "";
  position: absolute;
  top: 15px;
  right: calc(50% + 20px);
  left: calc(-50% + 20px);
  height: 2px;
  border-radius: 1px;
  background: var(--border);
}

.step-track-wide .step-track-item.is-done + .step-track-item::before {
  background: var(--ok-fill);
}

/* 箇条書き（丸の中のチェック／注意の線は CSS で描く） */
.check-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 30px;
  font-size: 0.9375rem;
  line-height: 1.65;
}

.check-list li::before {
  content: "";
  position: absolute;
  top: 0.15em;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success-bg);
  box-shadow: inset 0 0 0 1px var(--success-border);
}

.check-list li::after {
  content: "";
  position: absolute;
  top: calc(0.15em + 4px);
  left: 7px;
  width: 6px;
  height: 10px;
  border: solid var(--ok);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.demo-card .check-list li::before {
  background: var(--demo-soft);
  box-shadow: inset 0 0 0 1px var(--demo-line);
}

.demo-card .check-list li::after {
  border-color: var(--demo-ink);
}

.check-list-danger li::before {
  background: var(--error-bg);
  box-shadow: inset 0 0 0 1px var(--error-border);
}

.check-list-danger li::after {
  top: calc(0.15em + 9px);
  left: 6px;
  width: 8px;
  height: 2px;
  border: 0;
  border-radius: 1px;
  background: var(--danger);
  transform: none;
}

/* 項目と値の一覧（<div> で包んだ組でも、dt/dd を直に並べても同じ見た目） */
.meta-list {
  display: grid;
  grid-template-columns: minmax(6.5em, 32%) minmax(0, 1fr);
  margin: 0;
  padding: 2px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.meta-list:empty {
  display: none;
}

.meta-list > div {
  display: contents;
}

.meta-list dt,
.meta-list dd {
  margin: 0;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

.meta-list dt {
  padding-right: 14px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 700;
}

.meta-list dd {
  min-width: 0;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.meta-list > div:first-child > dt,
.meta-list > div:first-child > dd,
.meta-list > dt:first-child,
.meta-list > dt:first-child + dd {
  border-top: 0;
}

@media (max-width: 379px) {
  .meta-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .meta-list dt {
    padding-bottom: 0;
  }

  .meta-list dd {
    padding-top: 2px;
    border-top: 0;
  }
}

/* ---------- ボタン ---------- */
.button-primary,
.button-secondary,
.button-ghost,
.button-danger,
.button-danger-outline {
  text-align: center;
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

/* site.css に無い種類のボタンの形（.button-primary と同じ寸法） */
.button-ghost,
.button-danger,
.button-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  padding: 12px 24px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.button-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--link);
}

.button-ghost:hover {
  background: var(--surface-muted);
  color: var(--link-hover);
}

.button-danger {
  border: 0;
  background: var(--danger-fill);
  color: var(--on-danger);
}

.button-danger:hover {
  background: var(--danger-fill-hover);
}

.button-danger-outline {
  border: 1px solid var(--error-border);
  background: transparent;
  color: var(--danger);
}

.button-danger-outline:hover {
  border-color: var(--danger);
  background: var(--error-bg);
}

.button-primary:active,
.button-secondary:active,
.button-ghost:active,
.button-danger:active,
.button-danger-outline:active {
  transform: scale(0.97);
}

.button-ghost:focus-visible,
.button-danger:focus-visible,
.button-danger-outline:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* デモ用インスタント主催者のボタン（.button-primary と一緒に使う） */
.button-demo,
.button-demo:hover {
  background: var(--demo-strong);
  color: var(--on-demo);
}

.button-demo:hover {
  background: var(--demo-strong-hover);
}

.button-small {
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.875rem;
}

.button-small .button-spinner {
  width: 14px;
  height: 14px;
}

.button-wide {
  width: 100%;
}

.form-actions > .button-wide {
  flex: 1 1 100%;
}

/* 押せない状態（site.css は .button-primary だけを扱う） */
:is(.button-primary, .button-secondary, .button-ghost, .button-danger, .button-danger-outline, .chip-button, .copy-chip, .modal-close)[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-primary[disabled]:hover {
  background: var(--link);
}

.button-secondary[disabled]:hover {
  border-color: var(--border);
}

.button-ghost[disabled]:hover {
  background: transparent;
  color: var(--link);
}

.button-danger[disabled]:hover {
  background: var(--danger-fill);
}

.button-danger-outline[disabled]:hover {
  border-color: var(--error-border);
  background: transparent;
}

.button-demo[disabled]:hover {
  background: var(--demo-strong);
}

/* 処理中（admin.js の setButtonBusy が aria-busy="true" と disabled を付ける） */
:is(.button-primary, .button-secondary, .button-ghost, .button-danger, .button-danger-outline)[aria-busy="true"] {
  opacity: 0.8;
  cursor: progress;
}

/* 狭い画面では、カード・モーダルの主なボタンを横いっぱいに並べる */
@media (max-width: 479px) {
  :is(.card, .modal-body) .form-actions > :is(.button-primary, .button-secondary, .button-ghost, .button-danger, .button-danger-outline):not(.button-small) {
    flex: 1 1 100%;
  }
}

/* コピーできる ID */
.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 32px;
  margin: 0;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: copy;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.copy-chip:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.copy-chip:active {
  transform: scale(0.97);
}

/* 小さな選択ボタン（期間のプリセットなど） */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 0;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.chip-button:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.chip-button:active {
  transform: scale(0.96);
}

.chip-button[aria-pressed="true"] {
  border-color: var(--accent-ink);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* 指で操作する端末では、押せる部品を 44px 以上にする */
@media (pointer: coarse) {
  .button-small {
    min-height: 44px;
    padding-inline: 16px;
  }

  .chip-button,
  .copy-chip {
    min-height: 44px;
  }

  .toast-close {
    width: 44px;
    height: 44px;
  }
}

/* ---------- フォーム ---------- */
.stack-form {
  display: grid;
  gap: 20px;
}

.sub-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 800;
}

.sub-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
}

/* fieldset の既定の枠を消す（.field と一緒に使う） */
.fieldset {
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset > legend {
  padding: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.5;
}

.fieldset > legend .badge {
  margin-left: 8px;
  vertical-align: 1px;
}

.fieldset > .sub-label {
  margin-top: 4px;
}

.field-row {
  display: grid;
  gap: 20px;
  align-items: start;
}

.field-row > * {
  min-width: 0;
}

@media (min-width: 640px) {
  .field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
  }
}

/* 入力欄の共通の見た目（site.css が扱わない数値・日時の欄や、.field の外の欄も同じにする）。詳細度は低くしておく */
.admin-page :where(
  .field input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]),
  .field textarea,
  .inline-field input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"]),
  .hex-field input,
  select
) {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--field-bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* iOS Safari が入力時に拡大しない大きさ */
  line-height: 1.6;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.admin-page select:hover,
.admin-page :is(.inline-field, .hex-field) :is(input, select):hover {
  border-color: var(--text-secondary);
}

.admin-page select:focus-visible,
.admin-page :is(.inline-field, .hex-field) :is(input, select):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.admin-page :is(input, select, textarea):disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 今は変えられない欄（登録済みの SF Symbol のステッカー ID、送信中・認証中のメールアドレスと認証コード） */
.field input[readonly] {
  background-color: var(--surface-muted);
  color: var(--text-secondary);
  cursor: default;
}

/* プルダウン: 端末ごとの見た目をやめ、右端に小さな三角を描く */
.admin-page select {
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
  cursor: pointer;
}

.admin-page input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.admin-page input[type="datetime-local"] {
  display: block;
  min-width: 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.admin-page input[type="datetime-local"]::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

.admin-page input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0.7;
  cursor: pointer;
}

/* ファイルの選択（鍵ファイル） */
.field input[type="file"]:not(.visually-hidden) {
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 7px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button {
  margin: 0 12px 0 0;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.field input[type="file"]::-webkit-file-upload-button {
  margin: 0 12px 0 0;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.field input[type="file"]:hover::file-selector-button {
  border-color: var(--link);
}

/* 等幅の欄（site.css の font: inherit より後・同じ詳細度で上書きする） */
.field input.mono,
.field textarea.mono,
.hex-field input.hex-input {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}

.field textarea.mono {
  min-height: 6em;
  line-height: 1.5;
  word-break: break-all;
}

/* 6桁の認証コード */
.field input.code-input {
  max-width: 20rem;
  min-height: 64px;
  padding: 10px 14px 10px calc(14px + 0.35em); /* 最後の文字の後ろの字間の分だけ左を広げて中央に見せる */
  font: 700 2rem/1.2 var(--font-heading);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.35em;
  text-align: center;
}

/* 入力欄＋ボタン／ラベルの横並び */
.inline-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}

.inline-field > :is(input, select) {
  flex: 1 1 10rem;
  min-width: 0;
}

.inline-field > input[type="number"] {
  flex: 0 1 11rem;
}

.inline-field > :is(button, .sub-label) {
  flex: none;
}

/* カラーコードの欄 */
.hex-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.hex-field > .sub-label {
  flex: 1 0 100%;
}

.hex-prefix {
  flex: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 1.0625rem;
  font-weight: 700;
}

.hex-field > input.hex-input {
  flex: 0 1 9.5rem;
  min-width: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.color-dot {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--hairline-strong);
  border-radius: 50%;
  background: var(--dot-color, transparent);
  box-shadow: 0 0 0 3px var(--surface);
}

/* 読めない色: 赤い破線＋斜線 */
.color-dot.is-invalid {
  border: 2px dashed var(--danger);
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--error-bg) 4px 8px);
}

.counter {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--danger);
}

/* ログイン: 認証コードの送信結果・有効期限・開発用のコード */
.auth-delivery {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  background: var(--success-bg);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.countdown {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.countdown.is-expired {
  color: var(--danger);
}

.debug-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  border: 1px dashed var(--notice-border);
  border-radius: var(--radius-md);
  background: var(--notice-bg);
}

.debug-box .debug-code {
  flex: 1 1 10rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.publish-note {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.form-alert-warning {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--text);
}

.form-alert-info {
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--text);
}

.empty-inline {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.empty-inline p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.image-status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.image-status-row > .field-hint {
  flex: 1 1 auto;
}

.image-status-row > button {
  flex: none;
}

.kind-fields {
  display: grid;
  gap: 12px;
}

/* ---------- 選ぶ部品（セグメント・カテゴリ・シンボル・色） ---------- */
/* セグメント: ラジオは透明にして項目全体に重ね（押せる・フォーカスできる）、選んだ項目を白い面で浮かせる */
.segmented {
  position: relative;
  display: flex;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.segmented-option {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
}

.segmented-option > input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented-option > span {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  transition:
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.segmented-option:hover > span {
  color: var(--text);
}

.segmented-option:has(> input:checked) > span {
  background: var(--thumb);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 12px -4px rgb(0 0 0 / 0.18);
  color: var(--text);
}

/* :has が使えないブラウザ向け（同じ見た目） */
.segmented-option > input:checked + span {
  background: var(--thumb);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 12px -4px rgb(0 0 0 / 0.18);
  color: var(--text);
}

.segmented-option > input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.segmented-option > input:disabled + span {
  opacity: 0.5;
}

@media (pointer: coarse) {
  .segmented-option > span {
    min-height: 44px;
  }
}

/* 主催者のカテゴリ（role="radio" のボタン。--category-color はテーマカラー） */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.category-card {
  --cat: var(--category-color, var(--accent));
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 92px;
  margin: 0;
  padding: 12px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.category-card:hover {
  border-color: color-mix(in srgb, var(--cat) 45%, var(--border));
}

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

.category-card[aria-checked="true"] {
  border-color: var(--cat);
  background: color-mix(in srgb, var(--cat) 10%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--cat);
}

.category-card-glyph {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--cat) 16%, transparent);
  font-size: 1.375rem;
  line-height: 1;
}

.category-card-label {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.35;
}

.category-card[aria-checked="true"] .category-card-label {
  color: color-mix(in srgb, var(--cat) 70%, var(--text));
}

/* 選んだカテゴリの名前も、--accent-ink と同じく明るいテーマカラーで読める濃さにする */
@supports (color: oklch(from red min(l, 0.5) c h)) {
  .category-card[aria-checked="true"] .category-card-label {
    color: oklch(from var(--cat) min(l, 0.5) c h);
  }

  @media (prefers-color-scheme: dark) {
    .category-card[aria-checked="true"] .category-card-label {
      color: oklch(from var(--cat) max(l, 0.78) c h);
    }
  }
}

/* SF Symbol の候補（絵文字＋名前） */
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.symbol-grid:empty {
  display: none;
}

.symbol-tile {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 72px;
  margin: 0;
  padding: 10px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.symbol-tile:hover {
  border-color: var(--accent-line);
}

.symbol-tile:active {
  transform: scale(0.95);
}

.symbol-tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.symbol-tile-glyph {
  font-size: 24px;
  line-height: 1.1;
}

.symbol-tile-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.symbol-tile[aria-pressed="true"] .symbol-tile-name {
  color: var(--accent-ink);
}

/* テーマカラーの候補（32px の丸。押せる範囲は ::before で 44px に広げる） */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 4px;
}

.swatch {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-spring), outline-color var(--dur-fast) var(--ease-out);
}

.swatch::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch:active {
  transform: scale(0.92);
}

.swatch[aria-checked="true"] {
  outline: 3px solid var(--text);
  outline-offset: 3px;
}

.swatch:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- タブ（上部・横スクロール可。下部の固定バーは作らない） ---------- */
.tabs {
  position: sticky;
  top: var(--app-bar-offset);
  z-index: 15;
  display: flex;
  gap: 4px;
  margin-inline: calc(var(--pad-start) * -1) calc(var(--pad-end) * -1);
  padding: 6px var(--pad-end) 0 var(--pad-start);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--glass-page);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}

.tabs::-webkit-scrollbar {
  display: none;
}

/* 狭い画面: アイコンの下に名前を置き、4 つを等分に並べる */
.tab {
  position: relative;
  display: inline-flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 68px;
  min-height: 52px;
  margin: 0;
  padding: 6px 8px 8px;
  border: 0;
  border-radius: 12px 12px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.tab::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent-ink);
  opacity: 0;
  transform: scaleX(0.3);
  transition:
    transform var(--dur-slow) var(--ease-spring),
    opacity var(--dur-fast) var(--ease-out);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--accent-ink);
}

.tab[aria-selected="true"]::after {
  opacity: 1;
  transform: none;
}

.tab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.tab-icon {
  font-size: 1.25rem;
  line-height: 1.1;
  transition: transform var(--dur-slow) var(--ease-spring);
}

.tab[aria-selected="true"] .tab-icon {
  transform: translateY(-1px) scale(1.08);
}

.tab-label {
  min-width: 0;
}

.tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--badge-red);
  box-shadow: 0 0 0 2px var(--surface);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 560px) {
  .tab {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px 10px;
    border-radius: 12px;
    font-size: 0.9375rem;
  }

  .tab::after {
    right: 16px;
    left: 16px;
  }

  .tab-icon {
    font-size: 1.0625rem;
  }

  .tab-badge {
    position: static;
    margin-left: -2px;
    box-shadow: none;
  }
}

/* 広い画面: 内容の幅にそろえた、浮いている角丸のバー */
@media (min-width: 720px) {
  .tabs {
    top: calc(var(--app-bar-offset) + 10px);
    margin-inline: 0;
    padding: 6px;
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
  }

  .tab:hover {
    background: var(--surface-muted);
  }

  .tab::after {
    bottom: 3px;
  }
}

/* 狭い画面のポータルは、タブを上部のバーに続けて置く */
@media (max-width: 719px) {
  body[data-view="portal"] .portal {
    padding-top: 0;
  }
}

.tab-panel {
  display: grid;
  gap: 20px;
  animation: panel-in var(--dur-slow) var(--ease-out) backwards;
}

.tab-panel:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 6px;
  border-radius: var(--radius-lg);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- アカウント ---------- */
.account-header {
  padding: 22px;
  background: radial-gradient(130% 120% at 0% 0%, var(--accent-soft) 0%, transparent 62%), var(--surface);
}

.account-header.is-official {
  border-color: rgb(255 59 107 / 0.3);
  background:
    radial-gradient(120% 120% at 0% 0%, rgb(255 59 107 / 0.12) 0%, transparent 55%),
    radial-gradient(120% 120% at 100% 100%, rgb(94 92 230 / 0.12) 0%, transparent 55%),
    var(--surface);
}

.account-header.is-demo {
  border-color: var(--demo-line);
  background: radial-gradient(130% 120% at 0% 0%, var(--demo-soft) 0%, transparent 62%), var(--surface);
}

.account-header[aria-busy="true"] {
  cursor: progress;
}

.account-header-skeleton {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 12px 18px;
}

.account-header-skeleton .skeleton-avatar {
  grid-row: 1 / span 2;
}

.account-header-skeleton .skeleton-line:nth-child(2) {
  align-self: end;
}

.account-header-skeleton .skeleton-line:nth-child(3) {
  align-self: start;
}

.account-header-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.account-header-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.account-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.account-name {
  margin: 0;
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  font-weight: 800;
  line-height: 1.3;
}

.account-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.account-badges:empty {
  display: none;
}

.account-email {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.account-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.account-description {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  line-height: 1.75;
  white-space: pre-line;
}

/* アイコンのタイル（--avatar-color で色づけ） */
.avatar-tile {
  --av: var(--avatar-color, var(--accent));
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 88px;
}

.avatar-glyph {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: linear-gradient(
    150deg,
    color-mix(in srgb, var(--av) 34%, var(--surface)) 0%,
    color-mix(in srgb, var(--av) 14%, var(--surface)) 100%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--av) 30%, transparent),
    0 12px 26px -16px var(--av);
  font-size: 2.5rem;
  line-height: 1;
}

.avatar-caption {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.avatar {
  --av: var(--avatar-color, var(--accent));
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: color-mix(in srgb, var(--av) 20%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--av) 32%, transparent);
  font-size: 1.25rem;
  line-height: 1;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 1rem;
}

.avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  font-size: 2.25rem;
}

/* 公式・デモの印（長いデモの印は折り返す） */
.badge-official,
.badge-demo {
  font-weight: 800;
  white-space: normal;
}

.badge-official {
  box-shadow: inset 0 0 0 1px rgb(255 59 107 / 0.38);
  color: var(--link);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .badge-official {
    background-image: linear-gradient(120deg, var(--official-from), var(--official-mid) 55%, var(--official-to));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.badge-demo {
  background: var(--demo-soft);
  box-shadow: inset 0 0 0 1px var(--demo-line);
  color: var(--demo-ink);
}

/* 数字のタイル */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-tile {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card .stat-tile {
  border-color: transparent;
  background: var(--surface-muted);
  box-shadow: none;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.45;
}

.stat-value {
  display: block;
  color: var(--text);
  font: 700 1.25rem/1.35 var(--font-heading);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-value.mono {
  font-family: var(--font-mono);
  font-size: 1.0625rem;
}

/* 読み込み直しで数字が変わったときに少しだけ光らせる（admin.js が 600ms だけ .is-updated を付ける） */
.stat-value.is-updated {
  animation: stat-pop 500ms var(--ease-spring);
}

@keyframes stat-pop {
  0% {
    color: var(--accent-ink);
    opacity: 0.35;
    transform: translateY(4px) scale(0.94);
  }

  60% {
    color: var(--accent-ink);
    opacity: 1;
  }

  100% {
    transform: none;
  }
}

@media (max-width: 419px) {
  .stat-tile {
    padding: 12px;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .stat-value.mono {
    font-size: 0.9375rem;
  }
}

/* とても狭い画面では、名前と数字を左右に置いた 1 列の一覧にする */
@media (max-width: 359px) {
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .stat-tile {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 12px;
    padding: 12px 14px;
  }
}

/* デモの残り時間 */
.demo-progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--demo-soft);
  color: var(--demo);
}

.demo-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--demo-soft);
}

.demo-progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--demo), #3a86ff);
  transition: width var(--dur-slow) var(--ease-out);
}

.demo-progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--demo), #3a86ff);
}

/* 本登録のプレビュー */
.profile-preview {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  background: radial-gradient(140% 120% at 0% 0%, var(--accent-soft) 0%, transparent 60%), var(--surface);
}

.profile-preview-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.profile-preview-name {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.4;
}

.profile-preview-icon {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.profile-preview-description {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.65;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

/* ---------- ステッカー ---------- */
.sticker-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.sticker-preview-body {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-width: 0;
}

.sticker-preview-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.4;
}

.sticker-preview-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.sticker-preview-subtitle:empty {
  display: none;
}

/* ステッカーの絵柄（--art-color で色づけしたタイルに、画像・canvas・絵文字を置く） */
.artwork {
  --art: var(--art-color, var(--brand-pink));
  --art-size: 72px;
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: var(--art-size);
  height: var(--art-size);
  overflow: hidden;
  border-radius: calc(var(--art-size) * 0.3);
  background: radial-gradient(
    120% 120% at 28% 18%,
    color-mix(in srgb, var(--art) 34%, var(--surface)) 0%,
    color-mix(in srgb, var(--art) 12%, var(--surface)) 72%
  );
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--art) 26%, transparent);
}

.artwork-lg {
  --art-size: 96px;
}

.artwork-md {
  --art-size: 72px;
}

.artwork-sm {
  --art-size: 48px;
}

.artwork-xs {
  --art-size: 34px;
}

.artwork-canvas,
.artwork-image {
  display: block;
  width: 86%;
  height: 86%;
  object-fit: contain;
}

.artwork-glyph {
  font-size: calc(var(--art-size) * 0.5);
  line-height: 1;
}

.artwork-placeholder {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: max(9px, calc(var(--art-size) * 0.2));
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* 画像のドロップ先 */
.dropzone {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  min-height: 140px;
  padding: 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.dropzone:hover {
  border-color: var(--accent-line);
}

.dropzone:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}

.dropzone.is-busy {
  cursor: progress;
}

.dropzone.is-busy .dropzone-icon {
  animation: dropzone-pulse 1s var(--ease-out) infinite alternate;
}

.dropzone.has-image {
  min-height: 112px;
  border-style: solid;
  border-color: var(--success-border);
  background: var(--success-bg);
}

@keyframes dropzone-pulse {
  to {
    opacity: 0.45;
    transform: scale(0.92);
  }
}

.dropzone-icon {
  font-size: 2rem;
  line-height: 1;
}

.dropzone-title {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.5;
}

.dropzone-hint {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* 登録済みステッカーのタイル */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  container: tiles / inline-size;
}

.sticker-tile {
  display: grid;
  grid-template-areas:
    "art"
    "body"
    "actions";
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 12px;
  min-width: 0;
  padding: 16px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.sticker-tile > .artwork {
  grid-area: art;
}

.sticker-tile:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-raised);
  transform: translateY(-2px);
}

.sticker-tile.is-editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-raised);
}

.tile-body {
  display: grid;
  grid-area: body;
  align-content: start;
  justify-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.tile-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tile-subtitle {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 4px;
}

.tile-id {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tile-actions {
  display: flex;
  flex-wrap: wrap;
  grid-area: actions;
  gap: 6px;
  width: 100%;
}

.tile-actions > * {
  flex: 1 1 auto;
  padding-inline: 8px;
}

.tile-actions > :first-child {
  flex-basis: 100%;
}

/* 一覧が 1 列になる幅では、絵柄を左に置いた横長のタイルにする */
@container tiles (max-width: 359px) {
  .sticker-tile {
    grid-template-areas:
      "art body"
      "actions actions";
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    justify-items: stretch;
    padding: 14px;
    text-align: left;
  }

  .tile-body {
    justify-items: start;
  }

  .tile-meta {
    justify-content: flex-start;
  }

  .tile-actions > :first-child {
    flex-basis: auto;
  }

  .skeleton-tile {
    height: 156px;
  }
}

/* カテゴリのチップ（--chip-color の塗りに、admin.js が読みやすい文字色 --chip-text を指定する） */
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 1px 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--chip-color, var(--surface-muted));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
  color: var(--chip-text, var(--text-secondary));
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.6;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.count-pill {
  display: inline-block;
  min-width: 1.9em;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1.75;
  text-align: center;
  vertical-align: 2px;
  font-variant-numeric: tabular-nums;
}

/* 公開の状態・通報の印 */
.status-badge,
.report-badge,
.share-badge {
  --badge-ink: var(--text-secondary);
  --badge-bg: var(--surface-muted);
  --badge-line: var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px 1px 8px;
  border-radius: 999px;
  background: var(--badge-bg);
  box-shadow: inset 0 0 0 1px var(--badge-line);
  color: var(--badge-ink);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.6;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge::before,
.report-badge::before,
.share-badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge[data-status="published"] {
  --badge-ink: var(--ok);
  --badge-bg: var(--success-bg);
  --badge-line: var(--success-border);
}

.status-badge[data-status="under_review"] {
  --badge-ink: var(--warn-text);
  --badge-bg: var(--warn-bg);
  --badge-line: var(--warn-border);
}

.status-badge[data-status="hidden"] {
  --badge-ink: var(--text-secondary);
  --badge-bg: var(--surface-muted);
  --badge-line: var(--border);
}

.report-badge {
  --badge-ink: var(--danger);
  --badge-bg: var(--error-bg);
  --badge-line: var(--error-border);
}

.share-badge[data-enabled="true"] {
  --badge-ink: var(--ok);
  --badge-bg: var(--success-bg);
  --badge-line: var(--success-border);
}

.share-badge[data-enabled="false"] {
  --badge-ink: var(--warn-text);
  --badge-bg: var(--warn-bg);
  --badge-line: var(--warn-border);
}

/* ---------- イベント ---------- */
.event-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 一覧のカード（「その他」のメニューが下のカードに重なれるよう、transform などで重なりの文脈を作らない） */
.event-card {
  position: relative;
  display: grid;
  grid-template-areas:
    "date body"
    "actions actions";
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.event-card:hover {
  box-shadow: var(--shadow-raised);
}

/* 削除の処理中（admin.js が aria-busy="true" と .is-hidden-soft を付ける） */
.event-card[aria-busy="true"] {
  cursor: progress;
}

.event-card[data-status="under_review"] {
  border-color: var(--warn-border);
  background: linear-gradient(180deg, var(--warn-bg), transparent 70%), var(--surface);
}

.event-card[data-status="hidden"] .date-badge,
.event-card[data-status="hidden"] .event-name {
  opacity: 0.6;
}

/* カレンダーのアイコンのような日付 */
.date-badge {
  display: grid;
  grid-area: date;
  align-content: start;
  justify-items: center;
  width: 64px;
  padding-bottom: 8px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--border), 0 4px 12px -8px rgb(0 0 0 / 0.3);
  line-height: 1.15;
  text-align: center;
}

.date-badge-month {
  width: 100%;
  padding: 4px 0 3px;
  background: var(--badge-red);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.date-badge-day {
  margin-top: 4px;
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.date-badge-weekday {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
}

.event-card[data-status="under_review"] .date-badge-month {
  background: var(--warn-fill);
  color: var(--on-warn);
}

.event-card[data-status="hidden"] .date-badge-month {
  background: var(--text-secondary);
  color: var(--surface);
}

.event-body {
  display: grid;
  grid-area: body;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.event-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.event-name {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 800;
  line-height: 1.4;
}

.event-when,
.event-where {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.event-when {
  font-variant-numeric: tabular-nums;
}

.event-reward {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 8px;
  max-width: 100%;
  margin-top: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-muted);
}

.event-reward-title {
  min-width: 0;
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.event-review-note {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  background: var(--warn-bg);
  font-size: 0.875rem;
  line-height: 1.65;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  grid-area: actions;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
  .event-card {
    grid-template-areas: "date body actions";
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 18px 20px;
  }

  .event-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding-top: 0;
    border-top: 0;
  }

  .event-actions > *,
  .event-actions .more-menu > summary {
    width: 100%;
  }
}

/* 「その他」のメニュー（<details>） */
.more-menu {
  position: relative;
}

.more-menu > summary {
  list-style: none;
}

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

.more-menu[open] > summary {
  background: var(--surface-muted);
}

.more-menu .menu-list {
  top: calc(100% + 6px);
  z-index: 10;
  min-width: 220px;
}

/* イベントの報酬ステッカー（ラジオの一覧） */
.reward-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 8px;
}

.reward-list:empty {
  display: none;
}

.reward-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 58px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.reward-option:hover {
  border-color: var(--accent-line);
}

.reward-option > input[type="radio"] {
  flex: none;
  order: 3;
  width: 20px;
  height: 20px;
  margin: 0 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.reward-option > input[type="radio"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.reward-option-body {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.reward-option-title {
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reward-option-id {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reward-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* :has が使えないブラウザでは上の .is-selected だけで表す */
.reward-option:has(> input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- コード発行 ---------- */
.studio-root,
.offline-studio-host {
  display: grid;
  gap: 20px;
  min-width: 0;
}

/* 署名方式に合わない欄を出さない（admin.js の hidden の切り替えと同じ結果） */
.studio-root[data-mode="cloud"] [data-mode="local"],
.studio-root[data-mode="local"] [data-mode="cloud"] {
  display: none;
}

/* ログインせずに使うオフライン発行では、クラウド専用の部品を出さない */
.studio-root[data-offline="true"] [data-cloud-only] {
  display: none;
}

.target-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.target-row-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.target-row-title {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-heading);
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.target-row-meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* 発行したコード: QR＋項目 */
.result-layout {
  display: grid;
  align-items: start;
  gap: 20px;
}

@media (min-width: 720px) {
  .result-layout {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  }
}

.qr-column {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 0;
}

.qr-column .form-actions {
  justify-content: center;
  gap: 8px;
}

/* QR は常に白地（暗い表示でも読み取れるように） */
.qr-frame {
  width: 100%;
  max-width: 320px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.06), var(--shadow-raised);
}

.qr-frame:empty {
  aspect-ratio: 1;
}

.qr-frame svg,
.qr-frame canvas,
.qr-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.url-text {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.code-block {
  max-height: 320px;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

/* 入力が変わった後の古いコードは薄くして、配らないようにする（QR 自体は admin.js が .is-hidden-soft で薄くする） */
#studio-result :is(.qr-frame, .result-meta, .disclosure, .export-row) {
  transition: opacity var(--dur) var(--ease-out), filter var(--dur) var(--ease-out);
}

#studio-result.is-stale :is(.result-meta, .disclosure, .export-row) {
  opacity: 0.5;
}

#studio-result.is-stale .qr-frame {
  filter: grayscale(1);
}

/* 直後の NFC カードは、書き込みの操作と進捗だけを薄くする（リーダーの接続欄はそのまま使える） */
#studio-result + .studio-nfc :is(.studio-nfc-actions, .studio-nfc-session) {
  transition: opacity var(--dur) var(--ease-out);
}

#studio-result.is-stale + .studio-nfc :is(.studio-nfc-actions, .studio-nfc-session) {
  opacity: 0.5;
}

/* すべてのコードの一覧 */
.code-list {
  display: grid;
  max-height: 420px;
  margin: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  list-style: none;
}

.code-list:empty {
  display: none;
}

.code-row {
  display: grid;
  grid-template-areas:
    "index serial actions"
    "nfc nfc nfc"
    "url url url";
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 10px;
  padding: 8px 8px 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.code-row:first-child {
  border-top: 0;
}

.code-row.is-primary {
  background: var(--accent-soft);
}

.code-row-index {
  grid-area: index;
  min-width: 2em;
  color: var(--text-secondary);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.code-row.is-primary .code-row-index {
  color: var(--accent-ink);
}

.code-row-serial {
  grid-area: serial;
  overflow: hidden;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.code-row-url {
  grid-area: url;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.code-row-nfc-status {
  grid-area: nfc;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px 1px 7px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--badge-line, var(--border));
  background: var(--badge-bg, var(--surface-muted));
  color: var(--badge-ink, var(--text-secondary));
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 1.45;
  white-space: nowrap;
}

.code-row-nfc-status[hidden] {
  display: none;
}

.code-row-nfc-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.code-row-nfc-status[data-state="writing"] {
  --badge-ink: var(--accent-ink);
  --badge-bg: var(--accent-soft);
  --badge-line: var(--accent-line);
}

.code-row-nfc-status[data-state="written"] {
  --badge-ink: var(--ok);
  --badge-bg: var(--success-bg);
  --badge-line: var(--success-border);
}

.code-row-nfc-status[data-state="uncertain"] {
  --badge-ink: var(--warn-text);
  --badge-bg: var(--warn-bg);
  --badge-line: var(--warn-border);
}

.code-row-nfc-status[data-state="error"] {
  --badge-ink: var(--danger);
  --badge-bg: var(--error-bg);
  --badge-line: var(--error-border);
}

.code-row-actions {
  display: flex;
  grid-area: actions;
  gap: 2px;
}

.code-row-actions .button-small,
.code-row-actions .btn-sm {
  padding-inline: 10px;
}

@media (min-width: 720px) {
  .code-row {
    grid-template-areas: "index serial url nfc actions";
    grid-template-columns: 2.5em minmax(0, 9em) minmax(0, 1fr) auto auto;
  }
}

/* 書き出し・印刷 */
.export-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.export-row > .inline-field {
  flex: 1 1 22rem;
}

.export-row .inline-field > select {
  flex: 1 1 12rem;
  max-width: 20rem;
}

@media (min-width: 720px) {
  .export-row > .inline-field {
    justify-content: flex-end;
  }
}

/* NFC 書き込み（#studio-result の直後の独立カード。余白・枠は .card のまま、カード同士の間隔は .studio-root の gap に任せる） */
.studio-nfc {
  gap: 14px;
  min-width: 0;
}

.studio-nfc[hidden] {
  display: none;
}

.studio-nfc .card-header {
  margin: 0;
}

/* 説明文と iPhone アプリへの案内は、段落の余白ではなく grid の gap で間を取る */
.studio-nfc-intro,
.studio-nfc > .small {
  margin: 0;
}

.studio-nfc-device {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.studio-nfc-device-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--text-secondary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.studio-nfc-device-badge[data-state="none"],
.studio-nfc-device-badge[data-state="unsupported"] {
  background: var(--text-secondary);
}

.studio-nfc-device-badge[data-state="ready"],
.studio-nfc-device-badge[data-state="connected"] {
  background: var(--ok-fill);
}

.studio-nfc-device-badge[data-state="connecting"] {
  background: var(--warn-fill);
}

.studio-nfc-device-badge[data-state="uncertain"] {
  background: var(--warn);
  color: #ffffff;
}

.studio-nfc-device-badge[data-state="error"] {
  background: var(--danger-fill);
}

.studio-nfc-device-badge[data-state="writing"] {
  background: var(--accent);
  animation: nfc-pulse 1.1s var(--ease-out) infinite;
}

.studio-nfc-device-status {
  flex: 1 1 14rem;
  margin: 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.55;
}

.studio-nfc-device-actions {
  display: flex;
  gap: 6px;
}

@keyframes nfc-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.studio-nfc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio-nfc-session {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.studio-nfc-session[hidden] {
  display: none;
}

.studio-nfc-session-summary {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.studio-nfc-session-prompt {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.studio-nfc-session-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.studio-nfc-session-bar-fill {
  display: block;
  width: calc(clamp(0, var(--progress, 0), 1) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}

/* 要件指定の NFC ボタン用クラス（.button-secondary / .button-small と同じ見た目に寄せる） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
  padding: 12px 24px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring);
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--text-secondary);
}

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

.btn-secondary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-sm {
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.875rem;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 署名の検証 */
.inspector-result {
  display: grid;
  gap: 14px;
}

.inspector-status {
  --status-fill: var(--text-secondary);
  --status-on: var(--surface);
  --status-ink: var(--text);
  position: relative;
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 14px 16px 14px 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.inspector-status:empty {
  display: none;
}

.inspector-status::before {
  content: "–";
  content: "–" / "";
  position: absolute;
  top: 14px;
  left: 16px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--status-fill);
  color: var(--status-on);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1;
}

.inspector-status[data-status="valid"] {
  --status-fill: var(--ok-fill);
  --status-on: var(--on-ok);
  --status-ink: var(--ok);
  border-color: var(--success-border);
  background: var(--success-bg);
}

.inspector-status[data-status="valid"]::before {
  content: "✓";
  content: "✓" / "";
}

.inspector-status:is([data-status="notYetValid"], [data-status="expired"]) {
  --status-fill: var(--warn-fill);
  --status-on: var(--on-warn);
  --status-ink: var(--warn-text);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.inspector-status:is([data-status="notYetValid"], [data-status="expired"])::before {
  content: "!";
  content: "!" / "";
}

.inspector-status:is([data-status="invalidSignature"], [data-status="unknownKey"], [data-status="legacyFormat"], [data-status="notNokkete"], [data-status="malformed"]) {
  --status-fill: var(--danger-fill);
  --status-on: var(--on-danger);
  --status-ink: var(--danger);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.inspector-status:is([data-status="invalidSignature"], [data-status="unknownKey"], [data-status="legacyFormat"], [data-status="notNokkete"], [data-status="malformed"])::before {
  content: "×";
  content: "×" / "";
}

.inspector-status[data-status="empty"] {
  --status-fill: var(--text-secondary);
  --status-on: var(--surface);
  --status-ink: var(--text);
}

.inspector-status-label,
.inspector-status-detail {
  margin: 0;
}

.inspector-status-label {
  color: var(--status-ink);
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.45;
}

.inspector-status-detail {
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.65;
}

.inspector-warning {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  background: var(--warn-bg);
  font-size: 0.875rem;
  line-height: 1.65;
}

.inspector-warning:empty {
  display: none;
}

/* 判定の枠の中に添える注意（dev 鍵・署名を確認できない内容） */
.inspector-status > .inspector-warning {
  margin-top: 8px;
  background: var(--surface);
}

/* NFC タグの容量（NTAG213 / 215 / 216） */
.capacity-grid {
  display: grid;
  gap: 10px;
}

.capacity-grid:empty {
  display: none;
}

@media (min-width: 480px) {
  .capacity-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* タイルの後に続く目安の文は横いっぱいに */
.capacity-grid > :not(.capacity-tile) {
  grid-column: 1 / -1;
  margin: 0;
}

.capacity-tile {
  --cap-fill: var(--accent);
  --cap-ink: var(--text);
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.capacity-tile[data-fits="true"] {
  --cap-fill: var(--ok-fill);
  --cap-ink: var(--ok);
}

.capacity-tile[data-fits="false"] {
  --cap-fill: var(--danger-fill);
  --cap-ink: var(--danger);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.capacity-tile-label,
.capacity-tile-value {
  margin: 0;
}

.capacity-tile-label {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.capacity-tile-value {
  color: var(--cap-ink);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.capacity-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.capacity-tile[data-fits="false"] .capacity-bar {
  background: var(--surface);
}

/* 使用率（--usage: 0〜1）。1 を超えても枠いっぱいで止める */
.capacity-bar-fill {
  display: block;
  width: calc(clamp(0, var(--usage, 0), 1) * 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--cap-fill, var(--accent));
  transition: width var(--dur-slow) var(--ease-out);
}

/* ---------- 空・読み込み中 ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
}

.card.empty-state {
  padding: 32px 22px;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 6px;
  border-radius: 24px;
  background: linear-gradient(150deg, var(--accent-soft), transparent), var(--surface-muted);
  font-size: 2.25rem;
  line-height: 1;
}

.empty-state-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 800;
}

.empty-state-text {
  max-width: 30em;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.75;
}

.empty-state .form-actions {
  justify-content: center;
  margin-top: 8px;
}

/* スケルトン（光が左から右へ流れる） */
.skeleton {
  display: block;
  border-radius: 8px;
  background-color: var(--skeleton-base);
  background-image: linear-gradient(90deg, var(--skeleton-base) 0%, var(--skeleton-shine) 50%, var(--skeleton-base) 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 150% 0;
  }

  to {
    background-position: -50% 0;
  }
}

.skeleton-line {
  width: 100%;
  height: 14px;
  border-radius: 7px;
}

.skeleton-w40 {
  width: 40%;
}

.skeleton-w60 {
  width: 60%;
}

.skeleton-w80 {
  width: 80%;
}

.skeleton-avatar {
  width: 80px;
  height: 80px;
  border-radius: 24px;
}

.skeleton-tile {
  height: 236px;
  border-radius: 18px;
}

.skeleton-card {
  height: 132px;
  border-radius: var(--radius-lg);
}

/* ---------- モーダル（<dialog>） ---------- */
dialog.modal {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: 0 0 0 1px var(--glass-border), 0 30px 80px -24px rgb(0 0 0 / 0.5);
  color: var(--text);
  overflow-wrap: anywhere;
}

dialog.modal.modal-wide {
  max-width: 720px;
}

/* 見出し・本文・ボタンの縦並び。本文だけをスクロールさせる */
dialog.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in var(--dur-slow) var(--ease-spring) backwards;
}

/* ::backdrop はカスタムプロパティを受け継がないブラウザがあるので、値を直に書く */
dialog.modal::backdrop {
  background: rgb(0 0 0 / 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

dialog.modal[open]::backdrop {
  animation: backdrop-in 200ms ease-out backwards;
}

dialog.modal[data-busy="true"] {
  cursor: progress;
}

dialog.modal[data-busy="true"] .modal-close {
  opacity: 0.4;
  pointer-events: none;
}

.modal-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}

.modal-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 1.1875rem;
  font-weight: 800;
  line-height: 1.4;
}

.modal-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

@media (pointer: coarse) {
  .modal-close {
    width: 44px;
    height: 44px;
  }
}

.modal-body {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 14px;
  min-height: 0;
  max-height: 70vh;
  max-height: 70dvh;
  padding: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-body.stack-form {
  gap: 20px;
}

.modal-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.75;
  white-space: pre-line;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0.6;
    transform: translateY(48px);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

/* 狭い画面では下から出るシートにする */
@media (max-width: 559px) {
  dialog.modal,
  dialog.modal.modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }

  dialog.modal[open] {
    animation-name: sheet-in;
  }

  .modal-body {
    max-height: none;
  }

  .modal-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .modal-footer > * {
    flex: 1 1 auto;
  }
}

/* ---------- 印刷シート（画面では全画面のプレビュー） ---------- */
.print-sheet {
  display: none;
}

.print-sheet.is-open {
  position: fixed;
  inset: 0;
  z-index: 25; /* 上部のバー・タブより上、通知（30）より下 */
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--desk);
  color: var(--text);
  animation: view-in var(--dur-slow) var(--ease-out) backwards;
}

body.is-print-preview {
  overflow: hidden;
}

.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--pad-end) 12px var(--pad-start);
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bar);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}

.print-toolbar-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.4;
}

.print-toolbar .form-actions {
  gap: 8px;
}

/*
 * 用紙は A4（210×297mm）、余白 10mm → 印刷できる範囲は 190×277mm。
 * --mm を「1mm」の長さとして使い、画面では用紙の幅を画面に合わせて縮め、印刷では 1mm にする。
 */
.sheet-pages {
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 24px var(--pad-end) calc(48px + env(safe-area-inset-bottom, 0px)) var(--pad-start);
  container: sheet-pages / inline-size;
}

.sheet-page {
  --mm: 1mm;
  position: relative;
  width: calc(210 * var(--mm));
  aspect-ratio: 210 / 297;
  padding: calc(10 * var(--mm));
  overflow: hidden;
  border-radius: 3px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 18px 40px -18px rgb(0 0 0 / 0.45);
  color: #000000;
}

@supports (width: 1cqi) {
  .sheet-page {
    --mm: calc(min(100cqi, 210mm) / 210);
  }
}

/*
 * 面付け（data-layout = 1 / 6 / 12 / 24 面）。行の高さは 275mm（277mm から端数の余裕 2mm）を行数で割る。
 * 各セルに QR・表示名・シリアル・配布期間・kid を載せる（24 面だけは kid を省き、シリアルと配布期間までにする）。
 * QR の大きさは「既定の大きさ（--qr-max）」と「表示名・補足の行と一緒にセルへ収まる大きさ」の小さい方:
 *   1 面 150mm（セル 190×275mm）/ 6 面 約70mm（95×91.7mm）/ 12 面 約49mm（63.3×68.8mm）/ 24 面 約34.5mm（47.5×45.8mm）。
 * 文字の大きさ（mm）は 表示名 5 / 3.5 / 3 / 2.4、補足 3.5 / 2.7 / 2.5 / 2.2（補足はおよそ 10 / 7.7 / 7.1 / 6.2pt）。
 * 行の高さは line-height（--lh）に 0.05 を足して見積もり、フォントの違いで最後の行がはみ出さないようにする。
 */
.sheet-grid {
  --cols: 3;
  --rows: 4;
  --qr-max: 52;
  --pad: 1.6;
  --gap: 0.5;
  --lh: 1.25;
  --title-size: 3;
  --meta-size: 2.5;
  --meta-lines: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: calc(275 / var(--rows) * var(--mm));
  border-top: calc(0.2 * var(--mm)) dashed #c4c4cc;
  border-left: calc(0.2 * var(--mm)) dashed #c4c4cc;
}

.sheet-grid[data-layout="1"] {
  --cols: 1;
  --rows: 1;
  --qr-max: 150;
  --pad: 4;
  --gap: 1.2;
  --title-size: 5;
  --meta-size: 3.5;
  --meta-lines: 3;
  border: 0;
}

.sheet-grid[data-layout="6"] {
  --cols: 2;
  --rows: 3;
  --qr-max: 80;
  --pad: 2;
  --gap: 0.6;
  --title-size: 3.5;
  --meta-size: 2.7;
  --meta-lines: 3;
}

.sheet-grid[data-layout="12"] {
  --cols: 3;
  --rows: 4;
  --qr-max: 52;
  --pad: 1.6;
  --gap: 0.5;
  --title-size: 3;
  --meta-size: 2.5;
  --meta-lines: 3;
}

/* 24 面は QR を 34mm 以上に保つため、余白・行間を詰めて補足を 2 行（シリアル・配布期間）にする */
.sheet-grid[data-layout="24"] {
  --cols: 4;
  --rows: 6;
  --qr-max: 40;
  --pad: 0.6;
  --gap: 0.4;
  --lh: 1.2;
  --title-size: 2.4;
  --meta-size: 2.2;
  --meta-lines: 2;
}

/* 1 枚ずつ切り離せるよう、セルの右と下に薄い破線を引く（1 面は引かない） */
.sheet-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center; /* 万一はみ出しても、QR の上端ではなく下の行が切れるようにする */
  gap: calc(var(--gap) * var(--mm));
  min-width: 0;
  min-height: 0;
  padding: calc(var(--pad) * var(--mm));
  overflow: hidden;
  border-right: calc(0.2 * var(--mm)) dashed #c4c4cc;
  border-bottom: calc(0.2 * var(--mm)) dashed #c4c4cc;
  color: #000000;
  text-align: center;
  break-inside: avoid;
}

.sheet-grid[data-layout="1"] .sheet-cell {
  border: 0;
}

.sheet-cell-qr {
  --qr: min(
    var(--qr-max),
    calc(190 / var(--cols) - 2 * var(--pad) - 0.4),
    calc(275 / var(--rows) - 2 * var(--pad) - 0.4 - (var(--lh) + 0.05) * (var(--title-size) + var(--meta-size) * var(--meta-lines)) - var(--gap) * (var(--meta-lines) + 1))
  );
  display: block;
  flex: none;
  width: calc(var(--qr) * var(--mm));
  height: calc(var(--qr) * var(--mm));
  overflow: hidden;
  background: #ffffff;
}

/* <svg> の width / height 属性（画素数）ではなく、枠の大きさに合わせる */
.sheet-cell-qr svg,
.sheet-cell-qr img,
.sheet-cell-qr canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
}

/* QR を作れなかったセルの案内（暗い表示のプレビューでも、用紙の上では白地に黒い文字） */
.sheet-cell-qr > .empty-inline {
  place-content: center;
  justify-items: center;
  width: 100%;
  height: 100%;
  padding: calc(2 * var(--mm));
  border: calc(0.3 * var(--mm)) dashed #8e8e96;
  border-radius: calc(2 * var(--mm));
  background: #ffffff;
  color: #000000;
  font-size: calc(var(--meta-size) * var(--mm));
  line-height: 1.4;
}

.sheet-cell-title,
.sheet-cell-meta {
  display: block;
  flex: none;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  line-height: var(--lh);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sheet-cell-title {
  color: #000000;
  font-family: var(--font-heading);
  font-size: calc(var(--title-size) * var(--mm));
  font-weight: 800;
}

.sheet-cell-meta {
  color: #3a3a40;
  font-size: calc(var(--meta-size) * var(--mm));
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/*
 * QR の大きさの計算に入れた行数（--meta-lines）を超える補足は出さない（途中で切れた行を残さない）。
 * 1 / 6 / 12 面はシリアル・配布期間・kid の 3 行をすべて出し、24 面だけ 3 行目（kid）を省く。
 */
.sheet-cell-meta ~ .sheet-cell-meta ~ .sheet-cell-meta ~ .sheet-cell-meta,
.sheet-grid[data-layout="24"] .sheet-cell-meta ~ .sheet-cell-meta ~ .sheet-cell-meta {
  display: none;
}

.sheet-empty {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  text-align: center;
}

.sheet-page .sheet-empty {
  color: #6b6b75;
  font-size: calc(3.2 * var(--mm));
}

/* ---------- フッター ---------- */
.admin-page .site-footer .container {
  max-width: calc(var(--portal-max) + var(--gutter) * 2);
}

/* ---------- 対応していない環境・設定への配慮 ---------- */
/* 背景をぼかせないブラウザ・透明度を減らす設定では、浮いている層を不透明にする */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .app-bar,
  .print-toolbar {
    background: var(--surface);
  }

  .tabs {
    background: var(--bg);
  }

  .toast {
    background: var(--surface-raised);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .app-bar,
  .print-toolbar,
  .tabs,
  .toast {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .app-bar,
  .print-toolbar {
    background: var(--surface);
  }

  .tabs {
    background: var(--bg);
  }

  .toast {
    background: var(--surface-raised);
  }
}

/* color-mix が使えないブラウザでは、色づけの面を落ち着いた灰色にする */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .avatar,
  .avatar-glyph,
  .artwork,
  .category-card-glyph {
    background: var(--surface-muted);
    box-shadow: inset 0 0 0 1px var(--border);
  }

  .category-card:hover {
    border-color: var(--text-secondary);
  }

  .category-card[aria-checked="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
  }

  .category-card[aria-checked="true"] .category-card-label {
    color: var(--accent-ink);
  }
}

/* 強制カラー（Windows のハイコントラストなど）: 背景色で表していた選択状態を輪で表す */
@media (forced-colors: active) {
  .badge-official {
    background-image: none;
    -webkit-text-fill-color: currentColor;
  }

  .tab::after,
  .capacity-bar-fill,
  .studio-nfc-session-bar-fill {
    background: Highlight;
    forced-color-adjust: none;
  }

  .segmented-option > input:checked + span,
  .category-card[aria-checked="true"],
  .symbol-tile[aria-pressed="true"],
  .reward-option.is-selected,
  .chip-button[aria-pressed="true"],
  .code-row.is-primary {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }

  .skeleton {
    border: 1px solid GrayText;
  }
}

/* ---------- 動きを減らす設定 ---------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0s;
    --dur: 0s;
    --dur-slow: 0s;
  }

  .view,
  .tab-panel,
  .menu-list,
  .disclosure-card-body,
  .stat-value.is-updated,
  .launch-mark,
  .skeleton,
  .dropzone.is-busy .dropzone-icon,
  .studio-nfc-device-badge[data-state="writing"],
  .print-sheet.is-open,
  dialog.modal[open],
  dialog.modal[open]::backdrop {
    animation: none;
  }

  .toast,
  .sticker-tile:hover,
  .card-button:hover .card-button-chevron,
  .dropzone.is-over,
  .swatch:hover,
  .tab[aria-selected="true"] .tab-icon,
  .button-primary:active,
  .button-secondary:active,
  .btn-secondary:active,
  .button-ghost:active,
  .button-danger:active,
  .button-danger-outline:active,
  .organizer-menu-button:active,
  .card-button:active,
  .copy-chip:active,
  .chip-button:active,
  .category-card:active,
  .symbol-tile:active,
  .swatch:active {
    transform: none;
  }

  .tab::after {
    transform: none;
  }
}

/* ---------- 印刷（印刷用シートだけを A4 に出す） ---------- */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  /* 暗い表示の設定でも、用紙・余白は白にする */
  :root {
    color-scheme: light;
    background: #ffffff;
  }

  body.admin-page {
    display: block;
    min-height: 0;
    background: #ffffff;
  }

  /* overflow: hidden のままだと 1 ページ目しか出ないブラウザがある */
  body.is-print-preview {
    overflow: visible;
  }

  body > *:not(#print-sheet) {
    display: none !important;
  }

  /* site.css の [hidden] より強く、閉じていても印刷では出す */
  #print-sheet {
    position: static;
    inset: auto;
    z-index: auto;
    display: block !important;
    overflow: visible;
    background: #ffffff;
    color: #000000;
    animation: none;
  }

  #print-sheet .print-toolbar {
    display: none;
  }

  /* 印刷では --mm を 1mm に固定するので、コンテナクエリの入れ物にしない（サイズの封じ込めがページ送りを妨げないように） */
  #print-sheet .sheet-pages {
    display: block;
    gap: 0;
    padding: 0;
    container-type: normal;
  }

  #print-sheet .sheet-page {
    --mm: 1mm;
    width: auto;
    aspect-ratio: auto;
    padding: 0;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #print-sheet .sheet-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  /* 小さな補足の文字も網点にならないよう黒で刷る */
  #print-sheet .sheet-cell-meta {
    color: #000000;
  }

  #print-sheet .sheet-cell,
  #print-sheet .sheet-cell-qr {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #print-sheet .sheet-empty {
    color: #000000;
  }
}
