body.admin {
  height: auto;
  min-height: 100vh;
  overflow: auto;
  background: var(--bg);
  display: block;
  padding-bottom: 24px;
}

.admin-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* ── ログイン ─────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
}

.login-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.login-card h1 {
  font-size: 20px;
  margin: 6px 0 8px;
}

.login-desc {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

/* ── ヘッダー ─────────────────────────────────── */
.admin-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-header h1 {
  font-size: 15px;
  margin: 2px 0 0;
  font-weight: 700;
}

.admin-header .app-kicker {
  color: #fff;
  opacity: 0.7;
  font-size: 10px;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-header .btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.server-time {
  font-size: 10.5px;
  opacity: 0.8;
}

/* ── レイアウト（スマホ1列） ─────────────────── */
.console {
  display: grid;
  gap: 12px;
  padding: 12px;
  max-width: 760px;
  margin: 0 auto;
}

@media (min-width: 1000px) {
  .console {
    grid-template-columns: 340px 1fr;
    align-items: start;
  }
}

.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
}

.card-title {
  margin: 0 0 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.02em;
}

.sub-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-row {
  display: grid;
  gap: 9px;
}

@media (min-width: 520px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

.label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea {
  font-family: inherit;
  font-size: 16px; /* iOSで拡大されない */
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  width: 100%;
  min-width: 0;
  background: #fff;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 13px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  text-align: center;
  line-height: 1.3;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--brand);
  border-color: var(--line);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-sm {
  font-size: 12px;
  min-height: 34px;
  padding: 6px 10px;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  font-family: inherit;
  font-size: 11.5px;
  color: var(--brand);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  min-height: 30px;
}

.btn-ghost-danger {
  color: var(--danger);
  border-color: #fecaca;
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.small-note {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.form-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}

.alert {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head .card-title {
  margin: 0;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.inline-form input {
  flex: 1;
  min-width: 0;
}

.inline-form .btn {
  flex: none;
}

/* ── ツリー ───────────────────────────────────── */
.tree {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.user-head {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.user-head-main {
  min-width: 0;
}

.user-name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.user-meta {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.user-meta.is-full {
  color: var(--danger);
  font-weight: 700;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  flex: none;
}

.user-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  margin: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.empty.small {
  font-size: 11.5px;
}

.event-node {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdff;
}

.event-node.is-open {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
  background: #fff;
}

.event-line {
  display: flex;
  gap: 6px;
  padding: 8px;
  align-items: flex-start;
}

.tree-mark {
  color: #9aabbe;
  font-size: 13px;
  line-height: 1.4;
  flex: none;
}

.event-main {
  min-width: 0;
  flex: 1;
}

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

.event-name {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.event-purpose {
  margin: 3px 0 0 10px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.event-time {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.url-text {
  display: block;
  margin: 6px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  word-break: break-all;
  background: var(--brand-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  color: #16202b;
  user-select: all;
}

.url-text.small {
  font-size: 11px;
}

.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.row-buttons .is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  white-space: nowrap;
}

.pill-before {
  background: #fef3c7;
  color: #92400e;
}

.pill-active {
  background: #dcfce7;
  color: #166534;
}

.pill-ended {
  background: #e2e8f0;
  color: #334155;
}

.pill-expired {
  background: #fee2e2;
  color: #991b1b;
}

/* ── URL発行フォーム ─────────────────────────── */
.issue-form {
  margin-top: 9px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.issue-form > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  padding: 3px 0;
}

.issue-form .stack {
  margin-top: 8px;
}

/* ── 詳細パネル ───────────────────────────────── */
.detail-panel {
  margin: 0 8px 10px;
  border-top: 1px solid var(--line);
  box-shadow: none;
  padding: 12px;
  background: #fff;
}

.detail-head {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-head-main {
  min-width: 0;
}

.detail-name {
  margin: 6px 0 2px;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detail-purpose {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.detail-time {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.url-box {
  margin-top: 10px;
  padding: 10px;
  background: var(--brand-soft);
  border-radius: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0;
}

.qr-wrap {
  margin-top: 12px;
  text-align: center;
}

.qr-wrap img {
  width: 170px;
  height: 170px;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.admin-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-list li {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  background: #fff;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.admin-list .item-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-list .item-meta {
  margin: 3px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.admin-list .item-meta strong {
  color: var(--brand);
  font-size: 11.5px;
}

.admin-list .item-read {
  font-weight: 700;
  color: var(--ok);
}

.admin-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 2px 16px 20px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

#detail-holder[hidden] {
  display: none;
}
