:root {
  color-scheme: light dark;
  --background: #f7f7f5;
  --surface: #ffffff;
  --text: #171717;
  --muted: #77746f;
  --line: #e5e3df;
  --accent: #34322f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--background);
  font-family: "Pretendard", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.list-shell, .detail-shell {
  width: min(100% - 32px, 900px);
  margin: 0 auto;
  padding: 36px 0 72px;
}

.list-header {
  display: flex;
  justify-content: flex-end;
  min-height: 32px;
  margin-bottom: 10px;
}

.owner-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.owner-link:hover { color: var(--text); border-color: var(--muted); }

.story-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.story-table th {
  padding: 13px 14px;
  color: var(--muted);
  border-top: 2px solid var(--text);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}

.story-table th:first-child,
.story-table td:first-child {
  width: 124px;
  font-variant-numeric: tabular-nums;
}

.story-table th:last-child,
.story-table td:last-child {
  width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.story-table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.45;
}

.story-table td:first-child {
  color: var(--muted);
  font-size: 13px;
}

.story-table td.view-count {
  color: var(--muted);
  font-size: 13px;
}

.story-table a {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.story-table a:hover { text-decoration: underline; text-underline-offset: 4px; }

.empty-row { color: var(--muted); }

.detail-shell { max-width: 720px; }

.back-link {
  display: inline-block;
  margin-bottom: 38px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }

.detail-meta {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.detail-meta strong { color: inherit; font-weight: 650; }

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(27px, 5vw, 42px);
  font-weight: 750;
  letter-spacing: -0.045em;
  line-height: 1.28;
}

.detail-content {
  margin: 32px 0 0;
  color: var(--accent);
  font-size: 17px;
  line-height: 1.95;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-media {
  margin: 22px 0 0;
}

.detail-image-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  cursor: zoom-in;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  text-align: left;
}

.detail-image-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--text) 45%, transparent);
  outline-offset: 3px;
}

.detail-image-button img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  transition: transform 180ms ease;
}

.detail-image-button:hover img { transform: scale(1.012); }

.detail-image-hint {
  position: absolute;
  margin: -42px 0 0 12px;
  padding: 6px 9px;
  color: #fff;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.63);
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  transform: translateY(4px);
  transition: 150ms ease;
}

.detail-image-button:hover .detail-image-hint,
.detail-image-button:focus-visible .detail-image-hint { opacity: 1; transform: translateY(0); }

.image-lightbox {
  width: min(100% - 24px, 1440px);
  max-width: none;
  max-height: min(100% - 24px, 1000px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: #fff;
  border: 0;
  border-radius: 10px;
  background: #111;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.55);
}

.image-lightbox::backdrop { background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(3px); }

.image-lightbox-content { position: relative; display: grid; max-height: min(100vh - 24px, 1000px); }

.image-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: min(100vh - 24px, 1000px);
  margin: auto;
  object-fit: contain;
}

.image-lightbox-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.image-lightbox a,
.image-lightbox button {
  display: inline-grid;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0 10px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.54);
  font: inherit;
  font-size: 12px;
  text-decoration: none;
}

.image-lightbox button { font-size: 20px; line-height: 1; }
.image-lightbox a:hover, .image-lightbox button:hover { background: rgba(0, 0, 0, 0.82); }

@media (max-width: 520px) {
  .list-shell, .detail-shell {
    width: min(100% - 24px, 680px);
    padding-top: 22px;
  }

  .story-table th:first-child,
  .story-table td:first-child { width: 88px; }
  .story-table th:last-child,
  .story-table td:last-child { width: 56px; }
  .story-table th, .story-table td { padding: 14px 8px; }
  .story-table td { font-size: 15px; }
  .story-table td:first-child { font-size: 12px; }
  .back-link { margin-bottom: 28px; }
  .detail-content { margin-top: 25px; font-size: 16px; line-height: 1.9; }
  .detail-media { margin-top: 16px; }
  .image-lightbox { width: calc(100% - 16px); max-height: calc(100% - 16px); }
  .image-lightbox-image { max-height: calc(100vh - 16px); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111111;
    --surface: #171717;
    --text: #f4f3f1;
    --muted: #9b9893;
    --line: #30302e;
    --accent: #ddd9d3;
  }
}
