:root {
  color-scheme: light;
  --canvas: #ffffff;
  --rail: #f3f7fb;
  --ink: #07163f;
  --muted: #71809e;
  --line: #d9e1eb;
  --line-strong: #b8c6d8;
  --accent: #079b98;
  --accent-dark: #087773;
  --accent-soft: #e5f5f4;
  --warning: #d88a00;
  --danger: #dc3b31;
  --focus: #67c8c5;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button,
input {
  color: inherit;
  font: 600 14px/1.25 var(--font);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.app-shell {
  display: grid;
  grid-template-columns: clamp(320px, 24.5vw, 388px) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--rail);
  border-right: 1px solid #edf1f6;
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.sidebar > .brand {
  margin: 34px 36px 48px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  color: var(--accent);
  stroke-width: 2;
}

.sidebar-heading {
  padding: 0 36px 30px;
}

.sidebar-heading h1 {
  margin: 0 0 18px;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.primary-button,
.secondary-button,
.back-button,
.icon-button {
  border: 0;
  border-radius: 10px;
}

.primary-button {
  display: inline-flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 0 rgb(7 22 63 / 8%);
  transition: background-color 140ms ease, transform 140ms ease;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button.compact {
  width: auto;
  min-width: 104px;
  min-height: 42px;
}

.authors-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 28px;
}

.author-row {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  padding: 25px 34px 25px 58px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  transition: background-color 140ms ease;
}

.author-row::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: transparent;
  content: "";
}

.author-row:hover {
  background: rgb(255 255 255 / 55%);
}

.author-row.selected {
  background: var(--canvas);
}

.author-row.selected::before {
  background: var(--accent);
}

.author-row-title {
  overflow: hidden;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.author-row-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.author-row svg {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
}

.main-content {
  min-width: 0;
  overflow-y: auto;
  background: var(--canvas);
}

.mobile-appbar {
  display: none;
}

.welcome-state {
  display: grid;
  min-height: 100%;
  place-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
}

.welcome-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
}

.welcome-mark svg {
  width: 34px;
  height: 34px;
}

.welcome-state h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.025em;
}

.welcome-state p {
  max-width: 390px;
  margin: 10px 0 0;
  color: var(--muted);
}

.author-detail {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 108px 60px 80px;
}

.detail-header {
  display: flex;
  min-height: 86px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.detail-header h2 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(34px, 4vw, 42px);
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.detail-count {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.records-list {
  min-height: 200px;
}

.date-group + .date-group {
  margin-top: 24px;
}

.date-heading {
  margin: 0;
  padding: 14px 0 13px;
  border-bottom: 1px solid var(--line);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.record {
  border-bottom: 1px solid var(--line);
}

.record-summary {
  display: grid;
  width: 100%;
  min-height: 78px;
  grid-template-columns: 90px 220px minmax(0, 1fr) 28px;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background-color 140ms ease;
}

.record-summary:hover {
  background: #fbfcfe;
}

.record-time {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 650;
}

.status svg,
.status-ring {
  width: 20px;
  height: 20px;
  flex: none;
}

.status-ring {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.status-completed { color: var(--accent); }
.status-processing,
.status-uploading { color: var(--warning); }
.status-failed { color: var(--danger); }

.status-processing .status-ring,
.status-uploading .status-ring {
  border-color: color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  animation: spin 900ms linear infinite;
}

.record-helper {
  max-width: 520px;
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: normal;
}

.record-helper.error {
  color: var(--ink);
}

.disclosure-icon {
  grid-column: 4;
  width: 20px;
  height: 20px;
  justify-self: end;
  transition: transform 180ms ease;
}

.record.expanded .disclosure-icon {
  transform: rotate(180deg);
}

.record-text {
  max-width: 940px;
  padding: 2px 48px 34px 120px;
  color: #101d3e;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.empty-state,
.loading-state,
.error-state {
  display: grid;
  min-height: 240px;
  place-content: center;
  justify-items: center;
  padding: 36px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.error-state strong {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 17px;
}

.empty-state p,
.error-state p {
  max-width: 430px;
  margin: 0;
}

.empty-state .primary-button {
  width: auto;
  margin-top: 20px;
}

.skeleton-list {
  padding: 8px 28px;
}

.skeleton-row {
  height: 68px;
  margin: 10px 0;
  border-radius: 10px;
  background: #e8eef4;
  animation: skeleton 1.4s ease-in-out infinite;
}

@keyframes skeleton {
  50% { opacity: 0.48; }
}

.compact-empty {
  min-height: 190px;
  padding-inline: 28px;
}

.error-state .secondary-button {
  margin-top: 18px;
}

.records-skeleton {
  padding-inline: 0;
}

.disclosure-spacer {
  grid-column: 4;
  width: 20px;
  height: 20px;
}

.author-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--canvas);
  box-shadow: 0 24px 70px rgb(7 22 63 / 18%);
  color: var(--ink);
}

.author-dialog::backdrop {
  background: rgb(7 22 63 / 36%);
  backdrop-filter: blur(2px);
}

.author-dialog form {
  padding: 26px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.dialog-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  background: transparent;
}

.icon-button:hover {
  background: var(--rail);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 650;
}

.author-dialog input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--canvas);
  font-size: 15px;
  font-weight: 450;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.author-dialog input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.author-dialog input.invalid {
  border-color: var(--danger);
}

.field-error {
  min-height: 20px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  background: var(--canvas);
}

.secondary-button:hover {
  background: var(--rail);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(400px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 14px 34px rgb(7 22 63 / 20%);
  color: #fff;
  font-size: 14px;
}

.back-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  background: transparent;
  color: var(--accent-dark);
  font-size: 15px;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    min-height: 100dvh;
    border: 0;
  }

  .sidebar > .brand {
    margin: 24px 20px 34px;
  }

  .brand {
    gap: 11px;
    font-size: 20px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .sidebar-heading {
    padding: 0 20px 20px;
  }

  .sidebar-heading h1 {
    font-size: 30px;
    letter-spacing: -0.035em;
  }

  .authors-list {
    padding-bottom: 40px;
  }

  .author-row {
    margin: 0 12px;
    width: calc(100% - 24px);
    padding: 18px 16px 18px 20px;
    border-bottom: 1px solid var(--line);
  }

  .author-row.selected {
    border-radius: 10px;
  }

  .show-authors .main-content,
  .detail-open .sidebar {
    display: none;
  }

  .main-content {
    min-height: 100dvh;
    overflow: visible;
  }

  .mobile-appbar {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
  }

  .brand-mobile {
    font-size: 17px;
  }

  .brand-mobile .brand-mark {
    width: 28px;
    height: 28px;
  }

  .author-detail {
    width: 100%;
    padding: 42px 24px 64px;
  }

  .detail-header {
    min-height: auto;
    margin-bottom: 32px;
  }

  .detail-header h2 {
    font-size: 32px;
    line-height: 1.16;
  }

  .detail-count {
    margin-top: 8px;
    font-size: 17px;
  }

  .date-group + .date-group {
    margin-top: 34px;
  }

  .date-heading {
    margin-bottom: 12px;
    padding: 0;
    border: 0;
    color: var(--muted);
    font-size: 16px;
  }

  .record {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
  }

  .record-summary {
    min-height: 76px;
    grid-template-columns: 78px minmax(0, 1fr) 24px;
    gap: 8px 14px;
    padding: 17px 16px;
  }

  .record-time {
    grid-column: 1;
    grid-row: 1;
    font-size: 17px;
  }

  .status {
    grid-column: 2;
    grid-row: 1;
  }

  .record-helper {
    grid-column: 1 / span 2;
    grid-row: 2;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 14px;
    white-space: normal;
  }

  .disclosure-icon {
    grid-column: 3;
    grid-row: 1;
  }

  .record-text {
    margin: 0 16px;
    padding: 22px 0 26px;
    border-top: 1px solid var(--line);
    font-size: 16px;
    line-height: 1.55;
  }

  .disclosure-spacer {
    grid-column: 3;
  }

  .welcome-state {
    min-height: calc(100dvh - 76px);
  }

  .author-dialog form {
    padding: 22px;
  }

  .toast {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (min-width: 761px) {
  .app-shell .sidebar,
  .app-shell .main-content {
    display: flex;
  }

  .main-content {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
