* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1a1a1a;
}

#app {
  display: flex;
  height: 100vh;
}

#pdf-pane {
  flex: 1 1 60%;
  background: #525659;
}

#pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

#side-pane {
  flex: 0 0 600px;
  max-width: 600px;
  height: 100vh;
  overflow: hidden;
  padding: 14px;
  border-left: 1px solid #ccc;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Sections that stay on screen at all times (sized to their content). */
.side-fixed {
  flex: 0 0 auto;
}

/* Sections that get their own independent scrollbar and share the
   remaining vertical space roughly evenly (~40% each of the pane). */
.side-scroll {
  flex: 1 1 40%;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  padding: 8px 10px;
}

#nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

#nav-bar select {
  flex: 1;
  min-width: 0;
}

#progress-label {
  font-size: 0.85em;
  color: #555;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#match-summary {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

#match-summary summary {
  cursor: pointer;
  font-weight: 600;
}

.match-group {
  margin: 10px 0;
}

.match-group > h4 {
  margin: 4px 0;
  font-size: 0.95em;
}

.match-node {
  margin-left: 14px;
  font-size: 0.9em;
}

.match-node > summary {
  cursor: pointer;
}

.term-row {
  margin-left: 18px;
  font-size: 0.85em;
  color: #333;
  padding: 1px 0;
}

.term-row .term-total {
  color: #777;
}

.term-row a.page-link {
  margin-right: 5px;
  text-decoration: none;
  color: #1a5fb4;
}

.term-row a.page-link:hover {
  text-decoration: underline;
}

.no-hits {
  margin-left: 18px;
  color: #999;
  font-style: italic;
  font-size: 0.85em;
}

fieldset {
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 10px;
}

.annotation-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.annotation-row fieldset {
    min-width: 0;
}

/* Four equally-sized columns */
.annotation-row-4 fieldset {
    flex: 1;
}

/* Two equally-sized columns */
.annotation-row-2 fieldset {
    flex: 1;
}

legend {
  font-weight: 600;
  font-size: 0.85em;
  padding: 0 4px;
}

.radio-group label {
  margin-right: 2px;
  font-size: 0.7em;
}

#category-select, textarea {
  width: 100%;
}

.auto-hint {
  font-size: 0.8em;
  color: #777;
  font-style: italic;
  margin-bottom: 4px;
}

#action-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.action-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-item-right {
  justify-content: flex-end;
}

.action-item button {
  flex: 0 0 auto;
}

.action-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#save-status, #export-status {
  font-size: 0.85em;
  color: #555;
}

/* Login overlay -- shown before the app loads if no annotator is set */
#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#login-box {
  background: #fff;
  border-radius: 8px;
  padding: 32px 40px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

#login-box h2 {
  margin: 0 0 12px;
  font-size: 1.2em;
}

#login-box p {
  margin: 0 0 16px;
  color: #555;
  font-size: 0.9em;
  line-height: 1.5;
}

#login-form .login-input-row {
  display: flex;
  gap: 8px;
}

#login-name {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95em;
}

#login-error {
  margin: 8px 0 0;
  color: #c0392b;
  font-size: 0.85em;
  min-height: 1.2em;
}

/* Annotator badge in the nav bar */
#annotator-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82em;
  color: #555;
  white-space: nowrap;
  flex-shrink: 0;
}

#logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 1em;
  color: #888;
  line-height: 1;
}

#logout-btn:hover {
  color: #333;
}
