:root {
  --bg: #1b1714;
  --panel: #241f1b;
  --paper: #f4efe4;
  --paper2: #ebe4d4;
  --ink: #1c1612;
  --muted: #6d645b;
  --accent: #b85c38;
  --cream: #f3eadc;
  --ok: #1f6f5b;
  --sel: #b85c38;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--cream);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid #342e28;
}

.brand {
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  font-size: 12px;
  color: #cbbba8;
  font-weight: 400;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.tab-btn {
  border: none;
  background: #2c2622;
  color: var(--cream);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.top-actions button {
  border: none;
  background: #2c2622;
  color: var(--cream);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg);
}

.toolbar input,
.toolbar select {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #4a4038;
  background: #2a241f;
  color: var(--cream);
  font: inherit;
}

.toolbar input {
  min-width: 220px;
  flex: 1;
}

.count {
  margin-left: auto;
  color: #cbbba8;
  font-size: 13px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(360px, 1.2fr) minmax(340px, 1fr);
  gap: 0;
  min-height: 0;
}

.list-pane {
  overflow: auto;
  background: var(--bg);
  border-right: 1px solid #342e28;
}

#paper-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#paper-table th {
  position: sticky;
  top: 0;
  background: #2a241f;
  text-align: left;
  padding: 8px 6px;
  z-index: 1;
}

#paper-table td {
  padding: 7px 6px;
  border-bottom: 1px solid #2f2924;
  cursor: pointer;
}

#paper-table tr:hover td {
  background: #26211c;
}

#paper-table tr.selected td {
  background: var(--sel);
  color: #fff;
}

.detail-pane {
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 18px;
  border-right: 1px solid #d9d0c2;
}

.detail-pane h1 {
  font-size: 1.15rem;
  margin: 0 0 8px;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.detail-actions button,
#btn-save-note {
  border: none;
  background: #2c2622;
  color: var(--cream);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

#btn-fetch {
  background: var(--accent);
  color: #fff;
}

#btn-pdf {
  background: var(--ok);
  color: #f4fff9;
}

#btn-save-note.primary {
  background: var(--ok);
  color: #f4fff9;
  margin-top: 6px;
}

.prose h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}

.prose p,
.prose li {
  font-size: 13px;
  line-height: 1.55;
}

.prose ul {
  padding-left: 1.2rem;
}

.note-label {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
}

#d-note {
  width: 100%;
  margin-top: 4px;
  border: 1px solid #d9d0c2;
  border-radius: 4px;
  padding: 8px;
  font: inherit;
  resize: vertical;
  background: #fffaf3;
}

.pdf-pane {
  display: flex;
  flex-direction: column;
  background: var(--paper2);
  color: var(--ink);
  min-height: 0;
}

.pdf-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #d9d0c2;
  font-size: 13px;
}

#pdf-embed {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  background: #eae3d6;
  display: none;
}

#pdf-embed.visible {
  display: block;
}

.pdf-hint {
  margin: auto;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.harvest {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 12, 0.72);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.harvest.hidden {
  display: none;
}

.harvest-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #2a241f;
  color: var(--cream);
  border-radius: 8px;
  padding: 16px 18px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.harvest-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.harvest-card header button,
.harvest-actions button {
  border: none;
  background: #3a322c;
  color: var(--cream);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.harvest-note {
  color: #cbbba8;
  font-size: 13px;
  line-height: 1.5;
}

.harvest-drop {
  border: 1.5px dashed #b85c38;
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: #221c18;
}

.harvest-drop.busy {
  opacity: 0.6;
  pointer-events: none;
}

#harvest-status {
  min-height: 1.2em;
  font-size: 13px;
  color: #f3eadc;
}

#harvest-list {
  margin: 8px 0 12px;
  padding-left: 1.3rem;
  max-height: 42vh;
  overflow: auto;
  font-size: 13px;
  line-height: 1.45;
}

#harvest-list .ok {
  color: #b7e0c8;
}

#harvest-list .miss {
  color: #e7c07a;
}

footer#status {
  padding: 6px 14px;
  background: var(--panel);
  color: #cbbba8;
  font-size: 12px;
  border-top: 1px solid #342e28;
}

.hidden {
  display: none !important;
}

.file-ghost {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.whoami {
  font-size: 12px;
  color: #cbbba8;
  white-space: nowrap;
  padding: 0 6px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #14110f;
}

.login-card {
  width: min(380px, 92vw);
  background: #241f1b;
  color: var(--cream);
  border-radius: 10px;
  padding: 28px 26px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.login-sub,
.login-hint {
  color: #cbbba8;
  font-size: 13px;
}

.login-card label {
  display: block;
  font-size: 13px;
  margin: 10px 0;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #4a4038;
  background: #2a241f;
  color: var(--cream);
  font: inherit;
}

.login-submit {
  width: 100%;
  margin-top: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.form-error {
  color: #e7c07a;
  font-size: 13px;
}

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.harvest-doi {
  display: block;
  font-size: 13px;
  margin: 8px 0 12px;
  color: #cbbba8;
}

.harvest-doi input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #4a4038;
  background: #221c18;
  color: var(--cream);
  font: inherit;
}

.user-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.user-form button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid #3a322c;
}

.users-table button {
  border: none;
  background: #3a322c;
  color: var(--cream);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
    height: auto;
  }
  #app-shell {
    height: auto;
    min-height: 100vh;
  }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 40vh) auto minmax(280px, 50vh);
  }
  .pdf-pane {
    min-height: 50vh;
  }
  .toolbar input {
    min-width: 0;
  }
}
