:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657281;
  --line: #d8dee8;
  --accent: #0e7c66;
  --accent-dark: #075f4d;
  --danger: #a63b32;
  --code: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(920px, calc(100vw - 32px));
  margin: 48px auto;
  display: grid;
  gap: 18px;
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
}

.view-shell {
  width: min(1280px, calc(100vw - 32px));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.06);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.compact-brand {
  margin-bottom: 0;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 24px;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

p {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.55;
}

.hint {
  margin-top: -2px;
  font-size: 14px;
}

.create-form {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 700;
  color: #273240;
}

.path-input {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.path-input span {
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: #eef2f5;
  color: #425160;
  border-right: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  font-family: inherit;
}

button,
.button-link {
  width: fit-content;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.message {
  min-height: 24px;
  margin-top: 12px;
}

.message.error {
  color: var(--danger);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #812b25;
}

.result-panel {
  display: grid;
  gap: 16px;
}

.result-panel[hidden] {
  display: none;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-action {
  min-height: 50px;
  padding: 0 24px;
  background: var(--accent);
  color: #ffffff;
  font-size: 16px;
  letter-spacing: 0;
  box-shadow: 0 10px 18px rgba(14, 124, 102, 0.18);
}

.primary-action:hover {
  background: var(--accent-dark);
  color: #ffffff;
}

.admin-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 24px;
  align-items: end;
}

.admin-key-form {
  display: grid;
  gap: 10px;
}

.admin-upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(220px, 1.1fr) minmax(220px, 1fr) auto;
  gap: 10px 14px;
  align-items: end;
}

.admin-upload-form label {
  grid-row: 1;
}

.admin-upload-form input,
.admin-upload-form button {
  grid-row: 2;
}

.upload-hint {
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: 0;
}

.upload-progress {
  display: grid;
  gap: 8px;
  min-height: 74px;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fbfcfd;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #334155;
  font-weight: 800;
}

.upload-progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.upload-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.upload-progress-detail {
  min-height: 22px;
  margin-top: 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.view-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.view-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.view-actions .search-field {
  flex: 1 1 260px;
}

.view-create-link {
  min-height: 48px;
  gap: 8px;
  white-space: nowrap;
}

.view-create-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  fill: none;
}

.search-field {
  max-width: 280px;
}

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

.preview-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.06);
}

.preview-card-admin {
  cursor: default;
}

.preview-card.is-hidden-site {
  border-style: dashed;
}

.preview-card.is-dragging {
  opacity: 0.62;
  transform: scale(0.98);
}

.preview-card.drag-over {
  outline: 3px solid rgba(14, 124, 102, 0.28);
  outline-offset: 3px;
}

.preview-media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #f2f5f8;
}

.preview-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-media-empty {
  display: grid;
  place-items: center;
}

.preview-placeholder {
  padding: 16px;
  color: var(--muted);
  font-weight: 800;
}

.preview-card-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.preview-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.preview-title-stack {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.preview-work-name {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.preview-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-badge {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #334155;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.preview-badge.is-hidden {
  border-color: #f0c36d;
  color: #7a4b00;
  background: #fff8e6;
}

.preview-badge.is-password {
  border-color: #9fb6dc;
  color: #24476f;
  background: #eef5ff;
}

.preview-drag-handle {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 900;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.preview-drag-handle:active {
  cursor: grabbing;
}

body.is-sorting .preview-card,
body.is-sorting .preview-media,
body.is-sorting .preview-title {
  user-select: none;
}

body.is-sorting .preview-media,
body.is-sorting .preview-title {
  pointer-events: none;
}

.preview-title {
  color: var(--code);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.preview-stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfcfd;
}

.preview-stat dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-stat dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.preview-card-actions {
  min-height: 36px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.preview-download {
  width: 36px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: var(--accent-dark);
  text-decoration: none;
}

.preview-download:hover {
  border-color: #8fc6b9;
  background: #e8f5f1;
  color: var(--accent);
}

.preview-download:focus-visible {
  outline: 3px solid rgba(14, 124, 102, 0.24);
  outline-offset: 2px;
}

.preview-download svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

body.is-sorting .preview-download {
  pointer-events: none;
  user-select: none;
}

.empty-view {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
  background: white;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: #f4f6f8;
  color: #334155;
  font-size: 14px;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table a {
  color: var(--code);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  word-break: break-all;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.metric-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.small-button {
  min-height: 36px;
  padding: 0 14px;
}

.inline-check {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.inline-check input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.icon-button:hover {
  border-color: #8fc6b9;
  background: #e8f5f1;
  color: var(--accent-dark);
}

.icon-button.is-active {
  border-color: #9fb6dc;
  background: #eef5ff;
  color: #24476f;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.result-head .public-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent-dark);
  word-break: break-all;
}

.result-head .button-link {
  display: inline-flex;
  margin-top: 0;
  color: #ffffff;
}

.key-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fbfcfd;
}

.advanced {
  display: grid;
  gap: 10px;
}

.advanced summary {
  cursor: pointer;
  font-weight: 800;
  color: #273240;
}

pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 8px;
  background: var(--code);
  color: #d6e2f0;
  font-size: 13px;
  line-height: 1.5;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 920px);
    margin: 18px auto;
  }

  .panel {
    padding: 18px;
  }

  .brand-row,
  .result-head,
  .view-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-head,
  .admin-key-row,
  .admin-upload-form {
    grid-template-columns: 1fr;
  }

  .admin-upload-form label,
  .admin-upload-form input,
  .admin-upload-form button,
  .upload-hint {
    grid-row: auto;
  }

  .view-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search-field {
    max-width: none;
  }

  .upload-progress-head {
    flex-direction: column;
    gap: 4px;
  }

  h1 {
    font-size: 24px;
  }

  button,
  .button-link {
    width: 100%;
  }

  .admin-table .icon-button {
    width: 36px;
  }
}
