:root {
  --ink: #101010;
  --paper: #f7f5f0;
  --sheet: #ffffff;
  --line: #1b1b1b;
  --thin-line: #cfcfcf;
  --blue: #d8ebff;
  --red: #f4c9c6;
  --green: #dcefd7;
  --yellow: #ffe9a8;
  --muted: #6d6d6d;
  --accent: #7d1f2f;
  --sidebar-width: 330px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #e8e6df;
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid #bbb;
  background: #191919;
  color: #fff;
}

.sidebar-header {
  padding: 18px 18px 12px;
}

.viewer-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.viewer-tabs a {
  flex: 1;
  padding: 8px 9px;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e6e6e6;
  background: #272727;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.viewer-tabs a.active,
.viewer-tabs a:hover {
  border-color: #9d4051;
  color: #fff;
  background: var(--accent);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.sidebar-header p {
  margin: 7px 0 0;
  color: #d6d6d6;
  font-size: 14px;
}


.search-label {
  display: block;
  margin: 0 18px 6px;
  color: #d9d9d9;
  font-size: 13px;
}

.search-input {
  width: calc(100% - 36px);
  margin: 0 18px 12px;
  padding: 9px 11px;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  background: #080808;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 0 12px 12px;
}

.filter-button {
  min-height: 34px;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e6e6e6;
  background: #272727;
  cursor: pointer;
}

.filter-button.active,
.filter-button:hover {
  color: #fff;
  border-color: #9d4051;
  background: var(--accent);
}

.character-list {
  flex: 1;
  overflow: auto;
  padding: 0 8px 12px;
}

.character-item {
  display: block;
  width: 100%;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid #333;
  color: #f7f7f7;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.character-item:hover,
.character-item.active {
  background: #3a1520;
}

.character-name {
  display: block;
  font-weight: 700;
  line-height: 1.2;
}

.character-meta,
.character-path {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #c8c8c8;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer {
  min-width: 0;
  padding: 18px;
  overflow: auto;
}

.empty-state {
  max-width: 620px;
  margin: 12vh auto;
  padding: 28px;
  border: 1px solid #d0ccc1;
  border-radius: 6px;
  background: var(--paper);
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: #555;
}

.hidden {
  display: none !important;
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 12px;
}

.sheet-toolbar h2 {
  margin: 0;
  font-size: 26px;
}

.sheet-toolbar p {
  margin: 4px 0 0;
  color: #595959;
  font-size: 14px;
}

.source-link {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid #222;
  border-radius: 4px;
  color: #fff;
  background: #111;
  text-decoration: none;
}

.sheet-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr 0.7fr 0.95fr;
  gap: 0;
  min-width: 1160px;
  max-width: 1560px;
  border: 4px solid #000;
  background: #000;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.sheet-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #000;
}

.sheet-column + .sheet-column {
  border-left: 4px solid #000;
}

.section {
  margin: 0;
  border-bottom: 4px solid #000;
  background: var(--sheet);
}

.section:last-child {
  border-bottom: 0;
}

.section-title {
  min-height: 28px;
  padding: 3px 8px;
  color: #fff;
  background: #000;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: underline;
  text-transform: uppercase;
}

.section-title.plain {
  text-decoration: none;
}

.cell-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.cell-table th,
.cell-table td {
  min-height: 31px;
  padding: 5px 6px;
  border: 1px solid var(--thin-line);
  font-size: 19px;
  line-height: 1.15;
  vertical-align: top;
}

.cell-table th {
  color: #fff;
  background: #000;
  font-weight: 700;
  text-align: center;
}

.label {
  text-decoration: underline;
}

.center {
  text-align: center;
}

.right {
  text-align: right;
}

.italic {
  font-style: italic;
}

.small {
  font-size: 13px !important;
}

.blue {
  background: var(--blue);
}

.red {
  background: var(--red);
}

.green {
  background: var(--green);
}

.yellow {
  background: var(--yellow);
}

.muted-fill {
  background: #eeeeee;
}

.identity-table td {
  height: 32px;
  text-align: center;
}

.notes-box,
.concept-box,
.good-box {
  min-height: 168px;
  padding: 16px;
  border: 1px solid var(--thin-line);
  background: var(--yellow);
  font-size: 18px;
}

.notes-box {
  min-height: 390px;
  background: #fff;
}

.good-box {
  min-height: 96px;
}

.empty-row {
  height: 32px;
}

.footer-note {
  grid-column: 1 / -1;
  padding: 6px 10px;
  color: #fff;
  background: #000;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: 48vh;
    border-right: 0;
    border-bottom: 1px solid #bbb;
  }

  .viewer {
    padding: 12px;
  }

  .sheet-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
