* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --brand-red: #e60023;
  --brand-red-hover: #cc001f;
  --text-primary: #211922;
  --text-secondary: #62625b;
  --text-disabled: #91918c;
  --bg: #ffffff;
  --surface-sand: #e5e5e0;
  --surface-warm: #e0e0d9;
  --surface-fog: #f6f6f3;
  --surface-dark: #33332e;
  --border: #91918c;
  --border-light: #c8c8c1;
  --border-hover: #bcbcb3;
  --focus-blue: #435ee5;
  --error-red: #9e0a0a;
  --warm-wash: hsla(60, 20%, 98%, 0.5);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-xxl: 32px;
  --radius-hero: 40px;
}

body {
  font-family: 'Pin Sans', -apple-system, system-ui, 'Segoe UI', Roboto, Oxygen-Sans, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Helvetica, 'ヒラギノ角ゴ Pro W3', 'メイリオ', Meiryo, 'ＭＳ Ｐゴシック', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.4;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== Header / Navigation ========== */
.site-header {
  background: var(--bg);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-red);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.site-header .logo svg {
  flex-shrink: 0;
}

.site-header .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header .user-info .username {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.site-header .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
  line-height: normal;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-blue);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand-red);
  color: #000000;
}

.btn-primary:hover {
  background: var(--brand-red-hover);
}

.btn-secondary {
  background: var(--surface-sand);
  color: #000000;
}

.btn-secondary:hover {
  background: var(--border-hover);
}

.btn-circle {
  background: var(--surface-warm);
  color: var(--text-primary);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-circle:hover {
  background: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: #000000;
  border: none;
}

.btn-ghost:hover {
  background: var(--surface-fog);
}

.btn-danger {
  background: var(--brand-red);
  color: #000000;
}

.btn-danger:hover {
  background: var(--brand-red-hover);
}

/* ========== Main Content ========== */
main {
  flex: 1;
  padding: 12px 16px 32px;
  max-width: 1680px;
  margin: 0 auto;
  width: 100%;
}

/* ========== Login Page ========== */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  gap: 16px;
  text-align: center;
}

.login-logo svg {
  width: 48px;
  height: 48px;
}

.login-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1.2px;
  color: var(--text-primary);
}

.login-page p {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 320px;
}

.btn-github {
  background: var(--surface-dark);
  color: #ffffff;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  gap: 8px;
  margin-top: 8px;
}

.btn-github:hover {
  opacity: 0.9;
}

.login-page .guest-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  margin-top: 4px;
}

.login-page .guest-link:hover {
  color: var(--text-primary);
}

.login-page .guest-link.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.btn-icon {
  background: transparent;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--surface-sand);
}

.guest-tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-sand);
  border-radius: 10px;
  vertical-align: middle;
}

/* ========== Masonry Video Grid ========== */
.masonry-grid {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.masonry-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pin-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.pin-card:hover .pin-overlay {
  opacity: 1;
}

.pin-card .pin-image {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  background: var(--surface-sand);
  min-height: 120px;
}

.pin-card .pin-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-md);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 12px;
}

.pin-card .pin-info {
  padding: 6px 0 2px;
}

.pin-card .pin-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-card .pin-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.pin-card .pin-meta img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.pin-card .pin-meta .file-size {
  margin-left: auto;
  color: var(--text-disabled);
}

/* Save button on hover */
.pin-card .pin-save-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--brand-red);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.pin-card:hover .pin-save-btn {
  opacity: 1;
}

.pin-card .pin-save-btn:hover {
  background: var(--brand-red-hover);
}

/* Duration badge on thumbnail */
.pin-card .pin-duration {
  position: absolute;
  bottom: 52px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ========== Video Player Page ========== */
.video-page {
  max-width: 900px;
  margin: 0 auto;
}

.video-player-wrapper {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.video-player-wrapper video {
  width: 100%;
  height: 100%;
}

.video-info {
  margin-bottom: 16px;
}

.video-info h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1.2px;
  margin-bottom: 10px;
}

.video-info .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.video-info .meta .uploader {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text-primary);
}

.video-info .meta .uploader img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.video-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.video-description {
  margin-top: 20px;
  padding: 20px;
  background: var(--surface-fog);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== Upload Page ========== */
.upload-page {
  max-width: 560px;
  margin: 0 auto;
}

.upload-page h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1.2px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-primary);
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--focus-blue);
  box-shadow: 0 0 0 2px rgba(67, 94, 229, 0.2);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.file-input-wrapper {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface-fog);
}

.file-input-wrapper:hover {
  border-color: var(--text-disabled);
  background: var(--surface-sand);
}

.file-input-wrapper input[type="file"] {
  display: none;
}

.file-input-wrapper .upload-icon {
  margin-bottom: 12px;
}

.file-input-wrapper .placeholder {
  color: var(--text-secondary);
  font-size: 14px;
}

.file-input-wrapper .selected-file {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 14px;
}

/* Thumbnail Preview */
.thumbnail-preview {
  margin-top: 16px;
}

.thumbnail-preview label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 12px;
}

.thumbnail-preview img {
  max-width: 320px;
  border-radius: var(--radius-md);
}

.thumbnail-preview .thumbnail-controls {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.thumbnail-preview input[type="range"] {
  flex: 1;
  accent-color: var(--brand-red);
}

.thumbnail-preview .seek-time {
  font-size: 12px;
  color: var(--text-disabled);
  min-width: 36px;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-sand);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 20px;
}

.progress-bar .progress {
  height: 100%;
  background: var(--brand-red);
  transition: width 0.2s;
  border-radius: 3px;
}

.upload-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}

.pagination .page-info {
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.empty-state h2 {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1.2px;
}

.empty-state p {
  font-size: 16px;
}

/* ========== Loading ========== */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.loading-spinner::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface-sand);
  border-top-color: var(--brand-red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== Responsive: Masonry Columns ========== */
@media (max-width: 576px) {
  main {
    padding: 8px 8px 24px;
  }
  .site-header {
    padding: 0 8px;
  }
}

/* ========== Dark Footer ========== */
.site-footer {
  background: var(--surface-dark);
  color: var(--text-disabled);
  font-size: 12px;
  text-align: center;
  padding: 24px 16px;
  margin-top: auto;
}

.site-footer a {
  color: var(--text-disabled);
  text-decoration: none;
}

.site-footer a:hover {
  color: #ffffff;
}
