:root {
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --primary: #6C63FF;
  --primary-strong: #5147f0;
  --sidebar: #2E255B;
  --text: #1E1E1E;
  --muted: #7A7A8C;
  --border: #ECECF4;
  --success-bg: #e9fbf1;
  --success-text: #16784a;
  --warning-bg: #fff5e8;
  --warning-text: #a76412;
  --danger-bg: #fdecec;
  --danger-text: #bf2f2f;
  --radius-lg: 20px;
  --radius-md: 16px;
  --shadow: 0 10px 30px rgba(25, 28, 50, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(108, 99, 255, 0.10), transparent 24%),
    linear-gradient(180deg, #f9f9fc 0%, var(--bg) 100%);
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 32px 24px;
  background: linear-gradient(180deg, #2e255b 0%, #241c4d 100%);
  color: #fff;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sidebar__title {
  font-size: 18px;
  font-weight: 700;
}

.sidebar__subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 13px;
}

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

.sidebar__link {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.74);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar__link:hover,
.sidebar__link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateX(2px);
}

.sidebar__logout {
  margin-top: auto;
}

.main-content {
  min-width: 0;
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  min-width: 0;
}

.content-main,
.right-panel {
  display: grid;
  gap: 24px;
  align-content: start;
  min-width: 0;
}

.page-title,
.card__title,
.login-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.card__title {
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}

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

.card__badge,
.user-pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(108, 99, 255, 0.12);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 14px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font: inherit;
  color: var(--text);
  background: #fbfbfe;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(108, 99, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12);
}

.field input[type="file"] {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--muted);
}

.field input[type="file"]::file-selector-button {
  margin-right: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(108, 99, 255, 0.12);
  border-radius: 12px;
  background: #f3f2ff;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.field input[type="file"]::file-selector-button:hover {
  background: #ebe9ff;
  transform: translateY(-1px);
}

.field input[type="file"]::file-selector-button:active {
  transform: translateY(0);
}

.field input[type="file"]::-webkit-file-upload-button {
  margin-right: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(108, 99, 255, 0.12);
  border-radius: 12px;
  background: #f3f2ff;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.field input[type="file"]::-webkit-file-upload-button:hover {
  background: #ebe9ff;
  transform: translateY(-1px);
}

