:root {
  --paper: #f6ead3;
  --card: #fffdf6;
  --ink: #4c3524;
  --ink-soft: #7d6248;
  --grid-line: rgba(146, 106, 66, 0.13);
  --red: #d9502e;
  --orange: #ee8f3a;
  --sage: #6a8352;
  --border: rgba(146, 106, 66, 0.35);
  --shadow: rgba(101, 66, 32, 0.16);
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 26px 26px;
}

.admin-page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  filter: drop-shadow(1px 2px 3px rgba(101, 66, 32, 0.22));
}

.brand-logo .logo-bg {
  fill: var(--red);
}

.brand-logo .logo-frame {
  fill: none;
  stroke: #fff7e8;
  stroke-opacity: 0.36;
  stroke-width: 1.2;
}

.brand-logo .logo-mark {
  fill: #fff7e8;
}

.brand-title {
  display: block;
  font-size: 20px;
}

.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
}

.admin-head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.paper-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 22px;
  box-shadow: 3px 6px 18px var(--shadow);
  margin-bottom: 20px;
}

.muted {
  color: var(--ink-soft);
  font-size: 13.5px;
}

.btn-primary,
.btn-outline,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 6px 16px;
  border-radius: 8px 4px 9px 4px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.btn-primary {
  background: var(--red);
  color: #fff8ee;
  border: none;
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
}

.btn-danger {
  background: transparent;
  color: #b42b17;
  border: 1.5px solid #b42b17;
}

.btn-primary:hover,
.btn-outline:hover,
.btn-danger:hover {
  transform: translateY(-1px);
}

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

.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 40px;
}

.login-card {
  max-width: 420px;
  width: 100%;
}

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

.tab-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab-btn {
  padding: 8px 18px;
  border: 2px solid var(--ink);
  border-radius: 12px 4px 12px 4px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background: var(--ink);
  color: var(--card);
}

.badge {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 999px;
}

.global-toast {
  min-height: 24px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
}

.global-toast.ok {
  color: var(--sage);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title-row h2,
.card-title-row h3 {
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--orange);
  border-radius: 8px;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  background: #fff9ec;
  cursor: pointer;
}

.drop-zone.dragover {
  background: #fbeed2;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  object-fit: contain;
}

.form-cols {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: #fffdf8;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}

.field-full {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.form-submit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-msg {
  font-size: 13.5px;
  color: var(--red);
}

.cat-bar h3 {
  margin: 0 0 10px;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: #fff9ee;
}

.cat-del-btn {
  border: none;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
  padding: 0 3px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form input {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: #fffdf8;
  font-family: inherit;
}

.photo-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.photo-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 12px;
  box-shadow: 2px 4px 12px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-item img {
  width: 100%;
  height: 185px;
  object-fit: cover;
  border-radius: 3px;
  background: #eee1c8;
}

.photo-item-title {
  font-weight: 700;
  font-size: 16px;
}

.photo-item-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.photo-item-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.mini-tag {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f3e4c7;
  color: #5f442d;
}

.mini-tag.accent {
  background: #f9d8cf;
  color: #9e2d18;
}

.photo-item-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 6px;
}

.journal-admin-list,
.msg-list {
  display: grid;
  gap: 14px;
}

.journal-row,
.msg-row {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 14px 16px;
  background: #fffaf0;
}

.msg-row.unread {
  border-left: 4px solid var(--red);
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(46, 30, 16, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  max-width: 680px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  margin-bottom: 0;
}

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