:root {
  color-scheme: dark;
  font: 18px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111318;
  color: #f3f4f6;
  --surface: #1b1d24;
  --surface-raised: #242730;
  --border: #393d47;
  --muted: #b6bbc6;
  --accent: #9fc5ff;
  --button: #315783;
}
* { box-sizing: border-box; }
body { max-width: 920px; margin: 0 auto; padding: 20px; }
#feed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
button, input, textarea { font: inherit; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-raised); color: inherit; padding: 12px 14px; }
button { background: var(--button); border-color: transparent; cursor: pointer; min-height: 42px; padding: 9px 12px; font-size: .95em; }
button:disabled { opacity: .48; cursor: not-allowed; }
a { color: var(--accent); }
article, .panel { background: var(--surface); border: 1px solid #262932; border-radius: 18px; padding: 16px; margin: 14px 0; }
.media-card { min-width: 0; margin: 0; overflow: hidden; }
article h2 { font-size: 1.1rem; overflow-wrap: anywhere; margin: 0 0 6px; }
small { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
img, video { display: block; max-width: 100%; border-radius: 12px; }
.media-output video { width: 100%; max-height: 72vh; object-fit: contain; background: #090a0d; }
.photo-preview, .video-preview { display: block; position: relative; width: min(100%, 280px); margin: 10px auto; }
.photo-preview img, .video-preview img { width: 100%; height: clamp(120px, 24vw, 250px); object-fit: contain; background: #090a0d; }
.video-preview { min-height: 0; padding: 0; border: 0; overflow: hidden; background: #090a0d; }
.video-preview span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 48px; height: 48px; padding-left: 4px; border-radius: 50%; background: #111b; font-size: 1.4rem; }
.lightbox { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border: 0; background: #08090df5; color: #f7f8fa; }
.lightbox::backdrop { background: #050609ed; }
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox-close { align-self: flex-end; width: 48px; min-width: 48px; padding: 0; border-radius: 50%; font-size: 2rem; line-height: 1; background: #292d36; }
.lightbox-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center; gap: 8px; }
.lightbox-content { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox-media-frame { position: relative; display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: calc(100dvh - 100px); }
.lightbox-media-frame[hidden] { display: none; }
.lightbox-image, .lightbox-video { max-width: 100%; max-height: calc(100dvh - 100px); width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lightbox-image { cursor: default; }
.lightbox-video { touch-action: pan-y; }
.lightbox-tap-zones { position: absolute; inset: 0; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lightbox-tap-zones button { display: grid; place-items: center; min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; color: #fff; font-size: 2.4rem; opacity: .78; }
.lightbox-tap-zones button span { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border: 1px solid #fff8; border-radius: 50%; background: #0007; text-shadow: 0 1px 8px #000; }
.lightbox-tap-zones button:hover, .lightbox-tap-zones button:focus-visible { background: #0002; opacity: 1; }
.lightbox-tap-zones button:nth-child(2) span { font-size: 1.8rem; }
.lightbox-counter { color: #d0d3da; padding: 8px; text-align: center; }
.lightbox-arrow { width: 52px; min-width: 52px; height: 60px; padding: 0; border-radius: 16px; font-size: 2.3rem; line-height: 1; background: #292d36; }
.lightbox-arrow[hidden] { display: block; visibility: hidden; }
.lightbox-arrow:hover, .lightbox-close:hover { background: #3a414e; }
body:has(.lightbox[open]) { overflow: hidden; }
@media (max-width: 600px) {
  .photo-preview, .video-preview { width: 100%; }
  .photo-preview img, .video-preview img { height: clamp(120px, 36vw, 190px); }
  .lightbox-layout { grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 4px; }
  .lightbox-arrow { width: 42px; min-width: 42px; height: 52px; border-radius: 12px; }
}
.upload-panel { padding: 0; overflow: hidden; }
.file-picker { min-height: 180px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; border: 2px dashed #525b6b; border-radius: 18px; background: linear-gradient(145deg, #20242d, #191b21); cursor: pointer; }
.file-picker:hover, .file-picker:focus-within, .file-picker.dragging { border-color: var(--accent); background: #242b37; }
.file-picker-icon { width: 48px; height: 48px; color: var(--accent); }
.file-picker-title { font-size: 1.15rem; font-weight: 650; }
.file-picker-hint { color: var(--muted); }
.file-picker-action { margin-top: 8px; padding: 10px 22px; border-radius: 999px; background: #315783; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0, 0, 0, 0); }
.file-input:focus-visible + .file-picker { outline: 3px solid var(--accent); outline-offset: 3px; }
.file-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.file-list:empty { display: none; }
.file-item { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #15171c; }
.file-preview { width: 100%; height: 120px; display: grid; place-items: center; object-fit: cover; color: var(--accent); background: #222630; font-size: 2rem; }
.file-name { display: block; padding: 8px; font-size: .85rem; overflow-wrap: anywhere; }
.upload-submit { width: 100%; margin-top: 12px; font-weight: 650; }
.media-detail-actions { display: none; }
.lightbox-actions { flex: 0 0 auto; max-height: 30vh; overflow: auto; }
.lightbox-detail-actions { display: block; }
.media-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; margin: 12px 0; }
.media-delete { grid-column: 1; justify-self: start; min-width: 0; margin: 0; }
.media-delete button { max-width: 100%; white-space: normal; }
.media-actions .comment-add-button { grid-column: 2; justify-self: center; width: auto; max-width: 100%; white-space: normal; }
.comment-list { list-style: none; margin: 12px 0; padding: 0; }
.preview-comment-list .comment-item { display: block; margin: 4px 0; padding: 8px; font-size: .86em; }
.preview-comment-list .comment-item p { margin: 2px 0 0; }
.comment-item { display: flex; align-items: flex-start; gap: 12px; margin: 10px 0; padding: 12px; border-radius: 12px; background: #15171c; }
.comment-item + .comment-item { border-top: 1px solid var(--border); }
.comment-content { flex: 1; min-width: 0; }
.comment-item p { margin: 4px 0 10px; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-actions { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 44%; }
.comment-actions .comment-toggle, .comment-delete button { width: auto; max-width: 100%; white-space: normal; }
.comment-delete { margin: 0; }
.comment-form { margin: 8px 0; }
.comment-actions .comment-form { width: min(65vw, 360px); }
.comment-form textarea { display: block; width: 100%; min-height: 88px; resize: vertical; }
.comment-add { text-align: center; }
.comment-add button { width: auto; }
.action-status:not([hidden]) { position: fixed; z-index: 10; right: 16px; bottom: 16px; margin: 0; padding: 10px 14px; border-radius: 12px; background: #252a34; box-shadow: 0 4px 18px #0008; }
form label { display: block; margin: 8px 0 4px; }
form input:not([type=hidden]):not([type=checkbox]):not([type=file]) { max-width: 100%; }
@media (max-width: 600px) {
  body { padding: 12px; }
  button, input:not([type=hidden]):not([type=checkbox]):not([type=file]), textarea { width: 100%; }
  .file-picker { min-height: 160px; padding: 18px; }
  .file-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-actions { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 4px; }
  .media-delete button, .media-actions .comment-add-button { padding: 8px; font-size: .85em; }
}
