:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #172b39;
  background: #f3f6f8;
  --muted: #526675;
  --line: #d9e2e9;
  --accent: #135e59;
  --accent-dark: #104b47;
  --surface: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, select, a { touch-action: manipulation; }
button, input, select, textarea {
  border: 1px solid #aebfc9;
  border-radius: 6px;
  color: inherit;
  background: var(--surface);
  padding: 8px 10px;
}
button { cursor: pointer; white-space: nowrap; min-height: 38px; font-weight: 600; }
button:hover:not(:disabled) { background: #edf5f4; border-color: var(--accent); }
button:disabled { cursor: default; opacity: .52; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #2772b3;
  outline-offset: 2px;
}
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.text-link { color: var(--accent-dark); text-underline-offset: 3px; font-size: .89rem; font-weight: 600; }
.page-width { max-width: 1640px; margin-inline: auto; padding-inline: clamp(14px, 3vw, 42px); }
.topbar { color: #f7fbfc; background: #173842; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
.topbar p { margin-top: 4px; color: #c9dcdf; font-size: .89rem; }
.building-select, .topbar-actions, .account { display: flex; gap: 6px; align-items: center; }
.topbar-actions { gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.account { gap: 8px; font-size: .86rem; }
.account button { background: transparent; color: #fff; border-color: #64808a; }
.account button:hover:not(:disabled) { color: #173842; }
.building-select button { background: transparent; color: #f7fbfc; border-color: #64808a; min-width: 55px; }
.building-select button[aria-pressed="true"], .building-select button:hover:not(:disabled) {
  background: #e5f3ed; color: #113d39; border-color: #e5f3ed;
}
.toolbar, .location-controls, .button-group, .map-footer, .card-head, .editor-actions { display: flex; align-items: center; }
.toolbar { justify-content: space-between; gap: 12px; padding-block: 18px; flex-wrap: wrap; }
.location-controls, .button-group { gap: 8px; flex-wrap: wrap; }
.location-controls label { color: var(--muted); font-size: .88rem; font-weight: 600; }
.location-controls a { margin-inline-start: 4px; }
.notice { border: 1px solid #b4d6cc; background: #ebf8f2; color: #124c3d; padding: 10px 13px; margin-bottom: 14px; border-radius: 6px; }
.notice.failure { color: #872b2b; background: #fff1f0; border-color: #edc9c5; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(330px, 1fr); gap: 16px; padding-bottom: 28px; align-items: start; }
.card { min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; overflow: hidden; }
.card-head { padding: 13px 15px; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
h2 { font-size: 1.08rem; }
.square { min-width: 38px; line-height: 1; font-size: 1.12rem; }
.map-viewport { position: relative; height: clamp(320px, 58vh, 730px); overflow: auto; border-block: 1px solid var(--line); background: #eaf0f3; }
.map-empty { min-height: 100%; padding: 24px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.map-scene { position: relative; width: 100%; }
.map-scene.placing { cursor: crosshair; }
.map-scene img { display: block; width: 100%; height: auto; user-select: none; }
.markers { position: absolute; inset: 0; pointer-events: none; }
.map-scene.placing .marker { pointer-events: none; }
.marker {
  position: absolute; transform: translate(-50%, -50%); z-index: 1; pointer-events: auto;
  min-width: 28px; min-height: 28px; padding: 3px 6px; border-radius: 999px;
  border: 2px solid white; background: #ae4636; color: white; font-size: .73rem;
  box-shadow: 0 1px 5px #172b3977;
}
.marker:hover:not(:disabled) { z-index: 3; background: #743123; border-color: white; }
.marker.working { background: #a45b11; }
.marker.closed { background: #27634e; }
.marker.draft { z-index: 4; background: #265eab; }
.map-footer { min-height: 62px; padding: 9px 15px; justify-content: space-between; gap: 9px; }
.map-footer span, .summary, .editor-head span, .editor-marker span { color: var(--muted); font-size: .84rem; }
.filters { padding: 3px 15px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.filters input[type="search"] { width: 100%; min-width: 0; }
.check-label { display: flex; align-items: center; gap: 5px; grid-column: 1 / -1; color: var(--muted); font-size: .87rem; }
.check-label input { accent-color: var(--accent); }
.summary { padding: 3px 15px 9px; }
.findings { max-height: 63vh; overflow: auto; min-height: 125px; }
.empty-journal { color: var(--muted); padding: 17px 15px 26px; border-top: 1px solid var(--line); }
.finding {
  display: grid; gap: 5px; width: 100%; border: 0; border-top: 1px solid var(--line);
  border-radius: 0; padding: 12px 15px; text-align: left; white-space: normal; font-weight: 400;
}
.finding .finding-heading { font-weight: 650; overflow-wrap: anywhere; }
.finding .metadata { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: .81rem; }
.badge { font-weight: 600; border-radius: 4px; padding: 3px 6px; color: #902f24; background: #ffede8; }
.badge.working { color: #784408; background: #fff1d9; }
.badge.closed { color: #1b5c44; background: #e4f4eb; }
.editor { padding: 8px 15px 15px; display: grid; gap: 11px; }
.editor-head { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; }
.editor h3 { font-size: 1rem; }
.editor label { display: grid; gap: 5px; font-size: .88rem; font-weight: 600; min-width: 0; }
.editor label :is(input, select, textarea) { width: 100%; min-width: 0; font-weight: 400; }
.editor textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.input-action, .editor-marker { display: flex; align-items: center; gap: 8px; }
.editor-marker { justify-content: space-between; }
.editor-actions { justify-content: flex-end; gap: 8px; }
.error { color: #9b3026; font-size: .88rem; }
.sign-in { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 410px); padding: 24px; display: grid; gap: 13px; }
.login-card label { display: grid; gap: 5px; font-weight: 600; }
.login-card p:not(.error) { color: var(--muted); }
.sources { margin: 0 0 12px; color: var(--muted); font-size: .89rem; }
.sources summary { cursor: pointer; font-weight: 650; }
.source-list { border-left: 2px solid var(--line); padding: 8px 14px; display: grid; justify-items: start; gap: 6px; }
.journal-tabs { display: flex; gap: 7px; padding: 0 15px 10px; }
.journal-tabs button[aria-pressed="true"] { color: var(--accent-dark); background: #e5f3ed; border-color: #9fbfb7; }
.line-search { padding: 2px 15px 8px; }
.line-search input { display: block; width: 100%; }
.line-info { margin: 0 15px 10px; padding: 10px; background: #eef6f4; border: 1px solid #c5dcd5; border-radius: 6px; display: grid; gap: 7px; }
.line-info p { overflow-wrap: anywhere; }
.line-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.editor-summary { padding: 0; }
.photo-report { display: grid; gap: 7px; }
.photo-report > button { justify-self: start; }
.photos { display: flex; gap: 7px; flex-wrap: wrap; }
.photos:empty { display: none; }
.photos img { display: block; width: 76px; height: 58px; border-radius: 4px; border: 1px solid var(--line); object-fit: cover; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .findings { max-height: 46vh; }
}
