:root {
  --bg: #03070d;
  --bg2: #08131a;
  --fg: #d9ffe6;
  --muted: #88b59b;
  --card: #07141b;
  --card2: #0c1d28;
  --accent: #5dff97;
  --accent2: #17b86e;
  --line: #1f4c39;
  --tab: #10252f;
  --tab-active: #163345;
  --tab-pane-bg: linear-gradient(180deg, rgba(8, 21, 28, 0.72) 0%, rgba(5, 14, 20, 0.88) 100%);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--fg);
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(125, 168, 146, 0.018) 0px,
      rgba(125, 168, 146, 0.018) 1px,
      transparent 1px,
      transparent 4px
    ),
    radial-gradient(circle at 10% 10%, rgba(93, 255, 151, 0.16), transparent 38%),
    radial-gradient(circle at 90% 0%, rgba(23, 184, 110, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 6px 6px, 180vw 160vh, 140vw 140vh, 100% 100%;
  background-attachment: fixed, scroll, scroll, fixed;
}
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.container {
  max-width: min(1920px, calc(100vw - 24px));
  width: calc(100vw - 24px);
  margin: 24px auto 48px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 22px 40px rgba(1, 6, 14, 0.65);
  overflow-x: clip;
}
.login-container {
  max-width: 620px;
  width: 100%;
  min-height: 760px;
}
h1 {
  margin-top: 0;
  color: var(--accent);
}
.brand-title {
  margin-bottom: 6px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  font-size: 24px;
}
.brand-subtitle {
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
p { color: var(--muted); }
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.auth-form {
  display: grid;
  gap: 10px;
  max-width: 100%;
}
.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.role-btn {
  background: #0f2030;
  color: #b8d9ce;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.role-btn.active {
  border-color: #66d7ff;
  box-shadow: inset 0 0 0 1px rgba(102, 215, 255, 0.45);
  color: #ddf6ff;
}
.role-hint {
  margin: 0;
  font-size: 13px;
  color: #9ed1bd;
}
label {
  font-weight: 600;
  color: #a7d6bc;
  font-size: 13px;
}
input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  color: var(--fg);
  background: #061018;
  border-radius: 8px;
  padding: 8px 10px;
}
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  color: var(--fg);
  background: #061018;
  border-radius: 8px;
  padding: 8px 10px;
}
textarea {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--fg);
  background: #061018;
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}
button {
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #011107;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
button.secondary {
  background: #163224;
  color: #d7ffe6;
}
button.danger {
  background: linear-gradient(135deg, #d43838, #ff6b6b);
  color: #2a0000;
}
.notice {
  border-radius: 8px;
  padding: 10px;
  border: 1px solid transparent;
}
.notice.error {
  background: rgba(255, 60, 60, 0.12);
  border-color: rgba(255, 60, 60, 0.35);
  color: #ffb4b4;
}
.notice.warning {
  background: rgba(255, 209, 92, 0.1);
  border-color: rgba(255, 209, 92, 0.35);
  color: #ffe6a1;
}
.notice.success {
  background: rgba(41, 224, 125, 0.1);
  border-color: rgba(41, 224, 125, 0.35);
  color: #aef0cb;
}
.table-wrap {
  margin-top: 14px;
  overflow: auto;
  max-width: 100%;
  border: 1px solid rgba(31, 76, 57, 0.6);
  border-radius: 12px;
  background: rgba(7, 20, 27, 0.85);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  white-space: nowrap;
}
th { color: #8effbe; }
h2 {
  margin-top: 4px;
  margin-bottom: 8px;
  color: #b2ffd0;
}
h3 {
  margin-top: 14px;
  color: #a4ffca;
}
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-form input[type="number"] {
  width: 90px;
}
.link-btn {
  display: inline-block;
  color: #8cffb9;
  text-decoration: none;
}
.link-btn:hover {
  text-decoration: underline;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 4px 10px 12px;
}
.tab-panel.active .book-top-grid .panel-card {
  margin-top: 0;
}
.tab-panel.active > .panel-card {
  margin-top: 8px;
}
.card-mock {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(7, 20, 27, 0.75);
}
.card-mock ul {
  margin: 8px 0 0 18px;
  color: var(--muted);
}
.dashboard-body .container::before {
  content: "";
  position: absolute;
  pointer-events: none;
}
.panel-card {
  background:
    linear-gradient(180deg, rgba(12, 29, 40, 0.85) 0%, rgba(7, 20, 27, 0.9) 100%);
  border: 1px solid rgba(31, 76, 57, 0.8);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
  min-width: 0;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 12px;
}
.book-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}
.book-grid > *,
.book-top-grid > * {
  min-width: 0;
}
.upload-zone {
  align-self: start;
}
.result-zone {
  min-height: 680px;
  display: flex;
  flex-direction: column;
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.drop-zone {
  border: 1px dashed rgba(93, 255, 151, 0.5);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  background: rgba(8, 21, 28, 0.7);
  color: #b9e7cf;
}
.drop-zone.dragover {
  border-color: rgba(93, 255, 151, 0.95);
  box-shadow: 0 0 0 2px rgba(93, 255, 151, 0.24);
  background: rgba(15, 34, 24, 0.6);
}
.drop-zone input[type="file"] {
  margin-top: 10px;
}
.ok-chip,
.bad-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: normal;
}
.ok-chip {
  background: rgba(41, 224, 125, 0.12);
  border: 1px solid rgba(41, 224, 125, 0.45);
  color: #adf7cc;
}
.bad-chip {
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.45);
  color: #ffbcbc;
}
.batch-edit {
  min-width: 120px;
  height: 32px;
  font-size: 12px;
  padding: 4px 8px;
}
.mono-sm {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
.chrome-tabs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 12px;
  border-bottom: none;
  padding: 0;
  overflow-x: auto;
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  z-index: 3;
}
.chrome-tab {
  border: 1px solid var(--line);
  border-bottom: 1px solid rgba(31, 76, 57, 0.92);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: linear-gradient(180deg, var(--tab) 0%, #0b1c25 100%);
  color: #b7dfca;
  height: 46px;
  padding: 0 14px;
  white-space: nowrap;
  margin-bottom: 0;
  position: relative;
  overflow: visible;
}
.chrome-tab.active {
  background: linear-gradient(180deg, rgba(var(--tone-rgb, 93,255,151), 0.22) 0%, rgba(5, 14, 20, 0.88) 100%);
  color: #d6ffea;
  border-color: rgba(var(--tone-rgb, 93,255,151), 0.75);
  border-bottom-color: transparent;
  box-shadow:
    inset 0 0 0 1px rgba(var(--tone-rgb, 93,255,151), 0.24),
    0 0 18px rgba(var(--tone-rgb, 93,255,151), 0.28);
  margin-bottom: -1px;
  z-index: 3;
}
.chrome-tab.active::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: -2px;
  height: 4px;
  background: linear-gradient(180deg, rgba(var(--tone-rgb, 93,255,151), 0.10) 0%, rgba(5, 14, 20, 0.94) 100%);
  pointer-events: none;
}
.tab-shell {
  margin-top: 20px;
  position: relative;
  border: none;
  background: transparent;
  box-shadow: none;
  padding-top: 60px;
  overflow: visible;
}
.tab-shell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 58px;
  bottom: 0;
  border: 1px solid rgba(var(--tone-rgb, 93,255,151), 0.72);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(var(--tone-rgb, 93,255,151), 0.08) 0%, rgba(5, 14, 20, 0.92) 120px, rgba(5, 14, 20, 0.88) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(var(--tone-rgb, 93,255,151), 0.14),
    0 0 22px rgba(var(--tone-rgb, 93,255,151), 0.18);
  pointer-events: none;
  z-index: 0;
}
.tab-shell .tab-panel {
  margin-top: 0;
  position: relative;
  z-index: 1;
}

