:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #697386;
  --line: #d9dee7;
  --accent: #d82424;
  --accent-dark: #b81d1d;
  --focus: #2367d1;
  --shadow: 0 10px 30px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
.auth-link {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.auth-link:hover {
  background: var(--accent-dark);
}

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

button.secondary {
  background: #eef1f6;
  color: var(--text);
}

button.secondary:hover {
  background: #e2e6ee;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(35, 103, 209, 0.14);
}

textarea {
  resize: vertical;
  min-height: 180px;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto;
}

.toolbar,
.controls,
.video-panel,
.schedule-panel,
.reply-panel,
.comment-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
}

.brand p,
.video-panel p,
.message,
.comment-sub {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 320px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
}

.input-group {
  display: grid;
  gap: 7px;
}

.input-group span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.video-panel {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
}

.video-panel img {
  width: 168px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #dfe4ec;
}

.video-panel h2,
.section-head h2 {
  font-size: 18px;
  line-height: 1.35;
}

.schedule-panel {
  margin-top: 16px;
  padding: 16px;
}

.section-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.schedules {
  display: grid;
  gap: 10px;
}

.schedules.empty {
  min-height: 84px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
}

.schedule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 7px;
  background: #fff;
}

.schedule-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.schedule-title strong {
  margin-right: auto;
}

.schedule-badge {
  border-radius: 999px;
  background: #eef1f6;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.schedule-item.randomReply .schedule-badge {
  background: #fff1d6;
  color: #7a4a00;
}

.schedule-item.deletion .schedule-badge {
  background: #ffe4e4;
  color: #9f1d1d;
}

.schedule-delete {
  min-height: 30px;
  border-radius: 6px;
  background: #fff1f1;
  color: #9f1d1d;
  padding: 0 10px;
  font-size: 12px;
}

.schedule-delete:hover {
  background: #ffe4e4;
}

.schedule-meta,
.schedule-candidates {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.schedule-remaining {
  color: var(--text);
  font-weight: 800;
}

.schedule-remaining.due {
  color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.comment-column,
.reply-panel {
  padding: 16px;
}

.reply-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
}

.section-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head.compact {
  min-height: auto;
  margin: 6px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

#randomRepliesInput {
  min-height: 120px;
}

.comments {
  display: grid;
  gap: 10px;
}

.comments.empty {
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
}

.comment {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.select-comment {
  width: 100%;
  min-height: 96px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.select-comment:hover,
.select-comment.selected {
  background: #fff5f5;
}

.select-comment.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dfe4ec;
}

.comment-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.comment-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.comment-meta strong {
  color: var(--text);
  font-size: 14px;
}

.comment-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.comment-sub {
  font-size: 12px;
}

.message {
  min-height: 22px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.message.error {
  color: #b42318;
}

.message.success {
  color: #067647;
}

.hidden {
  display: none;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 1180px);
    margin: 10px auto;
  }

  .toolbar,
  .controls,
  .workspace,
  .video-panel {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  .auth-link {
    width: 100%;
  }

  .video-panel img {
    width: 100%;
  }

  .reply-panel {
    position: static;
  }
}
