/* ==============================
   30 Components
   ============================== */

/* Card / Typography */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow:var(--card-shadow);
}
.card + .card{ margin-top:16px }
.card-title{ margin:0 0 10px; font-size:18px }
.card.mini{ padding:12px }

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

/* Buttons */
.btn, .btn-small, .menu-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  background:var(--primary);
  color:#fff;
  border:0;
  cursor:pointer;
  border-radius:12px;
  font-weight:700;
  text-align:center;
  transition:transform .03s, box-shadow .15s, background-color .15s;
  box-shadow:0 6px 14px rgba(59,130,246,.28);
  min-height:44px;
  font-size:16px;
}
.btn{ padding:12px 16px }
.btn-small{ padding:6px 12px; font-size:14px; border-radius:8px; min-height:36px }
.menu-btn{ width:100%; padding:16px; text-decoration:none }

.btn:hover,.menu-btn:hover{ box-shadow:0 10px 20px rgba(59,130,246,.32) }
.btn:active,.menu-btn:active{ background:var(--primary-pressed); transform:translateY(1px) }
.btn[disabled]{ opacity:.6; cursor:not-allowed; box-shadow:none }

/* horizontal nav menu */
.menu--nav{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px }
.menu--nav .menu-btn{
  flex:0 0 auto;
  padding:8px 14px;
  font-size:14px;
  border-radius:8px;
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text);
  font-weight:600;
  box-shadow:none;
}
.menu--nav .menu-btn:hover{ background:#1e293b }

/* Home menu spacing (universal insurance) */
.menu, .menu-list, .menu-block, .home-menu{
  display:grid;
  gap:16px;
}
.menu a.menu-btn,
.menu-list a,
.home-menu a{
  display:block;
  width:100%;
  padding:16px;
  border-radius:14px;
  background:var(--primary);
  color:#fff;
  text-align:center;
  text-decoration:none;
  font-weight:700;
  box-shadow:0 6px 14px rgba(59,130,246,.28);
}
.menu a.menu-btn:hover,
.menu-list a:hover,
.home-menu a:hover{ filter:brightness(.96); text-decoration:none; }
.menu a.menu-btn > *{ line-height:1.3; }

/* Pills */
.pill{
  display:inline-block;
  padding:.35rem .8rem;
  border-radius:999px;
  font-weight:600;
  letter-spacing:.02em;
  border:1px solid transparent;
  background:#2b3440;
  color:#e7edf4;
}
.pill--open{ background:#123421; border-color:#1e6a3c; color:#d8ffe6 }
.pill--recording{ background:#1c2548; border-color:#485ad0; color:#e4eaff; box-shadow:0 0 0 2px #3848c880 inset }
.pill--closed{ background:#3d2121; border-color:#b54a4a; color:#ffe3e3; box-shadow:0 0 0 2px #c44 inset }

/* Badge (single source of truth) */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  line-height:1;
  border:1px solid rgba(148,163,184,.35);
  background:#0b1220;
  color:var(--muted);
  white-space:nowrap;
}
.badge--ok{ color:#86efac; border-color:#14532d; background:#062612 }
.badge--warn{ color:#fde68a; border-color:#7c2d12; background:#261407 }
.badge--err{ color:#fecaca; border-color:#7f1d1d; background:#2a0f12 }
.badge-nb{
  display:inline-block;
  background:#fff1f0;
  border:1px solid #ffa39e;
  color:#a8071a;
  font-size:.82em;
  padding:.06rem .4rem;
  border-radius:6px;
  margin-left:.35rem;
}

/* Alerts / Flash */
.flash-success{
  background:#0a2e23;
  color:#a7f3d0;
  border:1px solid #065f46;
  padding:10px 12px;
  border-radius:12px;
  margin-bottom:10px;
}

.alert{
  padding:10px 12px;
  border-radius:10px;
  margin:8px 0;
  border:1px solid rgba(148,163,184,.25);
  background: rgba(148,163,184,.08);
  color: var(--text);
}
.alert-ok{
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.12);
  color: #dcfce7;
}
.alert-info{
  border-color: rgba(59,130,246,.45);
  background: rgba(59,130,246,.12);
  color: #dbeafe;
}
.alert-warn{
  border-color: rgba(245,158,11,.50);
  background: rgba(245,158,11,.14);
  color: #ffedd5;
}
.alert-err,
.alert-error{ /* compat */
  border-color: rgba(239,68,68,.55);
  background: rgba(239,68,68,.14);
  color: #fee2e2;
}

/* Details / mini-details */
details summary{ cursor:pointer }
details[open] summary{ margin-bottom:6px }

.mini-details summary{
  cursor:pointer;
  list-style:none;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.mini-details summary::-webkit-details-marker{display:none;}
.mini-details summary:after{ content:"▾"; opacity:.7; font-size:.9em; }
.mini-details[open] summary:after{ content:"▴"; }

.mini-details__body{
  margin-top:8px;
  padding:10px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow:var(--card-shadow);
  min-width:180px;
}
.mini-table{ width:100%; border-collapse:collapse; }
.mini-table th,.mini-table td{ padding:6px 8px; border-bottom:1px solid var(--border); }
.mini-table tr:last-child th,.mini-table tr:last-child td{ border-bottom:none; }

/* Modal */
.modal{ position:fixed; inset:0; z-index:9999; }
.modal-backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
.modal-body{
  position:relative;
  max-height:85vh;
  overflow:auto;
  margin:10vh auto 0;
  width:min(520px, calc(100% - 24px));
  box-shadow:0 18px 40px rgba(0,0,0,.45);
  border:1px solid rgba(255,255,255,.08);
}
@media (max-width: 480px){
  .modal-body{ margin-top:6vh; }
}

/* ==============================
   Unclassed button rescue
   .btn を優先、クラス無しは自動でそれっぽく
   ============================== */

button:not(.btn):not(.btn-small):not(.menu-btn),
input[type="submit"]:not(.btn):not(.btn-small),
input[type="button"]:not(.btn):not(.btn-small),
input[type="reset"]:not(.btn):not(.btn-small){
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  background:var(--primary);
  color:#fff;
  border:0;
  cursor:pointer;
  border-radius:12px;
  font-weight:700;
  text-align:center;
  min-height:44px;
  padding:12px 16px;
  font-size:16px;
  box-shadow:0 6px 14px rgba(59,130,246,.28);
}

button:not(.btn):not(.btn-small):not(.menu-btn):hover,
input[type="submit"]:not(.btn):not(.btn-small):hover,
input[type="button"]:not(.btn):not(.btn-small):hover{
  filter:brightness(.96);
}

button:not(.btn):not(.btn-small):not(.menu-btn):active,
input[type="submit"]:not(.btn):not(.btn-small):active{
  background:var(--primary-pressed);
  transform:translateY(1px);
}

button[disabled],
input[disabled]{
  opacity:.6;
  cursor:not-allowed;
  box-shadow:none;
}

/* =========================
   Tabs Component
========================= */

.tabs{
  display:flex;
  gap:6px;
  border-bottom:1px solid var(--border, rgba(255,255,255,.12));
  margin-bottom:16px;
  overflow-x:auto;
  scrollbar-width:none;
}

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

.tab-link{
  position:relative;
  padding:10px 16px;
  font-size:.92rem;
  text-decoration:none;
  color:var(--text-muted, rgba(255,255,255,.6));
  background:transparent;
  border-radius:8px 8px 0 0;
  transition:all .15s ease;
  white-space:nowrap;
}

.tab-link:hover{
  color:var(--text, #fff);
  background:rgba(255,255,255,.05);
}

.tab-link.is-active{
  color:var(--text, #fff);
  background:var(--surface, rgba(255,255,255,.06));
  font-weight:600;
}

.tab-link.is-active::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:-1px;
  height:3px;
  border-radius:3px 3px 0 0;
  background:var(--accent, #4cafef);
}