:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17201d;
  background: #f4f7f5;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; min-width: 320px; background: #f4f7f5; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.topbar {
  flex: 0 0 64px;
  padding: 0 28px;
  background: #132b26;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand, .topbar-actions, .toolbar, .toolbar-actions, .dialog-header, .dialog-actions { display: flex; align-items: center; }
.brand { gap: 10px; }
.brand .brand-mark {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: 1px solid #5d8d82; color: #d3ece4; font-size: 11px; font-weight: 800;
  line-height: 1; text-align: center;
}
.brand strong, .brand span { display: block; }
.brand span { margin-top: 2px; color: #b9d1ca; font-size: 11px; }
.topbar-actions { gap: 10px; }
.user-email { max-width: 220px; overflow: hidden; color: #b9d1ca; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

main { width: min(100%, 1680px); min-height: 0; flex: 1; margin: 0 auto; padding: 24px 28px 20px; display: flex; flex-direction: column; }
.workspace-header { flex: 0 0 auto; display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 18px; }
.eyebrow { margin: 0 0 8px; color: #367668; text-transform: uppercase; font-size: 11px; font-weight: 800; }
h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
p { margin: 7px 0 0; color: #63706c; line-height: 1.5; }
.summary { display: flex; border: 1px solid #d9e2df; background: #fff; }
.summary div { width: 108px; padding: 12px 16px; border-left: 1px solid #e3eae7; }
.summary div:first-child { border-left: 0; }
.summary span, .summary small { display: block; }
.summary span { color: #173f37; font-size: 21px; font-weight: 750; }
.summary small { margin-top: 4px; color: #6f7b78; font-size: 11px; }

.tabs { flex: 0 0 auto; display: flex; gap: 22px; border-bottom: 1px solid #d9e2df; }
.tab { padding: 12px 2px; border: 0; border-bottom: 2px solid transparent; background: none; color: #687572; font-weight: 700; }
.tab.active { border-color: #2c7565; color: #1d5146; }
.tab-meta { margin-left: 5px; color: #85918e; font-size: 10px; font-weight: 700; }
.tab.active .tab-meta { color: #4d7d73; }
.tab-view { display: none; min-height: 0; padding-top: 18px; }
.tab-view.active { flex: 1; display: flex; flex-direction: column; }
.toolbar { flex: 0 0 auto; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 15px; }
.toolbar p { font-size: 13px; }
.toolbar-actions { align-items: end; gap: 8px; }
.selection-summary { color: #367668; font-size: 12px !important; font-weight: 700; }
.save-status { color: #6f7b78; font-size: 12px; font-weight: 700; white-space: nowrap; }
.focus-select { min-width: 170px; gap: 3px; }
.focus-select select { min-height: 38px; padding: 7px 9px; }

.button {
  min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 750; white-space: nowrap;
}
.button.primary { background: #246a5c; color: #fff; }
.button.primary:hover { background: #1a584c; }
.button.secondary { border-color: #cad7d3; background: #fff; color: #35534d; }
.topbar .button.secondary { border-color: #456d64; background: transparent; color: #e7f2ef; }
.file-button input { display: none; }
.status-badge, .risk {
  padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: uppercase;
}
.status-badge { background: #285148; color: #cbe1db; }

.review-layout {
  min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(280px, 360px) 1fr;
  border: 1px solid #d8e1de; background: #fff;
}
.review-list { min-height: 0; border-right: 1px solid #d8e1de; overflow-y: auto; overscroll-behavior: contain; }
.review-item { width: 100%; padding: 15px; border: 0; border-bottom: 1px solid #e5ebe9; background: #fff; text-align: left; cursor: pointer; }
.review-item:hover, .review-item.active { background: #eff7f4; }
.review-item.active { box-shadow: inset 3px 0 #2b7566; }
.review-meta { display: flex; justify-content: space-between; gap: 8px; color: #697672; font-size: 12px; }
.stars { color: #b17815; letter-spacing: 1px; }
.review-excerpt { margin-top: 9px; color: #2e3936; font-size: 13px; line-height: 1.45; }
.review-post-use { margin-top: 10px; display: flex; align-items: center; gap: 7px; color: #54716b; font-size: 11px; font-weight: 750; }
.review-post-use input { width: 14px; height: 14px; margin: 0; accent-color: #246a5c; }
.reply-only { color: #89938f; }
.review-detail { min-height: 0; padding: 24px; overflow-y: auto; overscroll-behavior: contain; }
.empty-state, .empty-detail { color: #71807c; font-size: 13px; }
.empty-state { padding: 22px; }
.empty-state.wide { border: 1px dashed #c7d5d1; background: #fff; }
.empty-detail { height: 100%; min-height: 220px; display: grid; place-content: center; justify-items: center; gap: 8px; }
.detail-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; border-bottom: 1px solid #e1e8e5; padding-bottom: 17px; }
.detail-head h2 { margin-bottom: 7px; }
.original-review { padding: 18px 0; color: #34403d; line-height: 1.6; }
.draft-box { padding: 18px; border: 1px solid #d8e1de; background: #f8faf9; }
.draft-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.draft-box textarea { width: 100%; min-height: 145px; border: 1px solid #cad7d3; background: #fff; padding: 12px; resize: vertical; line-height: 1.55; }
.draft-actions { display: flex; gap: 8px; margin-top: 12px; }
.rationale { margin-top: 12px; color: #6b7774; font-size: 12px; line-height: 1.5; }
.risk.low { background: #e3f5eb; color: #25714c; }
.risk.medium { background: #fff0cc; color: #8b6415; }
.risk.high { background: #fae3df; color: #a13d31; }

.post-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; overflow-y: auto; overscroll-behavior: contain; }
.source-summary { margin-top: 9px; color: #687572; font-size: 12px; line-height: 1.5; }
.source-summary strong { color: #35534d; }
.source-summary .source-warning { color: #9a5e14; font-weight: 750; }
.source-summary .button { min-height: 30px; margin-left: 8px; padding: 0 9px; font-size: 11px; vertical-align: middle; }
.post-card { min-height: 0; padding: 18px; border: 1px solid #d8e1de; background: #fff; display: flex; flex-direction: column; }
.post-label {
  min-height: 28px; color: #377668; font-size: 11px; font-weight: 800; text-transform: uppercase;
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.post-card h3 { min-height: 38px; margin: 8px 0 10px; font-size: 16px; }
.post-card textarea { width: 100%; min-height: 180px; flex: 1; padding: 10px; border: 1px solid #d6e0dd; resize: none; line-height: 1.55; color: #35413e; }
.post-footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 12px; color: #73807c; font-size: 11px; }

.profile-form { min-height: 0; width: 100%; flex: 1; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 15px; padding: 20px; border: 1px solid #d8e1de; background: #fff; overflow-y: auto; overscroll-behavior: contain; }
label { display: grid; gap: 7px; color: #475652; font-size: 12px; font-weight: 750; }
label.full { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid #cdd9d5; background: #fff; color: #283532; }
textarea { min-height: 100px; resize: vertical; }

dialog { width: min(540px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 32px)); border: 0; padding: 0; box-shadow: 0 18px 65px #0c2c2538; overflow: hidden; }
dialog::backdrop { background: #0d201c80; }
dialog form { max-height: min(720px, calc(100dvh - 32px)); display: grid; gap: 14px; padding: 20px; overflow-y: auto; }
.auth-dialog { width: min(420px, calc(100vw - 32px)); }
.auth-dialog::backdrop { background: #0d201ce6; }
.auth-dialog form { padding: 26px; }
.auth-message { min-height: 20px; color: #367668; font-size: 12px; font-weight: 700; }
.dialog-header, .dialog-actions { justify-content: space-between; gap: 10px; }
.dialog-header p { font-size: 12px; }
.dialog-actions { justify-content: end; margin-top: 5px; }
.icon-button { width: 32px; height: 32px; border: 0; background: transparent; color: #5b6965; font-size: 23px; }

@media (max-width: 760px) {
  .topbar { flex-basis: auto; min-height: 96px; padding: 12px 16px; align-items: center; gap: 12px; }
  .topbar-actions { flex-direction: column; align-items: end; }
  main { padding: 16px 14px 12px; }
  .workspace-header { align-items: start; flex-direction: column; gap: 14px; margin-bottom: 14px; }
  .summary { width: 100%; }
  .summary div { flex: 1; width: auto; padding: 10px; }
  .tabs { gap: 14px; overflow-x: auto; }
  .tab { font-size: 12px; white-space: nowrap; }
  .tab-view { padding-top: 14px; }
  #repliesView .toolbar { align-items: start; flex-direction: column; }
  #repliesView .toolbar-actions { flex-wrap: wrap; align-items: center; }
  .review-layout { min-height: 0; display: grid; grid-template-rows: minmax(120px, 34%) 1fr; grid-template-columns: 1fr; }
  .review-list { max-height: none; border-right: 0; border-bottom: 1px solid #d8e1de; }
  .review-detail { padding: 16px; }
  .empty-detail { min-height: 220px; }
  .post-grid, .profile-form { grid-template-columns: 1fr; }
  .post-card { min-height: 420px; }
  .post-card h3 { min-height: auto; }
  #postsView .toolbar { align-items: start; flex-direction: column; }
  #postsView .toolbar-actions { flex-wrap: wrap; align-items: end; }
  label.full { grid-column: auto; }
}
