:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #f0f4f2;
  --border: #d8dedb;
  --text: #18211d;
  --muted: #65726d;
  --accent: #0f7b62;
  --accent-strong: #075844;
  --warning: #a15d00;
  --shadow: 0 10px 30px rgb(33 45 40 / 8%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary,
.section-heading button {
  background: #fff;
  color: var(--accent);
}

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

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 82px;
  padding: 18px 24px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.health-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
}

.health-badge.ok {
  background: #e6f5ef;
  border-color: #a7d9c7;
  color: var(--accent-strong);
}

.health-badge.error {
  background: #fff2e4;
  border-color: #e8bc83;
  color: var(--warning);
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 320px) minmax(260px, 380px) minmax(380px, 1fr);
  min-height: 0;
  padding: 16px;
}

.sidebar,
.notes-column,
.viewer-column {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.sidebar,
.notes-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.upload-panel {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 10px;
  padding: 16px;
}

.upload-panel label {
  font-size: 13px;
  font-weight: 800;
}

.upload-row {
  display: grid;
  gap: 8px;
}

input[type="file"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  min-height: 38px;
  padding: 7px;
  width: 100%;
}

.message {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.section-heading {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 54px;
  padding: 12px 16px;
}

.file-list,
.note-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 12px;
}

.file-button,
.note-button {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.file-button:hover,
.note-button:hover,
.file-button.active,
.note-button.active {
  background: var(--panel-strong);
  border-color: #b4c3bd;
}

.item-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item-meta,
.item-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.item-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  justify-items: center;
  min-height: 120px;
  text-align: center;
}

.viewer-column {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.viewer-header {
  border-bottom: 1px solid var(--border);
  min-height: 74px;
  padding: 16px;
}

#viewerTitle {
  overflow-wrap: anywhere;
}

#viewerMeta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
}

#noteFrame {
  background: #fff;
  border: 0;
  height: 100%;
  width: 100%;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(240px, 320px) 1fr;
    grid-template-rows: minmax(220px, 36vh) 1fr;
  }

  .viewer-column {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(420px, 1fr);
    padding: 10px;
  }

  .viewer-column {
    grid-column: auto;
  }
}
