:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #dbe1ea;
  --text: #102037;
  --muted: #4b5c74;
  --brand: #0b5fff;
  --warn: #d23f00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  background: radial-gradient(circle at top right, #eaf0ff, var(--bg) 55%);
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  display: grid;
  gap: 12px;
  width: min(440px, 92vw);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.left-actions,
.config-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

.sidebar {
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 12px;
  background: #fdfefe;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 18px;
}

#book-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

#book-tree li {
  margin-bottom: 8px;
}

.reader-area {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 0;
}

.reader-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.reader-title {
  padding: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.reader-content {
  overflow: auto;
  padding: 18px;
  line-height: 1.85;
}

.chapter-list {
  margin: 0;
  padding: 10px 16px;
  list-style: decimal;
  border-top: 1px solid var(--line);
  background: #f7f9fd;
}

.chapter-list li {
  cursor: pointer;
  margin-bottom: 6px;
}

dialog {
  width: min(1100px, 96vw);
  max-height: 88vh;
  border: 1px solid var(--line);
  border-radius: 12px;
}

dialog::backdrop {
  background: rgba(11, 19, 37, 0.35);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.task-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fff;
}

.task-row .head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  border-radius: 6px;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--line);
}

.badge.high {
  color: #fff;
  border-color: var(--warn);
  background: var(--warn);
}

.badge.medium {
  color: #fff;
  border-color: #c78100;
  background: #c78100;
}

.badge.low {
  color: #fff;
  border-color: #1f8a3a;
  background: #1f8a3a;
}

.error {
  color: var(--warn);
}

.log-detail {
  background: #0d1b2e;
  color: #d4e1f4;
  padding: 10px;
  border-radius: 8px;
  min-height: 150px;
  max-height: 240px;
  overflow: auto;
}

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

  .sidebar {
    position: fixed;
    inset: 52px auto 0 0;
    width: min(82vw, 320px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 6px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .task-form {
    grid-template-columns: 1fr;
  }

  .reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
  }
}
