/* ============================================================
   SITOA style.css
   全画面共通(index.html / master.html)
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background: #f5f6f8;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

body.master-body { background: #0b1220; color: #e5e7eb; }

a { color: inherit; }
button { font-family: inherit; }
input, button, textarea, select { font-size: inherit; }

/* ----------- 共通レイアウト ----------- */
.app-root, .master-root { min-height: 100vh; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ----------- TopBar ----------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 10;
}
body.master-body .topbar {
  background: #111827;
  border-bottom: 1px solid #1f2937;
}
.topbar-title { font-weight: 700; letter-spacing: 0.02em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ----------- Card ----------- */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
body.master-body .card {
  background: #111827;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.card-center {
  max-width: 420px;
  margin: 40px auto;
}
.master-card { margin-top: 120px; }

/* ----------- Typography ----------- */
.brand {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
  margin-bottom: 8px;
}
.brand.small { font-size: 20px; }
.h2 { font-size: 22px; font-weight: 700; text-align: center; }
.lead { text-align: center; font-size: 16px; margin: 16px 0; }
.muted { color: #6b7280; }
body.master-body .muted { color: #9ca3af; }
.small { font-size: 13px; }
.mono { font-family: "SFMono-Regular", Menlo, Consolas, monospace; }
.spacer { height: 16px; }
.error { color: #dc2626; min-height: 18px; margin-top: 8px; }

/* ----------- Form ----------- */
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 4px;
  color: #374151;
}
body.master-body .label { color: #d1d5db; }

.text-input, .code-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus, .code-input:focus { border-color: #2563eb; }
body.master-body .text-input, body.master-body .code-input {
  background: #0b1220; color: #e5e7eb; border-color: #374151;
}

.code-input {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 32px;
  text-align: center;
  letter-spacing: 0.4em;
  padding: 14px;
  text-transform: uppercase;
}

/* ----------- Buttons ----------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.full { width: 100%; margin-top: 12px; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid #d1d5db;
}
body.master-body .btn-ghost { border-color: #374151; }
.btn-danger { background: #dc2626; color: #fff; }

/* ----------- Tabs ----------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  overflow-x: auto;
}
body.master-body .tabs {
  background: #111827; border-bottom: 1px solid #1f2937;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

/* ----------- Row ----------- */
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0;
}
.row > .text-input { flex: 1; min-width: 140px; }

/* ----------- Table ----------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #e5e7eb;
}
.tbl th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}
body.master-body .tbl th {
  background: #1f2937; color: #d1d5db;
}
body.master-body .tbl th, body.master-body .tbl td {
  border-bottom: 1px solid #1f2937;
}
.tbl tbody tr:hover { background: rgba(37, 99, 235, 0.04); }

/* ----------- Toast ----------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 1000;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

/* ----------- Loading ----------- */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.loading.hidden { display: none; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------- Modal ----------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  color: #0f172a;
}
.kit-text {
  background: #f3f4f6;
  padding: 16px;
  border-radius: 8px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 12px 0;
}

/* ----------- Chips ----------- */
.chip-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 0;
  flex-wrap: wrap;
}
.chip-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  padding-top: 7px;
  min-width: 84px;
}
body.master-body .chip-label { color: #d1d5db; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}
.chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.chip:hover { border-color: #9ca3af; background: #f9fafb; }
.chip.selected {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.chip.selected:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ----------- Row right (button align) ----------- */
.row-right {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 4px;
}

/* ----------- Modal extras ----------- */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 26px;
  color: #6b7280;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.modal-close:hover { color: #111827; }
.modal-body { max-height: 60vh; overflow: auto; padding: 4px 2px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.form-grid .label { margin-top: 12px; }
.form-grid .label:first-child { margin-top: 0; }
.mt8 { margin-top: 8px; }

/* ----------- Mobile ----------- */
@media (max-width: 640px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 8px 6px; }
  .row { flex-direction: column; align-items: stretch; }
  .row > .btn { width: 100%; }
  .row-right > .btn { width: 100%; }
  .modal { padding: 16px; }
  .chip-block { flex-direction: column; align-items: stretch; gap: 4px; }
  .chip-label { min-width: auto; padding-top: 0; }
}
