:root {
  color-scheme: light;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --ink: #171a1f;
  --muted: #68717f;
  --line: #dce1e7;
  --line-strong: #b8c0ca;
  --success: #167d4b;
  --warning: #a96312;
  --danger: #b83232;
  --focus: #1469d2;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

button, input { font: inherit; letter-spacing: 0; }

a { color: inherit; }

button, input, a { outline-offset: 3px; }

button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--focus); }

button {
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
  padding: 0 18px;
  font-weight: 650;
}

button:hover { background: #2b3038; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.summary-inner,
.task-section,
.video-section {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand-lockup > strong {
  font-family: "DIN Alternate", "Arial Narrow", sans-serif;
  font-size: 19px;
}

.brand-mark {
  width: 38px;
  height: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 4px;
}

.brand-mark span { display: block; background: var(--ink); }
.brand-mark span:nth-child(1) { height: 45%; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 68%; background: var(--success); }
.brand-mark.compact { width: 23px; height: 19px; gap: 2px; }

.back-link {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-size: 20px;
}

.text-button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.text-button:hover { background: transparent; color: var(--ink); }

h2, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 18px; }

.task-form {
  width: min(460px, 100%);
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
}

.task-form input { width: 100%; height: 38px; border: 0; padding: 0 11px; min-width: 0; font-size: 14px; }
.task-form input:focus { outline: 0; }
.task-form button { border-radius: 0; border-width: 0 0 0 1px; min-height: 40px; padding: 0 14px; font-size: 14px; }

.page-message { margin: -4px 0 16px; }
.page-message.error, .form-error { color: var(--danger); }

.summary-band { background: #eef1f4; border-bottom: 1px solid var(--line); }
.summary-inner { min-height: 94px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-inner > div { display: flex; align-items: baseline; gap: 10px; padding: 22px 0; }
.summary-inner > div + div { border-left: 1px solid var(--line); padding-left: 32px; }
.summary-inner strong { font-family: "DIN Alternate", "Arial Narrow", sans-serif; font-size: 31px; }
.summary-inner span { color: var(--muted); }

.task-section, .video-section { padding: 36px 0 64px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.task-section-heading { align-items: center; gap: 32px; }

.task-table { border-top: 1px solid var(--line-strong); background: var(--surface); }
.task-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(120px, .7fr) 112px minmax(135px, .9fr) minmax(150px, 1fr) minmax(120px, .8fr) 70px; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); }
.task-row > * { padding: 14px 16px; min-width: 0; }
.task-head { min-height: 42px; color: var(--muted); font-size: 12px; font-weight: 650; }
.task-name { display: flex; align-items: center; gap: 7px; }
.task-name strong, .task-link { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; overflow-wrap: anywhere; }
.task-link { text-decoration-thickness: 1px; text-underline-offset: 4px; }
.note-cell { display: flex; align-items: center; gap: 6px; }
.task-note { flex: none; color: var(--muted); font-size: 12px; }
.note-edit, .note-save { width: 28px; height: 28px; min-height: 28px; padding: 0; display: grid; place-items: center; border-radius: 0; }
.note-edit { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 17px; }
.note-edit svg { width: 15px; height: 15px; }
.note-edit:hover { background: transparent; color: var(--ink); }
.note-form { width: 100%; display: flex; align-items: center; gap: 4px; }
.note-form[hidden], .note-edit[hidden], .task-note[hidden] { display: none; }
.note-form input { width: calc(100% - 30px); height: 30px; min-width: 0; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 0; }
.note-save { width: 26px; border: 0; background: transparent; color: var(--success); }
.note-save svg { width: 17px; height: 17px; }
.note-save:hover { background: transparent; color: #0d6339; }
.status-cell { display: flex; align-items: center; }
.recording-live-link { width: 22px; height: 18px; flex: none; display: grid; place-items: center; color: #df2f3a; text-decoration: none; }
.live-sound { height: 14px; display: flex; align-items: center; gap: 2px; }
.live-sound i { width: 3px; height: 12px; display: block; background: currentColor; transform-origin: center; animation: live-sound-jump 800ms ease-in-out infinite; }
.live-sound i:nth-child(2) { animation-delay: -600ms; }
.live-sound i:nth-child(3) { animation-delay: -400ms; }
.live-sound i:nth-child(4) { animation-delay: -200ms; }
@keyframes live-sound-jump {
  0%, 100% { transform: scaleY(.25); }
  50% { transform: scaleY(1); }
}
.created-cell, .check-cell small { color: var(--muted); font-size: 12px; }
.check-cell { display: flex; flex-direction: column; gap: 2px; }
.check-cell small[title] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }

.status { display: inline-block; border-radius: 4px; padding: 5px 8px; background: #edf0f3; color: #4d5663; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-recording, .video-uploaded { background: #e4f3eb; color: var(--success); }
.status-completed { background: #d9efe4; color: #0d6339; }
.status-finalizing, .video-uploading, .video-processing { background: #fff0dc; color: var(--warning); }
.video-upload_failed { background: #fbe5e5; color: var(--danger); }
.task-status { padding: 0; border-radius: 0; background: transparent; color: var(--muted); }
.task-status.status-recording, .task-status.status-completed { background: transparent; color: var(--success); }
.task-status.status-finalizing { background: transparent; color: var(--warning); }

.progress-link { width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.progress-link > span:last-child { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.progress-link:hover .progress-rail { filter: brightness(.92); }
.progress-rail { width: 108px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; }
.progress-rail i { display: block; height: 8px; border: 1px solid var(--line-strong); background: var(--surface); }
.progress-rail i.filled { border-color: var(--success); background: var(--success); }
.task-actions { text-align: right; white-space: nowrap; }
.action-head { text-align: right; }
.action-placeholder { color: var(--line-strong); }

.empty-state { min-height: 180px; display: grid; place-items: center; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.empty-state p { margin: 0; }

.detail-progress { display: flex; align-items: center; gap: 14px; }
.detail-progress strong { font-family: "SFMono-Regular", Consolas, monospace; }
.video-list { border-top: 2px solid var(--ink); background: var(--surface); }
.video-row { min-height: 74px; display: grid; grid-template-columns: 54px minmax(220px, 1fr) 130px 190px; align-items: center; border-bottom: 1px solid var(--line); }
.video-row > * { padding: 12px 16px; min-width: 0; }
.video-index { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; }
.video-meta { display: flex; flex-direction: column; gap: 2px; }
.video-meta span { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.video-actions { display: flex; justify-content: flex-end; gap: 18px; white-space: nowrap; }
.video-actions a, .copy-link { font-weight: 650; text-underline-offset: 4px; }
.copy-link { min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; text-decoration: underline; }
.copy-link:hover { background: transparent; color: var(--muted); }
.video-actions span { color: var(--line-strong); }
.copy-toast { position: fixed; left: 50%; bottom: 28px; z-index: 10; transform: translateX(-50%); padding: 9px 14px; border-radius: 4px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 650; box-shadow: 0 4px 14px rgb(0 0 0 / 18%); }
.copy-toast[hidden] { display: none; }

.login-page { background: var(--surface); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-panel { width: min(360px, 100%); }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 13px; font-weight: 650; }
.login-form input { height: 48px; border: 1px solid var(--line-strong); border-radius: 0; padding: 0 12px; }
.login-form button { margin-top: 6px; }
.form-error { margin: 0 0 16px; }

@media (max-width: 760px) {
  .header-inner, .summary-inner, .task-section, .video-section { width: min(100% - 28px, 1180px); }
  .summary-inner { min-height: 78px; }
  .summary-inner > div { display: block; padding: 16px 10px 14px; }
  .summary-inner > div:first-child { padding-left: 0; }
  .summary-inner > div + div { padding-left: 14px; }
  .summary-inner strong, .summary-inner span { display: block; }
  .summary-inner strong { font-size: 26px; }
  .summary-inner span { font-size: 11px; margin-top: 2px; }
  .task-section, .video-section { padding-top: 28px; }
  .task-section-heading { align-items: stretch; flex-direction: column; gap: 14px; }
  .task-section-heading .task-form { width: 100%; }
  .task-head { display: none; }
  .task-table { background: transparent; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; min-height: 0; margin-bottom: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
  .task-row > * { padding: 0; }
  .task-name { grid-column: 1; grid-row: 1; }
  .note-cell { grid-column: 1 / -1; grid-row: 2; }
  .created-cell { grid-column: 1; grid-row: 3; }
  .status-cell { grid-column: 2; grid-row: 1; }
  .progress-cell { grid-column: 1 / -1; grid-row: 4; padding-top: 12px; border-top: 1px solid var(--line); }
  .progress-rail { flex: 1; width: auto; }
  .check-cell { grid-column: 1; grid-row: 5; font-size: 12px; color: var(--muted); }
  .task-actions { grid-column: 2; grid-row: 5; }
  .detail-progress { gap: 8px; }
  .detail-progress .progress-rail { display: none; }
  .video-row { grid-template-columns: 42px minmax(0, 1fr) auto; padding: 12px 0; }
  .video-row > * { padding: 8px 10px; }
  .video-row .status { grid-column: 2; justify-self: start; }
  .video-actions { grid-column: 3; grid-row: 1 / 3; flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .live-sound i { animation: none; }
}
