:root {
  --bg: #f3efe6;
  --paper: #fffdf8;
  --ink: #1c1915;
  --muted: #6f675c;
  --line: #ddd4c6;
  --accent: #9a3b18;
  --line-green: #06c755;
  --shadow: 0 18px 50px rgba(40, 28, 16, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
}

body.admin-body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

h1,
h2,
strong {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
}

body.admin-body h1,
body.admin-body h2,
body.admin-body strong {
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: 0.02em;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.page {
  min-height: 100dvh;
}

.page-gate {
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at top, rgba(154, 59, 24, 0.08), transparent 42%),
    var(--bg);
}

.gate-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.panel {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.site-brand {
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.95rem;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
}

.stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.switch span {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.btn {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  color: #8a1f12;
  border-color: #e3c1b8;
}

.error {
  margin: 0;
  color: #8a1f12;
}

.hint {
  margin: 0;
  color: #2f6b3a;
}

.line-block {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #cfeedd;
  border-radius: 14px;
  background: #f3fbf6;
  color: inherit;
  text-decoration: none;
}

.line-block strong {
  display: block;
  font-family: inherit;
}

.line-block small {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px);
  background: rgba(243, 239, 230, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar .site-brand {
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.board-main,
.admin-main {
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #efe8dc;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.clickable {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(20, 16, 12, 0.82);
  padding: 24px;
}

.lightbox[hidden],
.page[hidden],
#admin-page[hidden],
#login-page[hidden] {
  display: none !important;
}

.lightbox img {
  max-width: min(920px, 100%);
  max-height: min(86dvh, 100%);
  border-radius: 12px;
  background: #111;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.admin-main {
  display: grid;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
}

.panel {
  width: 100%;
}

.panel-head,
.row-inline {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.grow {
  flex: 1;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.switch input {
  width: 18px;
  min-height: 18px;
}

.rows {
  display: grid;
  gap: 12px;
}

.col-edit {
  display: grid;
  grid-template-columns: 1fr 72px 72px;
  gap: 10px;
  align-items: end;
}

input[type="color"] {
  padding: 4px;
  min-height: 46px;
  cursor: pointer;
}

.cell-input {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.cell-input:focus {
  outline: none;
  box-shadow: inset 0 -1px 0 currentColor;
}

.data-table .td-actions {
  white-space: nowrap;
}

.admin-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-head .btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

@media (max-width: 720px) {
  .data-table {
    min-width: 0;
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    padding: 8px 0 14px;
    border-bottom: 1px solid var(--line);
  }

  .data-table tr:last-child {
    border-bottom: 0;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    border: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    flex: 0 0 30%;
  }

  .data-table td .cell-input {
    flex: 1;
    text-align: right;
  }

  .data-table td.td-actions {
    flex-direction: column;
    align-items: stretch;
    white-space: normal;
  }

  .data-table td.td-actions::before {
    flex: none;
  }

  .topbar-actions .btn {
    min-height: 40px;
    padding: 0 10px;
  }

  .row-inline,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .col-edit {
    grid-template-columns: 1fr 72px 72px;
  }
}
