:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #2f3437;
  --muted: #787774;
  --border: #eaeaea;
  --accent: #111111;
  --accent-hover: #333333;
  --smurf-blue: #3daee9;
  --radius: 10px;
  --font: "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --serif: "Newsreader", "Georgia", serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.brand {
  font-family: var(--serif);
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.nav-user {
  color: var(--muted);
}

.nav-link {
  color: var(--text);
  text-decoration: none;
}

.admin-menu {
  position: relative;
}

.admin-menu summary {
  list-style: none;
  cursor: pointer;
  font-weight: 500;
}

.admin-menu summary::-webkit-details-marker {
  display: none;
}

.admin-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.admin-menu-panel a {
  padding: 0.5rem 0.625rem;
  text-decoration: none;
  color: var(--text);
  border-radius: 6px;
}

.admin-menu-panel a:hover {
  background: var(--bg);
}

.site-main {
  flex: 1;
  padding: 1.25rem 0 2rem;
}

.site-footer {
  padding: 1rem 0 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.page-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0.25rem 0 0.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.6875rem;
  color: var(--muted);
  margin: 0;
}

.lede {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 36ch;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.auth-card {
  margin-top: 2rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.auth-card h1 {
  font-family: var(--serif);
  font-size: 1.75rem;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.auth-card--login {
  text-align: center;
}

.auth-card--login .stack-form {
  text-align: left;
  margin-top: 1.5rem;
}

.login-mascot--dulifuli {
  margin: 0 auto 0.75rem;
  line-height: 0;
}

.dulifuli-img {
  width: 4.75rem;
  height: auto;
  max-width: 32vw;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.dulifuli-rant {
  margin: 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--smurf-blue);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.auth-card--login .dulifuli-rant:first-of-type {
  margin-top: 0.35rem;
  margin-bottom: 0.65rem;
}

.login-form {
  margin-top: 0.25rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h2 {
  font-size: 1rem;
  margin: 0 0 1rem;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-form label span {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}

.activity-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.activity-filter-form .filter-field {
  flex: 1 1 10rem;
  min-width: 8rem;
}

.activity-filter-form .filter-field span {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.activity-filter-form .filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.panel-warn {
  border-color: #e8c4a8;
  background: #fff9f3;
}

.notice-warn {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: #7a4a12;
}

.check-list,
.steps-list {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.5;
}

.check-list li,
.steps-list li {
  margin-bottom: 0.5rem;
}

.muted-small {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.inline-form input[type="text"] {
  flex: 1;
  min-width: 12rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
}

.form-error {
  background: #fdebec;
  color: #9f2f2d;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.form-success {
  background: #edf3ec;
  color: #346538;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.folder-grid {
  display: grid;
  gap: 0.75rem;
}

.folder-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s var(--ease);
}

.folder-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.folder-card-title {
  font-weight: 600;
}

.folder-card-meta {
  font-size: 0.8125rem;
  color: var(--muted);
}

.upload-zone {
  margin-bottom: 1.25rem;
}

.upload-trigger {
  display: block;
  padding: 1.5rem;
  border: 1px dashed color-mix(in srgb, var(--muted) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
}

.upload-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.upload-hint {
  font-size: 0.8125rem;
  color: var(--muted);
}

.upload-zone.is-uploading .upload-trigger {
  opacity: 0.55;
  pointer-events: none;
}

.upload-progress {
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.upload-progress-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.upload-pct {
  flex: 0 0 3rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.upload-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.upload-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--accent);
  transition: width 0.15s linear;
}

.upload-status {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.upload-detail {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}

.media-filter {
  margin-bottom: 1rem;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-tab {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.filter-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-tab.is-active .filter-count {
  color: rgba(255, 255, 255, 0.85);
}

.filter-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-count {
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.15rem;
}

.media-card.is-filtered-out {
  display: none;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.media-thumb {
  display: block;
  aspect-ratio: 1;
  background: #f0efec;
  position: relative;
  overflow: hidden;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-video-placeholder {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.95) 0 18%, transparent 19%),
    linear-gradient(145deg, #3a3a3a, #1a1a1a);
}

.media-video-placeholder::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-35%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #111;
}

.badge-video {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(17, 17, 17, 0.75);
  color: #fff;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
}

.media-meta {
  padding: 0.625rem 0.75rem 0.75rem;
}

.media-name {
  margin: 0;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-sub {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.media-uploader {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.media-delete-form {
  margin: 0;
}

.btn-danger {
  color: #9f2f2d;
  border-color: #fdebec;
}

.btn-danger:hover {
  background: #fdebec;
}

.tag {
  display: inline-block;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #f0efec;
}

.tag-green {
  background: #edf3ec;
  color: #346538;
}

.tag-blue {
  background: #e1f3fe;
  color: #1f6c9f;
}

.tag-red {
  background: #fdebec;
  color: #9f2f2d;
}

.empty-state {
  color: var(--muted);
  grid-column: 1 / -1;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.user-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.user-row:last-child {
  border-bottom: none;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.activity-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.activity-table th,
.activity-table td {
  text-align: left;
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.activity-table code {
  font-family: var(--mono);
  font-size: 0.75rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 17, 17, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}

.lightbox.is-open {
  display: flex;
  pointer-events: auto;
}

.lightbox-body img,
.lightbox-body video {
  max-width: 100%;
  max-height: 90dvh;
  border-radius: 6px;
}

.lightbox-close {
  position: absolute;
  z-index: 2;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  width: 3rem;
  height: 3rem;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

body.lightbox-open {
  overflow: hidden;
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: reveal 0.6s var(--ease) forwards;
  animation-delay: calc(var(--index, 0) * 80ms);
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 768px) {
  .app-shell {
    max-width: 960px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .user-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
