:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --bg-2: #e8f0ee;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(30, 41, 59, 0.12);
  --text: #1d2433;
  --muted: #5e697c;
  --brand: #214d63;
  --brand-2: #9a5d2f;
  --accent: #1f7a6b;
  --danger: #b23b4c;
  --shadow: 0 24px 60px rgba(17, 24, 39, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(154, 93, 47, 0.14), transparent 35%),
    radial-gradient(circle at top right, rgba(33, 77, 99, 0.18), transparent 28%),
    linear-gradient(160deg, var(--bg) 0%, #f7f8fb 48%, var(--bg-2) 100%);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  gap: 4px;
}

.brand h1,
.brand h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
}

.brand small {
  color: var(--muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.tag,
.button,
button,
input[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.button,
button,
input[type="submit"] {
  background: linear-gradient(135deg, var(--brand), #134356);
  color: #fff;
  box-shadow: 0 12px 24px rgba(33, 77, 99, 0.24);
}

.button.secondary,
.tag.secondary {
  background: rgba(33, 77, 99, 0.08);
  color: var(--brand);
  box-shadow: none;
}

.button.danger {
  background: linear-gradient(135deg, var(--danger), #842636);
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  transform: translateY(-1px);
}

.button:active,
button:active,
input[type="submit"]:active {
  transform: translateY(0);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--card);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.flash.success {
  border-color: rgba(31, 122, 107, 0.28);
}

.flash.error {
  border-color: rgba(178, 59, 76, 0.28);
}

.dashboard-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.dashboard-nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--brand);
  font-weight: 700;
}

.grid-2 {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 1.6fr;
  margin-top: 18px;
}

.card {
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.card.pad {
  padding: 20px;
}

.hero {
  padding: 26px;
  display: grid;
  gap: 14px;
}

.hero h3,
.section-title {
  margin: 0;
  font-size: 1.05rem;
}

.meta,
.muted {
  color: var(--muted);
}

.viewer {
  padding: 16px;
  min-height: 72vh;
}

.viewer iframe {
  width: 100%;
  height: 78vh;
  border: 0;
  border-radius: 18px;
  background: #fff;
}

.intro-video {
  display: block;
  width: 100%;
  max-height: 78vh;
  margin-bottom: 16px;
  border-radius: 18px;
  background: #111;
}

.archive-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}

.archive-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(30, 41, 59, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.archive-item.active {
  border-color: rgba(33, 77, 99, 0.28);
  background: rgba(33, 77, 99, 0.08);
}

.archive-count-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.archive-count-edit input[type="number"] {
  width: 88px;
  padding: 9px 10px;
}

.magazine-edit-table {
  table-layout: fixed;
  font-size: 0.84rem;
}

.magazine-edit-table th,
.magazine-edit-table td {
  padding: 8px 6px;
}

.magazine-edit-table th:nth-child(1) {
  width: 4%;
}

.magazine-edit-table th:nth-child(2) {
  width: 27%;
}

.magazine-edit-table th:nth-child(3),
.magazine-edit-table th:nth-child(4) {
  width: 11%;
}

.magazine-edit-table th:nth-child(5) {
  width: 10%;
}

.magazine-edit-table th:nth-child(6) {
  width: 10%;
}

.magazine-edit-table th:nth-child(7) {
  width: 27%;
}

.magazine-edit-issue-name {
  overflow: hidden;
}

.magazine-edit-issue-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.magazine-edit-filename {
  display: block;
  overflow: hidden;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.magazine-edit-table .tag {
  padding: 5px 8px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.magazine-edit-count .archive-count-edit {
  gap: 4px;
}

.magazine-edit-count .archive-count-edit input[type="number"] {
  width: 62px;
  min-width: 0;
  padding: 6px 5px;
  font-size: 0.8rem;
}

.magazine-edit-count .archive-count-edit button,
.magazine-edit-actions .nav-actions button,
.magazine-edit-actions .nav-actions .button {
  padding: 6px 7px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.magazine-edit-actions .nav-actions {
  flex-wrap: nowrap;
  gap: 4px;
}

.magazine-edit-actions .nav-actions form {
  flex: 0 0 auto;
}

.issue-date-filter {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.issue-date-filter label {
  min-width: 190px;
}

.archive-count-edit :disabled,
.archive-clear-form button:disabled {
  opacity: 0.45;
  filter: grayscale(1);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-progress {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(33, 77, 99, 0.18);
  border-radius: 14px;
  background: rgba(33, 77, 99, 0.05);
}

.upload-progress-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.upload-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

.archive-item strong,
.issue-title {
  display: block;
}

.two-col {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.editor-preview-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
}

.editor-photo-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(30, 41, 59, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
}

.editor-photo-preview {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: #f0ece7;
}

.editor-photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.customer-auth-fields,
.customer-options {
  display: grid;
  gap: 14px;
}

.customer-auth-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
}

.login-history-filter-section {
  padding: 14px 16px;
}

.login-history-summary h2,
.login-history-summary p {
  margin-top: 6px;
  margin-bottom: 6px;
}

.login-history-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.login-history-system-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.login-history-system-status div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
  padding: 10px 12px;
  border: 1px solid rgba(30, 41, 59, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.login-history-system-status strong {
  font-size: 1.05rem;
}

.login-history-filter {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 10px;
}

.login-history-filter label {
  gap: 5px;
}

.login-history-filter input[type="date"],
.login-history-filter select {
  min-height: 42px;
  padding: 9px 12px;
}

.login-history-filter input[type="submit"] {
  white-space: nowrap;
  padding: 10px 14px;
}

.login-history-submit {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(30, 41, 59, 0.15);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

textarea {
  min-height: 110px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.version-history-scroll {
  max-height: 560px;
  overflow-y: auto;
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(30, 41, 59, 0.08);
  vertical-align: top;
}

.admin-user-name {
  width: 16em;
  min-width: 16em;
  white-space: nowrap;
}

.admin-user-totp {
  width: 6%;
  max-width: 6%;
}

.admin-user-link {
  width: 16%;
  max-width: 16%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.admin-user-actions {
  white-space: nowrap;
}

.qr-box {
  width: 160px;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(30, 41, 59, 0.1);
}

.qr-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-grid {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(1080px, 100%);
  padding: 18px;
}

.login-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.login-hero {
  padding: 30px;
  background: linear-gradient(160deg, rgba(33, 77, 99, 0.12), rgba(154, 93, 47, 0.08));
}

.login-form {
  padding: 30px;
}

.stack {
  display: grid;
  gap: 14px;
}

.stack form {
  margin: 0;
}

.setup-message {
  white-space: pre-line;
}

.footer-note {
  padding: 12px 4px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 1000px) {
  .grid-2,
  .two-col,
  .login-split,
  .editor-preview-layout {
    grid-template-columns: 1fr;
  }

  .viewer iframe {
    height: 88vh;
  }

  .intro-video {
    max-height: 88vh;
  }

  .login-history-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 100%);
  }

  .topbar,
  .hero,
  .pad,
  .login-hero,
  .login-form {
    padding: 16px;
  }

  .login-history-filter-section {
    padding: 12px;
  }

  .login-history-filter {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .customer-auth-fields,
  .customer-options,
  .editor-photo-row {
    grid-template-columns: 1fr;
  }

  .login-history-system-status {
    grid-template-columns: 1fr;
  }
}
