@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  --bg-0: #f5f1e7;
  --bg-1: #ece2d0;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --ink: #1e1d1a;
  --ink-soft: #5f5b52;
  --accent: #d94f33;
  --accent-2: #2a7f62;
  --line: rgba(36, 33, 27, 0.12);
  --danger: #b93a3a;
  --shadow: 0 18px 50px rgba(37, 35, 32, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #fff6d8 0%, transparent 35%),
    radial-gradient(circle at 90% 5%, #ffd5cc 0%, transparent 32%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1));
}

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
}

.action-btn,
.text-btn {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-weight: 600;
}

.action-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(36, 33, 27, 0.14);
}

.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.viewer-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.viewer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.viewer-hero {
  position: relative;
  width: 100%;
  min-height: 300px;
  max-height: 72vh;
  background: linear-gradient(160deg, #f8ead8, #fdfaf2);
  display: flex;
  justify-content: center;
  align-items: center;
}

.viewer-hero img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  cursor: zoom-in;
}

.viewer-hero .placeholder {
  color: var(--ink-soft);
  font-size: 15px;
}

.viewer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.inline-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.72);
}

.switch-row input {
  width: 16px;
  height: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  font-weight: 700;
}

.panel-content {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
  animation: reveal 0.2s ease;
}

.panel.collapsed .panel-content {
  display: none;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.kv-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
}

.kv-item .k {
  font-size: 12px;
  color: var(--ink-soft);
}

.kv-item .v {
  margin-top: 4px;
  font-weight: 600;
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid rgba(42, 127, 98, 0.25);
  background: rgba(42, 127, 98, 0.1);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  background: var(--surface-strong);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-family: "Space Grotesk", sans-serif;
}

.input,
.search-input,
.password-input,
.datetime-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 22;
  background: rgba(8, 8, 8, 0.86);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  background: #1f1e1b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-3px);
}

.admin-layout {
  display: grid;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.card h3 {
  margin-top: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.7);
}

.stat .label {
  color: var(--ink-soft);
  font-size: 12px;
}

.stat .value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.small-btn {
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.hidden {
  display: none;
}

.warn {
  color: var(--danger);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .brand {
    font-size: 20px;
  }

  .viewer-hero {
    min-height: 240px;
    max-height: 62vh;
  }

  .viewer-hero img {
    max-height: 62vh;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .switch-row {
    width: 100%;
    justify-content: space-between;
  }
}
