/* ===== BookFlow Design System ===== */
:root {
  --bg: #ECEEFB;
  --surface: #fff;
  --surface-2: #F5F6FC;
  --ink: #0E0F1A;
  --ink-2: #2D3142;
  --ink-3: #5B6478;
  --ink-4: #9AA0B4;
  --brand-1: #2B5FD6;
  --brand-2: #4E36D6;
  --brand-glow: rgba(43,95,214,0.15);
  --hairline: #E8EBF4;
  --hairline-2: #E2E5F0;
  --danger: #DC3545;
  --danger-bg: #FFF0F0;
  --success: #22c55e;
  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'Menlo', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(14,15,26,0.08), 0 4px 16px rgba(14,15,26,0.05);
  --shadow-lg: 0 4px 24px rgba(14,15,26,0.12), 0 1px 4px rgba(14,15,26,0.06);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, opacity 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-1);
  color: #fff;
  border-color: var(--brand-1);
}
.btn-primary:hover { background: #2451c0; border-color: #2451c0; }

.btn-ghost {
  background: transparent;
  color: var(--ink-3);
  border-color: var(--hairline-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: #f8c9cc;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.field-hint { font-weight: 400; color: var(--ink-4); font-size: 12px; }

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}
input:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
input::placeholder { color: var(--ink-4); }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  height: 52px;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.topbar-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.topbar-brand-sub {
  color: var(--brand-1);
  font-weight: 500;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ===== Page layout ===== */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}
.page-narrow {
  max-width: 640px;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--ink-4);
  margin-top: 4px;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-4);
  margin-bottom: 20px;
}
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--brand-1); }
.breadcrumb span { color: var(--ink); font-weight: 500; }

/* ===== Flash messages ===== */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 20px;
  background: #EFF6FF;
  color: #1d4ed8;
  border: 1px solid #BFDBFE;
}
.flash-deleted, .flash-notfound {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #f8c9cc;
}

/* ===== Workspace grid ===== */
.ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.ws-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.08s;
}
.ws-card:hover {
  border-color: var(--brand-1);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}
.ws-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.ws-card-body { flex: 1; min-width: 0; }
.ws-card-name { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ws-card-desc {
  font-size: 12.5px;
  color: var(--ink-4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-card-meta { font-size: 12px; color: var(--ink-4); margin-top: 4px; }
.ws-card-arrow { color: var(--ink-4); flex-shrink: 0; }

/* ===== Video list ===== */
.video-list { display: flex; flex-direction: column; gap: 6px; }
.video-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius);
  padding: 12px 16px;
  transition: border-color 0.1s;
}
.video-row:hover { border-color: var(--hairline); }
.video-row-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-1);
  flex-shrink: 0;
}
.video-row-body { flex: 1; min-width: 0; }
.video-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-row-meta { font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.video-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--ink-4);
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--surface-2);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-4);
}
.empty-state p { font-size: 14px; }

/* ===== Upload card ===== */
.upload-card {
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.drop-zone {
  border: 2px dashed var(--hairline-2);
  border-radius: var(--radius);
  transition: border-color 0.12s, background 0.12s;
  cursor: pointer;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--brand-1);
  background: rgba(43,95,214,0.04);
}
.drop-zone-content {
  text-align: center;
  padding: 40px 24px;
}
.drop-zone-icon {
  color: var(--ink-4);
  margin-bottom: 14px;
}
.drop-zone-label { font-size: 14.5px; color: var(--ink-2); font-weight: 500; }
.drop-zone-browse { color: var(--brand-1); cursor: pointer; }
.drop-zone-browse:hover { text-decoration: underline; }
.drop-zone-hint { font-size: 12.5px; color: var(--ink-4); margin-top: 6px; }

.upload-progress {
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  width: 100%;
}
.upload-file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
  font-family: var(--font-mono);
  word-break: break-all;
}
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  border-radius: 99px;
  transition: width 0.15s ease;
  width: 0%;
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
.upload-error {
  padding: 10px 14px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid #f8c9cc;
}
.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,15,26,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-sm { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-4);
  padding: 4px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--ink); background: var(--surface-2); }
.modal-body-text { font-size: 14px; color: var(--ink-3); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Login ===== */
.login-body {
  background: #0A0B14;
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(43,95,214,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 100%, rgba(78,54,214,0.12) 0%, transparent 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-wrap {
  width: 100%;
  max-width: 400px;
}
.login-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 44px 40px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.06) inset;
}
.login-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.login-logo-brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.login-logo-product {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin-bottom: 28px;
}
.login-heading {
  margin-bottom: 28px;
}
.login-heading h1 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}
.login-heading p {
  font-size: 13.5px;
  color: rgba(255,255,255,0.35);
}
.login-error {
  padding: 11px 14px;
  background: rgba(220,53,69,0.15);
  color: #ff8080;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid rgba(220,53,69,0.3);
  margin-bottom: 16px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 20px;
}
.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}
.login-field input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  color: #fff;
  font-family: var(--font-sans);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.login-field input::placeholder { color: rgba(255,255,255,0.2); }
.login-field input:focus {
  border-color: rgba(43,95,214,0.7);
  box-shadow: 0 0 0 3px rgba(43,95,214,0.2);
  background: rgba(255,255,255,0.08);
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 20px rgba(43,95,214,0.4);
}
.login-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-subtitle { font-size: 13.5px; color: var(--ink-4); }
.login-error {
  padding: 10px 12px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid #f8c9cc;
}

/* ===== Player page ===== */
.player-body {
  background: #0E0F1A;
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.player-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.player-logo-text {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  letter-spacing: -0.02em;
}
.player-ws-badge {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.08);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.1);
}
.player-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 48px;
}
.player-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 20px;
  color: #fff;
}
.player-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.player-wrap video { width: 100%; display: block; }
.player-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.player-actions .btn-ghost {
  color: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.12);
}
.player-actions .btn-ghost:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
}
.player-meta { font-size: 12.5px; color: rgba(255,255,255,0.35); font-family: var(--font-mono); }
.player-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: rgba(255,255,255,0.2);
}
.player-footer a { color: rgba(255,255,255,0.35); }

/* Plyr accent color override */
.plyr--video .plyr__control--overlaid,
.plyr--full-ui input[type=range] { --plyr-color-main: #2B5FD6; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .page { padding: 24px 16px 48px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .ws-grid { grid-template-columns: 1fr; }
  .video-row-actions { flex-wrap: wrap; }
  .player-title { font-size: 20px; }
  .player-header { padding: 14px 18px; }
  .login-card { padding: 28px 22px; }
  .modal { padding: 22px 18px; }
}
