:root {
  color-scheme: light;
  font-family: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  background: #f4f2ee;
  color: #1f2933;
}

body {
  margin: 0;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: #111827;
  color: #f8fafc;
}

.site-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  line-height: 1.1;
}

.site-logo {
  width: clamp(32px, 2vw, 32px);
  height: clamp(32px, 2vw, 32px);
  flex-shrink: 0;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.site-header nav a {
  color: #e2e8f0;
  text-decoration: none;
}

.site-header nav a:hover {
  color: #f59e0b;
}

.site-header nav button {
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #e2e8f0;
}

.site-header nav button:hover {
  background: #0f172a;
  color: #f8fafc;
}

.nav-user {
  font-size: 0.9rem;
  color: #cbd5f5;
}

main {
  padding: 2rem;
  display: grid;
  gap: 1.5rem;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

form {
  display: grid;
  gap: 1rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

label {
  display: grid;
  gap: 0.5rem;
  font-weight: 600;
}

.inline-label {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
}

.inline-label span {
  margin-right: 0.75rem;
}

input,
select,
textarea {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
}

textarea {
  font-family: inherit;
  resize: vertical;
}

button {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: #1f2933;
  color: #f8fafc;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #0f172a;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.form-message {
  font-size: 0.9rem;
  margin: 0;
}

.form-message[data-state="error"] {
  color: #dc2626;
}

.form-message[data-state="success"] {
  color: #15803d;
}

.helper-text {
  margin: 0;
  font-size: 0.9rem;
  color: #64748b;
}

.candidate-list {
  display: grid;
  gap: 0.75rem;
}

.episode-picker {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.episode-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.candidate-option,
.history-card {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  background: #f8fafc;
  cursor: pointer;
}

.history-card {
  grid-template-columns: auto auto 1fr;
  align-items: start;
  cursor: default;
}

.history-select {
  display: grid;
  place-items: start;
  padding-top: 0.2rem;
}

.history-select input {
  width: 18px;
  height: 18px;
}

.activity-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.activity-stat {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  background: #f8fafc;
  display: grid;
  gap: 0.35rem;
}

.activity-stat span {
  font-size: 0.8rem;
  color: #64748b;
}

.activity-stat strong {
  font-size: 1.1rem;
}

.activity-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.activity-controls input,
.activity-controls select {
  min-width: 180px;
}

.activity-list,
.schedule-list {
  display: grid;
  gap: 0.75rem;
}

.schedule-group {
  display: grid;
  gap: 0.5rem;
}

.schedule-group h3 {
  margin: 0;
  font-size: 1rem;
  color: #334155;
}

.schedule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  background: #f8fafc;
}

.schedule-title {
  font-weight: 600;
}

.schedule-meta {
  font-size: 0.9rem;
  color: #475569;
}

.schedule-time {
  text-align: right;
  font-weight: 600;
}

.schedule-time small {
  display: block;
  font-weight: 400;
  color: #64748b;
}

.activity-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  background: #f8fafc;
}

.activity-row summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
  cursor: pointer;
  list-style: none;
}

.activity-row summary::-webkit-details-marker {
  display: none;
}

.activity-main {
  display: grid;
  gap: 0.25rem;
}

.activity-title {
  font-weight: 600;
}

.activity-meta {
  font-size: 0.9rem;
  color: #475569;
}

.activity-status {
  display: grid;
  justify-items: end;
  gap: 0.35rem;
  text-align: right;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pending {
  background: #fde68a;
  color: #92400e;
}

.status-active {
  background: #bfdbfe;
  color: #1e3a8a;
}

.status-success {
  background: #bbf7d0;
  color: #166534;
}

.status-failed {
  background: #fecaca;
  color: #991b1b;
}

.status-unknown {
  background: #e2e8f0;
  color: #475569;
}

.activity-detail {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #e2e8f0;
  display: grid;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #475569;
}

.activity-detail pre {
  margin: 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.8rem;
  overflow: auto;
}

.empty-state {
  color: #64748b;
  font-size: 0.95rem;
}

.history-bulk-actions {
  align-items: center;
}

.history-controls {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.history-filters {
  align-items: center;
}

.history-filters input[type="search"] {
  min-width: 220px;
}

.history-pagination {
  align-items: center;
}

.candidate-option input {
  margin: 0 0.5rem 0 0;
}

.candidate-poster {
  width: 64px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: #e2e8f0;
}

.candidate-meta h3 {
  margin: 0;
  font-size: 1rem;
}

.candidate-meta p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #475569;
}

.history-meta {
  display: grid;
  gap: 0.5rem;
}

.history-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.history-edit {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.history-edit.is-visible {
  display: flex;
}

.history-edit input {
  min-width: 220px;
}

.history-edit select {
  min-width: 140px;
}

button.secondary-button {
  background: #e2e8f0;
  color: #1f2933;
  border: 1px solid #cbd5f5;
}

button.secondary-button:hover {
  background: #cbd5f5;
}

button.danger-button {
  background: #b91c1c;
}

button.danger-button:hover {
  background: #991b1b;
}

.menu-button {
  border: 1px solid #cbd5f5;
  background: #ffffff;
  padding: 0.35rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.menu-button:hover {
  background: #f1f5f9;
}

.menu-dots {
  display: grid;
  gap: 3px;
}

.menu-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #1f2933;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 160px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  padding: 0.35rem;
  display: none;
  z-index: 20;
}

.menu-panel.is-open {
  display: grid;
  gap: 0.25rem;
}

.menu-panel button {
  width: 100%;
  text-align: left;
  background: transparent;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-weight: 600;
  color: #1f2933;
}

.menu-panel button:hover {
  background: #f1f5f9;
}

.menu-panel button.danger-button {
  background: transparent;
  color: #b91c1c;
  border: none;
}

.menu-panel button.danger-button:hover {
  background: #fee2e2;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 40;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-panel {
  position: relative;
  width: min(90vw, 640px);
  max-height: min(85vh, 720px);
  overflow: auto;
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  display: grid;
  gap: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-body {
  display: grid;
  gap: 1rem;
}

.metadata-section {
  display: grid;
  gap: 0.5rem;
}

.metadata-section h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #1f2933;
}

.metadata-grid {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr;
  gap: 0.5rem 1rem;
}

.metadata-grid dt {
  font-weight: 600;
  color: #1f2933;
}

.metadata-grid dd {
  margin: 0;
  color: #475569;
  word-break: break-word;
}