.tab-shell.tone-book { --tone-rgb: 93, 255, 151; }
.tab-shell.tone-audio { --tone-rgb: 183, 123, 255; }
.tab-shell.tone-daw { --tone-rgb: 255, 217, 93; }
.pipeline-progress {
  border: 1px solid rgba(31, 76, 57, 0.9);
  background: rgba(6, 16, 24, 0.8);
  border-radius: 12px;
  padding: 12px;
  margin-top: 6px;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(18, 49, 36, 0.8);
  border: 1px solid rgba(31, 76, 57, 0.9);
}
.stop-form {
  margin: 0 0 8px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #15a55f 0%, #66ff9f 100%);
  box-shadow: 0 0 16px rgba(93, 255, 151, 0.45);
  transition: width 0.4s ease;
}
.progress-stats {
  margin-top: 8px;
  color: #9ec1ae;
  font-size: 12px;
}
.status-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(31, 76, 57, 0.8);
  color: #a6ffc9;
  background: rgba(12, 36, 24, 0.6);
  font-size: 12px;
  line-height: 1.1;
}
.max-h-table {
  max-height: 340px;
}
.chapter-links {
  display: grid;
  gap: 8px;
}
.chapter-links-large {
  margin-top: 10px;
  max-height: none;
  height: 100%;
  flex: 1 1 auto;
  overflow: auto;
  padding-right: 6px;
}
.chapter-link {
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border: 1px solid rgba(31, 76, 57, 0.8);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(11, 33, 22, 0.75) 0%, rgba(7, 20, 27, 0.9) 100%);
  color: #d9ffe9;
  padding: 10px 12px;
}
.chapter-link:hover {
  border-color: rgba(93, 255, 151, 0.7);
  box-shadow: 0 0 0 1px rgba(93, 255, 151, 0.22);
}
.chapter-num {
  font-size: 12px;
  color: #9bd6b4;
  font-weight: 700;
}
.chapter-title {
  font-size: 13px;
  color: #e2fff0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1120px) {
  .container {
    margin: 8px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 12px;
  }
  .book-top-grid,
  .book-grid {
    grid-template-columns: 1fr;
  }
  .result-zone {
    min-height: 0;
  }
  .chapter-links-large {
    max-height: 360px;
  }
}

@media (max-width: 700px) {
  .header-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .chrome-tabs {
    margin: 0 8px;
    top: 10px;
  }
  .chrome-tab {
    height: 40px;
    padding: 0 10px;
    font-size: 12px;
  }
  .tab-shell {
    margin-top: 16px;
    padding-top: 50px;
  }
  .tab-shell::before {
    top: 50px;
  }
  .tab-panel.active {
    padding: 8px;
  }
  .panel-card {
    padding: 10px;
  }
}
