* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

.panel {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

h1,
h2,
p {
  margin-top: 0;
}

.subtext {
  color: #6b7280;
}

.small {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

#video-file {
  display: none;
}

.saved-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.saved-file-field {
  display: grid;
  gap: 8px;
}

.saved-file-field label {
  font-weight: 600;
}

.saved-file-field input,
.saved-file-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.saved-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.saved-file-status {
  min-height: 1.25rem;
  margin-top: 0;
  margin-bottom: 16px;
}

.button,
.text-button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
}

.button {
  background: #2563eb;
  color: #ffffff;
  padding: 10px 14px;
}

.button.secondary {
  background: #e5e7eb;
  color: #111827;
}

.text-button {
  background: transparent;
  color: #2563eb;
  padding: 6px 0;
}

.text-button.danger {
  color: #dc2626;
}

.file-name {
  color: #4b5563;
  min-width: 0;
  overflow-wrap: anywhere;
}

.video-card {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 0 12px;
  border: none;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
  margin-bottom: 12px;
}

#video-player {
  width: 100%;
  max-height: 480px;
  background: #111827;
  border-radius: 10px;
}

.video-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
  color: #4b5563;
}

.video-toggle-button {
  padding: 8px 12px;
  min-width: 72px;
}

.video-time-row {
  display: inline-flex;
  gap: 16px;
  align-items: center;
  flex-wrap: nowrap;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.bookmark-form {
  display: grid;
  gap: 12px;
}

.bookmark-form label {
  font-weight: 600;
}

.bookmark-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.time-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.time-input-group input {
  flex: 0 1 96px;
  width: 96px;
  min-width: 0;
  text-align: center;
  padding: 8px 10px;
}

.time-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.form-message {
  min-height: 1.25rem;
  margin-bottom: 0;
  color: #b91c1c;
}

.bookmark-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.bookmark-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid #dbe3f0;
  border-radius: 10px;
  background: #f8fafc;
}

.bookmark-item.dragging {
  opacity: 0.5;
}

.bookmark-item.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
}

.bookmark-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.bookmark-play {
  border: none;
  background: transparent;
  color: #111827;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
}

.bookmark-range {
  margin-bottom: 0;
  color: #4b5563;
}

.bookmark-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.empty-state {
  color: #6b7280;
  margin-top: 16px;
  margin-bottom: 0;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  body {
    background: #ffffff;
  }

  .app-shell {
    padding: 0 10px 24px;
  }

  .panel {
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  }

  .video-card {
    top: 0;
    padding: 0 0 10px;
    margin-bottom: 10px;
  }

  h1 {
    font-size: 1.45rem;
    line-height: 1.2;
  }

  h2 {
    font-size: 1.1rem;
    line-height: 1.25;
  }

  .small {
    font-size: 0.9rem;
  }

  .upload-row,
  .saved-file-actions,
  .section-header,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .saved-file-grid,
  .time-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .button,
  .saved-file-field input,
  .saved-file-field select,
  .bookmark-form input[type="text"]:not(#bookmark-from):not(#bookmark-to) {
    width: 100%;
  }

  .button {
    padding: 11px 14px;
  }

  #video-player {
    max-height: 240px;
    border-radius: 8px;
  }

  .video-meta {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .video-toggle-button {
    width: fit-content;
    min-width: 64px;
    padding: 8px 10px;
  }

  .video-time-row {
    gap: 12px;
    white-space: nowrap;
  }

  .bookmark-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
  }

  .bookmark-main,
  .bookmark-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .bookmark-play {
    width: 100%;
    font-size: 0.98rem;
  }

  .time-input-group {
    gap: 6px;
  }

  .time-input-group input {
    flex-basis: 88px;
    width: 88px;
  }

  .time-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .saved-file-actions {
    align-items: stretch;
  }
}
