:root {
  /* Cream-based elegant palette */
  --bg: #faf5ee;
  /* 背景クリーム */
  --panel: #ffffff;
  /* パネル/カードの紙色 */
  --card: #ffffff;
  --text: #1f2937;
  /* gray-800 */
  --muted: #6b7280;
  /* gray-500 */
  --brand: #3556d4;
  /* 落ち着いたロイヤルブルー */
  --accent: #c19a41;
  /* 上品なゴールド */
  --ok: #17894f;
  /* グリーン */
  --warn: #b45309;
  /* アンバー */
  --danger: #c81e1e;
  /* レッド */
  --border: #e7e2db;
  /* アイボリーボーダー */
  --chip: #f7f1e8;
  /* 薄い紙色チップ */
  --input: #fffdf7;
  /* 入力欄の紙色 */
  --focus: #3657d6;
  /* フォーカスブルー */
  --logo-from: #f0c85c;
  --logo-to: #d09a24;
  --logo-outline: #f3d390;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 15% -18%, #fffdf8 0%, transparent 60%),
    radial-gradient(1100px 700px at 100% -10%, #fff7e6 0%, transparent 58%),
    linear-gradient(180deg, #fff8ef, var(--bg) 55%, #fffaf2);
  color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none
}

a:hover {
  text-decoration: underline
}

/* layout */
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 252, 247, .78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #0f172a
}

.brand .logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--logo-from), var(--logo-to));
  box-shadow: 0 0 0 2px #ffffff inset;
  outline: 1px solid var(--logo-outline);
}

.grow {
  flex: 1
}

main {
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: #374151;
  /* gray-700 */
  font-size: .9rem
}

.help {
  color: var(--muted);
  font-size: .92rem
}

/* controls */
input[type="text"],
select {
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  box-shadow: 0 1px 0 rgba(17, 24, 39, .03) inset;
}

input::placeholder {
  color: #9ca3af
}

input:focus,
select:focus {
  border-color: #c7d2fe;
  box-shadow: 0 0 0 3px rgba(54, 87, 214, .22);
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff, #fbfaf7);
  color: #1f2937;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  transition: box-shadow .15s ease, transform .05s ease, filter .15s ease;
}

.btn:hover {
  box-shadow: 0 1px 2px rgba(17, 24, 39, .05), 0 6px 20px rgba(17, 24, 39, .06)
}

.btn:active {
  transform: translateY(1px)
}

.btn.primary {
  background: linear-gradient(180deg, #3b5be3, #2c49c9);
  border-color: #2a3fa9;
  color: #ffffff;
}

.btn.ghost {
  background: transparent
}

.btn.ok {
  background: linear-gradient(180deg, #f0fbf6, #e5f9ef);
  border-color: #c9f1da;
  color: #0b5a38;
}

.btn.warn {
  background: linear-gradient(180deg, #fff7e8, #fff1d6);
  border-color: #f6e3b3;
  color: #7a3b06;
}

.btn.danger {
  background: linear-gradient(180deg, #fff2f2, #ffe7e9);
  border-color: #ffd0d5;
  color: #8f0f20;
}

.btn.sm {
  padding: 6px 9px;
  border-radius: 8px;
  font-size: .92rem
}

/* grid */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr)
}

@media (max-width:1200px) {
  .grid {
    grid-template-columns: repeat(3, 1fr)
  }
}

@media (max-width:900px) {
  .grid {
    grid-template-columns: repeat(2, 1fr)
  }
}

@media (max-width:560px) {
  .grid {
    grid-template-columns: 1fr
  }
}

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 88px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 10px 24px rgba(17, 24, 39, .03);
}

.avatar {
  width: var(--avatar, 54px);
  height: var(--avatar, 54px);
  border-radius: 12px;
  object-fit: cover;
  background: #f0e9e0;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.meta {
  flex: 1;
  min-width: 0
}

.name {
  font-weight: 700;
  color: #111827
}

.muted {
  color: var(--muted);
  font-size: .9rem
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

.badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e3d6b8;
  background: #fbf5e6;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .82rem;
  color: #7a5a12;
}

/* status pills */
.state {
  font-weight: 700;
  font-size: .86rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #cfdafc;
  background: #eff3ff;
  color: #213a9a;
  /* ブルー系 */
}

.state.live {
  background: #ecfbf3;
  color: #0b5a38;
  border-color: #bfead3;
}

.state.over {
  background: #fff7e8;
  color: #7a3b06;
  border-color: #f3d090;
}

/* panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
}

/* pagination */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 10px
}

.pagination .btn[aria-current="true"] {
  outline: 2px solid rgba(54, 87, 214, .22);
}

/* toast */
dialog.toast {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  box-shadow: 0 12px 36px rgba(17, 24, 39, .12);
}

dialog::backdrop {
  background: rgb(0 0 0 / .18)
}

/* alert pulse */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(180, 83, 9, .28)
  }

  70% {
    box-shadow: 0 0 0 10px rgba(180, 83, 9, 0)
  }

  100% {
    box-shadow: 0 0 0 0 rgba(180, 83, 9, 0)
  }
}

.overshift {
  outline: 1px solid #f3b56480;
  animation: pulse 1.6s ease-out infinite
}

/* header clock */
.clock {
  font-variant-numeric: tabular-nums
}

/* 1) 検索フォームが右にはみ出る対策（iOS/Safariのflex収縮対策） */
.toolbar {
  min-width: 0;
  /* ← これが重要：flex内で子要素を縮められるように */
  flex: 0 1 320px;
  /* 右端でほどよく縮む */
}

#search {
  width: 100%;
  /* 親(.toolbar)の幅に合わせる */
  max-width: 100%;
  min-width: 0;
}

/* 2) モバイル時はヘッダーをグリッドにして
      時計を中央、検索を2段目で全幅にする */
@media (max-width: 640px) {
  header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      "brand clock ."
      "search search search";
    gap: 10px;
  }

  .brand {
    grid-area: brand;
  }

  .clock {
    grid-area: clock;
    justify-self: center;
    /* 時計をど真ん中へ */
  }

  .grow {
    display: none;
  }

  /* スペーサーはモバイルでは不要 */
  .toolbar {
    grid-area: search;
    width: 100%;
  }

  #search {
    width: 100%;
  }

  /* 入力欄は全幅 */
}