.upload-actions,
.quick-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 24px rgba(108, 99, 255, 0.22);
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-ghost {
  background: #f3f2ff;
  color: var(--primary);
  border-color: rgba(108, 99, 255, 0.12);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.btn-full {
  width: 100%;
}

.message {
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}

.message.is-success {
  color: var(--success-text);
}

.message.is-error {
  color: var(--danger-text);
}

.recordings-list {
  display: grid;
  gap: 16px;
}

.recording-card {
  display: block;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfcff 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  min-width: 0;
  max-width: 100%;
}

.recording-card__main {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.recording-card:hover {
  border-color: rgba(108, 99, 255, 0.18);
  box-shadow: 0 16px 30px rgba(20, 25, 45, 0.06);
  transform: translateY(-2px);
}

.recording-card__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.recording-card__title {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.recording-card__sub {
  color: var(--muted);
  font-size: 13px;
}

.recording-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.recording-meta {
  display: grid;
  gap: 4px;
}

.recording-meta span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.recording-meta strong {
  font-size: 14px;
}

.recording-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.recording-card__footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.recording-card__extra {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.recording-card__extra-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.recording-card__extra-value {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-uploaded {
  background: #eef3ff;
  color: #3157d5;
}

.status-processing {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.status-transcribed {
  background: #eef3ff;
  color: #3157d5;
}

.status-done {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.stats-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.stat-tile {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fcfcff;
  min-width: 0;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 22px;
  line-height: 1.2;
}

.recent-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  text-decoration: none;
  background: #fcfcff;
  min-width: 0;
}

.recent-item span,
.recent-item strong {
  min-width: 0;
}

.recent-item span {
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.recent-item strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

.empty-state {
  padding: 40px 28px;
  border: 1px dashed rgba(108, 99, 255, 0.25);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8f8ff 100%);
  text-align: center;
}

.empty-state.compact {
  text-align: left;
}

.empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 22px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 18, 29, 0.45);
  backdrop-filter: blur(6px);
}

.modal.is-open {
  display: flex;
}

.modal__dialog {
  width: min(920px, 100%);
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(12, 14, 33, 0.18);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  margin: 0;
  font-size: 24px;
}

.modal__content,
.transcript-pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.85;
  font-size: 15px;
  color: #2a2d3a;
  background: transparent;
  border-radius: 18px;
}

.modal__content {
  padding: 24px;
}

.detail-hero__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.detail-summary__item {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
}

.detail-summary__item--status {
  background: linear-gradient(180deg, rgba(108, 99, 255, 0.12) 0%, rgba(108, 99, 255, 0.05) 100%);
  border-color: rgba(108, 99, 255, 0.18);
}

.detail-summary__item--file {
  grid-column: 1 / -1;
}

.detail-summary__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-summary__value {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.detail-summary__value--file {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.detail-summary__hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.transcript-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 18px;
  margin-bottom: 18px;
}

.transcript-toolbar__description {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.transcript-toolbar__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 520px;
}

.transcript-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.transcript-search__input {
  width: 100%;
  min-width: 180px;
  flex: 1 1 280px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfbfe;
  color: var(--text);
  font: inherit;
}

.transcript-search__input:focus {
  outline: none;
  border-color: rgba(108, 99, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12);
}

.transcript-search__count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.transcript-copy-btn {
  flex: 0 0 auto;
  margin-left: auto;
}

.transcript-nav-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.transcript-surface {
  padding: 10px;
  border: 1px solid rgba(108, 99, 255, 0.10);
  border-radius: 22px;
  background: linear-gradient(180deg, #fcfcff 0%, #f7f8ff 100%);
}

.transcript-pre {
  padding: 28px;
  max-height: 70vh;
  font-size: 15px;
  line-height: 1.9;
}

.transcript-content {
  display: grid;
  gap: 16px;
  white-space: pre-wrap;
}

.transcript-segment {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid rgba(108, 99, 255, 0.10);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
}

.transcript-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.transcript-speaker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.transcript-time {
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(108, 99, 255, 0.10);
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.transcript-text,
.transcript-segment__text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.speaker-1 {
  background: #eef2ff;
}

.speaker-2 {
  background: #f0fdf4;
}

.speaker-3 {
  background: #fff7ed;
}

.speaker-fallback {
  background: rgba(255, 255, 255, 0.75);
}

.transcript-pre mark {
  padding: 0.08em 0.16em;
  border-radius: 6px;
  background: #fff0a8;
  color: inherit;
}

.transcript-pre mark.is-active {
  background: #ffd666;
  box-shadow: 0 0 0 1px rgba(255, 191, 0, 0.25);
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  padding: 36px;
  box-shadow: 0 30px 80px rgba(18, 18, 42, 0.14);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.login-title {
  font-size: 28px;
}

.login-subtitle {
  margin: 0 0 24px 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

@media (max-width: 1280px) {
  .content-grid {
    grid-template-columns: 1fr 280px;
  }

  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .right-panel {
    display: none;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .main-content {
    padding: 24px;
  }

  .form-grid,
  .detail-summary,
  .recording-card__meta {
    grid-template-columns: 1fr;
  }

  .recording-card {
    grid-template-columns: 1fr;
  }

  .recording-card__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .recording-card__actions,
  .upload-actions {
    width: 100%;
    justify-content: stretch;
  }
}

@media (max-width: 640px) {
  .main-content,
  .sidebar {
    padding: 20px;
  }

  .topbar,
  .card__header,
  .detail-hero__header,
  .modal__header,
  .transcript-toolbar {
    flex-direction: column;
  }

  .transcript-toolbar__controls {
    min-width: 0;
    width: 100%;
    flex-wrap: wrap;
  }

  .transcript-toolbar__actions {
    justify-content: flex-start;
  }

  .topbar__actions,
  .upload-actions,
  .quick-actions {
    width: 100%;
  }

  .btn,
  .btn-full {
    width: 100%;
  }
}
