:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0f766e;
  --danger: #b91c1c;
  --warning: #9a3412;
  --ok: #166534;
  --border: #d1d5db;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #eef2ff, var(--bg));
}

.container {
  width: min(920px, 94vw);
  margin: 32px auto;
}

.auth-container {
  width: min(460px, 94vw);
  margin-top: 64px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-panel h1 {
  margin-bottom: 8px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.login-user {
  color: var(--muted);
  font-size: .9rem;
}

.passkey-block {
  margin-bottom: 12px;
}

.btn-passkey {
  width: 100%;
  background: var(--text);
}

.passkey-or {
  text-align: center;
  margin: 0 0 10px;
}

h1 { margin: 0 0 16px; }
h2 { margin-top: 0; font-size: 1.1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}

.meta {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 10px;
  margin: 0 0 14px;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }

.date-row {
  display: grid;
  grid-template-columns: 1.35fr .8fr .8fr;
  gap: 10px;
  margin: 8px 0 14px;
}

label { display: grid; gap: 4px; font-size: 0.95rem; }

select, input[type="text"] {
  min-width: 110px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* iOS Safari auto-zoom prevention */
  line-height: 1.4;
}

input[type="password"] {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* iOS Safari auto-zoom prevention */
  line-height: 1.4;
}

.btn {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.2;
}

.btn-warn { background: var(--warning); margin-top: 6px; }

.btn-ghost {
  background: #374151;
  padding: 8px 12px;
}

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-weight: 600;
}
.alert-success { background: #ecfdf5; color: var(--ok); }
.alert-warning { background: #fff7ed; color: var(--warning); }
.alert-error { background: #fef2f2; color: var(--danger); }

.warn-note { color: var(--warning); margin-bottom: 4px; }

.diagnostics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.diagnostics li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.diagnostics li.ok span { color: var(--ok); font-weight: 600; }
.diagnostics li.ng span { color: var(--danger); font-weight: 600; }
.diagnostics small { color: var(--muted); word-break: break-all; }

pre {
  white-space: pre-wrap;
  background: #111827;
  color: #d1fae5;
  padding: 10px;
  border-radius: 8px;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .5);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 16px;
}

.modal h2 {
  margin: 0 0 10px;
}

.modal-note {
  margin: 0 0 12px;
  color: var(--muted);
}

.modal-list {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px 10px;
  margin: 0 0 14px;
}

.modal-list dt {
  color: var(--muted);
}

.modal-list dd {
  margin: 0;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== 管理画面 (PC向け) ===== */
.admin-container {
  width: min(1080px, 94vw);
}

.admin-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.admin-link:hover { text-decoration: underline; }

.hint {
  color: var(--muted);
  font-size: .9rem;
  margin: 0 0 12px;
}

.table-wrap { overflow-x: auto; margin-bottom: 18px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.admin-table th, .admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
.admin-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.col-actions { white-space: nowrap; }

.cc-cell { font-size: .82rem; color: var(--muted); }

.inline-form { display: inline-block; margin-left: 4px; }

.btn-sm {
  padding: 6px 10px;
  font-size: .85rem;
  margin-top: 0;
}

.admin-form { display: grid; gap: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
}

.admin-form textarea {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.4;
  font-family: inherit;
  resize: vertical; /* 横に広げてレイアウトが崩れるのを防止 */
  max-width: 100%;
}

.admin-form input[type="email"],
.admin-form input[type="number"] {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.4;
}

.layout-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: end;
}
.layout-group legend { font-weight: 600; padding: 0 4px; }
.layout-group label { min-width: 90px; }
.layout-group input[type="number"] { width: 100px; }
.layout-group .check {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: auto;
  padding-bottom: 8px;
}

.tag-help {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .9rem;
}
.tag-help summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}
.tag-help p { margin: 8px 0 4px; }
.tag-help table { border-collapse: collapse; margin-top: 6px; }
.tag-help th, .tag-help td {
  border: 1px solid var(--border);
  padding: 4px 10px;
  text-align: left;
  font-weight: 400;
}
.tag-help code {
  background: #eef2ff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .85rem;
}

.req {
  color: var(--danger);
  font-size: .75rem;
  font-weight: 600;
}

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

@media (max-width: 820px) {
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .meta { grid-template-columns: 1fr; }
  .diagnostics li { flex-direction: column; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .logout-form { width: 100%; justify-content: space-between; }
  .date-row { width: 100%; gap: 8px; grid-template-columns: 1.35fr .75fr .75fr; }
  .date-row label { min-width: 0; }
  .date-row select { width: 100%; min-width: 0; padding: 10px; }
  input[type="text"], input[type="password"] { width: 100%; padding: 10px; }
  #send-form .btn {
    width: 100%;
    padding: 14px 16px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 10px;
  }
  .btn-ghost { width: auto; padding: 9px 12px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .modal-list { grid-template-columns: 1fr; }
}
