/* src/web/styles.css */
:root {
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light dark;
  --bg: #fafaf7;
  --panel: #fff;
  --border: #e5e5e0;
  --text: #1a1a1a;
  --muted: #6b6b66;
  --accent: #5865f2;
  --highlight: #fff4a3;
  --comment: #b6e3ff;
  --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --buncss-light: ;
    --buncss-dark: initial;
    --bg: #16161a;
    --panel: #1f1f23;
    --border: #2c2c33;
    --text: #f1f1ee;
    --muted: #8a8a85;
    --highlight: #4d4422;
    --comment: #1f3a55;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button:disabled {
  opacity: .5;
  cursor: default;
}

.topbar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  justify-content: space-between;
  align-items:  center;
  padding: 12px 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.topbar .user {
  display: flex;
  color: var(--muted);
  align-items:  center;
  gap: 10px;
}

.topbar .user img {
  border-radius: 50%;
  width: 28px;
  height: 28px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.list-empty, .loading {
  text-align: center;
  color: var(--muted);
  padding: 80px 16px;
}

.essay-row {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 16px 18px;
}

.essay-row:hover {
  border-color: var(--accent);
}

.essay-row .title {
  font-weight: 600;
}

.essay-row .meta {
  color: var(--muted);
  margin-top: 2px;
  font-size: .85rem;
}

.status-pill {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 999px;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: .75rem;
}

.status-ready {
  color: #1f8a4c;
  background: #1f8a4c20;
}

.status-transcribing {
  color: #b87800;
  background: #f0a52030;
}

.status-failed {
  color: #c0392b;
  background: #c0392b20;
}

.status-pending {
  color: var(--muted);
  background: #88888830;
}

.essay-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  align-items:  flex-start;
  gap: 24px;
}

@media (width <= 880px) {
  .essay-grid {
    grid-template-columns: 1fr;
  }
}

.transcript-panel, .side-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.transcript {
  white-space: pre-wrap;
  position: relative;
  font-size: 1rem;
  line-height: 1.7;
}

.transcript .hl {
  background: var(--highlight);
  border-radius: 2px;
  padding: 0 1px;
}

.transcript .cm {
  background: var(--comment);
  cursor: pointer;
  border-radius: 2px;
  padding: 0 1px;
}

.transcript .cm[data-active="true"] {
  outline: 2px solid var(--accent);
}

.images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.images-preview img {
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 120px;
  max-height: 160px;
}

.selection-toolbar {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  z-index: 10;
  border-radius: 8px;
  gap: 6px;
  padding: 6px;
  box-shadow: 0 4px 14px #00000026;
}

.annotation {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.annotation.active {
  border-color: var(--accent);
}

.annotation .quote {
  color: var(--muted);
  border-left: 3px solid var(--accent);
  white-space: pre-wrap;
  margin-bottom: 8px;
  padding-left: 8px;
  font-size: .85rem;
}

.annotation .body {
  white-space: pre-wrap;
}

.annotation .meta {
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items:  center;
  margin-bottom: 6px;
  font-size: .78rem;
}

.annotation .reply {
  background: #0000000a;
  border-radius: 6px;
  margin-top: 8px;
  padding: 8px;
}

@media (prefers-color-scheme: dark) {
  .annotation .reply {
    background: #ffffff0d;
  }
}

.annotation textarea {
  font: inherit;
  border: 1px solid var(--border);
  color: inherit;
  resize: vertical;
  background: none;
  border-radius: 6px;
  width: 100%;
  min-height: 60px;
  padding: 6px;
}

.annotation .actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.annotation .delete-btn {
  color: var(--danger);
  border-color: var(--danger);
  background: none;
}

.error-box {
  background: var(--panel);
  border: 1px solid var(--border);
  text-align: center;
  border-radius: 10px;
  max-width: 480px;
  margin: 60px auto;
  padding: 40px;
}
