:root {
  --ink: #13272a;
  --muted: #66787a;
  --paper: #fffdfa;
  --canvas: #f1f0e9;
  --line: #d9ddd7;
  --accent: #d9653b;
  --accent-dark: #b84d28;
  --green: #245c55;
  --green-dark: #173f3a;
  --soft-green: #e6eeea;
  --danger: #9b312e;
  --shadow: 0 12px 36px rgba(20, 43, 43, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 0%, rgba(217,101,59,.10), transparent 25rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { width: min(100%, 860px); margin: 0 auto; min-height: 100vh; background: rgba(255,255,255,.26); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  background: rgba(241,240,233,.93);
  border-bottom: 1px solid rgba(19,39,42,.08);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 12px 12px 12px 3px;
  font: 700 21px/1 Georgia, serif;
}

.brand-copy { flex: 1; }
.brand-copy h1 { margin: 1px 0 0; font: 700 22px/1 Georgia, serif; letter-spacing: -.02em; }
.eyebrow, .kicker { font-size: 10px; font-weight: 800; letter-spacing: .17em; color: var(--accent-dark); }

.project-menu-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  height: 42px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}
.project-menu-button svg { width: 18px; height: 18px; }
.floating-project-button { display: none; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { padding: 26px 18px 132px; }
.view { display: none; }
.view.active { display: block; animation: fadeUp .25s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 2px 2px 22px; }
.hero-row h2, .report-toolbar h2 { margin: 4px 0 0; font: 700 clamp(28px, 7vw, 42px)/1.08 Georgia, serif; letter-spacing: -.035em; }
.kicker { margin: 0; }

.status-pill {
  flex: none;
  padding: 8px 10px;
  background: var(--soft-green);
  color: var(--green-dark);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.status-pill span { display: inline-block; width: 7px; height: 7px; background: var(--green); border-radius: 50%; margin-right: 5px; }

.project-card, .observation-card {
  background: var(--paper);
  border: 1px solid rgba(19,39,42,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.project-card { margin-bottom: 30px; overflow: hidden; }
.project-card summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 18px; }
.project-card summary::-webkit-details-marker { display: none; }
.project-card summary > span { display: flex; gap: 12px; align-items: center; }
.project-card summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.project-card summary svg { transition: transform .2s; }
.project-card[open] summary svg { transform: rotate(180deg); }
.section-number { color: var(--accent); font: 700 13px/1 Georgia, serif; letter-spacing: .1em; }

.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 18px 20px; }
.field { display: grid; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field span, .comment-field span { font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field input, .comment-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.field input { height: 46px; padding: 0 13px; }
.field input:focus, .comment-field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(36,92,85,.11); }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 3px 14px; }
.section-heading > div { display: flex; gap: 11px; align-items: baseline; }
.section-heading h3 { margin: 0; font: 700 21px/1.2 Georgia, serif; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 750; font-size: 12px; padding: 10px 0 10px 10px; }

.empty-state {
  min-height: 310px;
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  padding: 38px 28px;
  border: 1px dashed #bdc6c0;
  border-radius: var(--radius);
  background: rgba(255,255,255,.45);
}
.empty-state[hidden] { display: none; }
.empty-illustration { width: 74px; height: 62px; color: var(--green); opacity: .82; }
.empty-illustration svg { width: 100%; height: 100%; stroke-width: 2; }
.empty-state h3 { margin: 12px 0 4px; font: 700 21px/1.2 Georgia, serif; }
.empty-state p { max-width: 310px; margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.primary-button, .secondary-button, .danger-button {
  border: 0;
  min-height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  font-weight: 760;
  cursor: pointer;
}
.primary-button { color: white; background: var(--green); box-shadow: 0 7px 18px rgba(36,92,85,.22); }
.primary-button:active { background: var(--green-dark); transform: translateY(1px); }
.secondary-button { color: var(--green-dark); background: var(--soft-green); }
.danger-button { color: white; background: var(--danger); }

.observation-list { display: grid; gap: 18px; }
.observation-card { overflow: hidden; }
.photo-section { background: #dfe4df; padding: 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px; background: #cbd3cd; }
.photo-tile:first-child:nth-last-child(1) { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.observation-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-number { position: absolute; left: 8px; top: 8px; min-width: 25px; height: 25px; padding: 0 7px; display: grid; place-items: center; border-radius: 999px; color: white; background: rgba(19,39,42,.8); font: 700 11px Georgia, serif; }
.photo-actions { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 5px; }
.photo-actions button { border: 0; border-radius: 8px; min-height: 30px; padding: 0 9px; color: white; background: rgba(19,39,42,.82); font-size: 10px; font-weight: 750; }
.photo-actions .remove-photo { background: rgba(122,31,28,.86); font-size: 17px; line-height: 1; }
.add-photos-button { width: 100%; min-height: 44px; margin-top: 9px; border: 1px dashed #91a29a; border-radius: 10px; background: rgba(255,255,255,.54); color: var(--green-dark); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; font-weight: 760; }
.add-photos-button svg { width: 18px; height: 18px; }
.observation-body { padding: 16px; }
.observation-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.observation-label { margin: 0; font-weight: 800; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.timestamp { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.order-controls { display: flex; gap: 5px; }
.order-controls button { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid var(--line); background: white; color: var(--green-dark); border-radius: 9px; }
.order-controls button:disabled { opacity: .3; }
.order-controls .delete-entry { color: var(--danger); }
.order-controls svg { width: 17px; height: 17px; }
.comment-field { display: grid; gap: 7px; }
.comment-field textarea { padding: 12px; min-height: 92px; line-height: 1.45; resize: vertical; }
.comment-tools { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; }
.dictate-button { border: 0; color: var(--green); background: var(--soft-green); min-height: 38px; padding: 0 12px; border-radius: 9px; display: inline-flex; align-items: center; gap: 7px; font-weight: 750; font-size: 12px; }
.dictate-button.listening { color: white; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(217,101,59,.12); } }
.dictate-button svg { width: 17px; height: 17px; }
.character-count { color: var(--muted); font-size: 10px; }
.add-another-wrap { margin-top: 18px; }
.add-another-wrap .secondary-button { width: 100%; border: 1px dashed #aebcb6; background: transparent; }

.bottom-bar {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  width: min(100%, 860px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px max(13px, env(safe-area-inset-bottom));
  background: rgba(255,253,250,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(15px);
}
.save-status { color: var(--muted); font-size: 10px; line-height: 1.2; }
.save-status span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #6da174; }
.save-status.saving span { background: var(--accent); }
.review-button { min-height: 48px; display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 12px; background: var(--accent); color: white; font-weight: 800; padding: 0 17px; }
.review-button:disabled { background: #b5b8b2; }
.review-button svg { width: 18px; height: 18px; }

.report-toolbar { display: grid; grid-template-columns: auto 1fr; gap: 15px; align-items: center; margin-bottom: 20px; }
.back-button { width: 51px; height: 51px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; background: white; color: var(--green); font-size: 0; }
.report-paper { background: white; box-shadow: var(--shadow); border: 1px solid var(--line); padding: clamp(24px, 6vw, 58px); }
.report-cover { padding-bottom: 26px; border-bottom: 3px solid var(--green); }
.report-brand { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.report-cover h3 { margin: 12px 0 5px; font: 700 clamp(30px, 7vw, 48px)/1.05 Georgia, serif; letter-spacing: -.04em; }
.report-address { color: var(--muted); margin: 0; }
.report-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 27px; }
.report-meta div { border-top: 1px solid var(--line); padding-top: 9px; }
.report-meta span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.report-meta strong { display: block; margin-top: 4px; font: 700 15px Georgia, serif; }
.report-section-title { margin: 32px 0 14px; display: flex; align-items: center; gap: 10px; font: 700 20px Georgia, serif; }
.report-section-title span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: white; background: var(--green); font: 700 11px/1 Georgia, serif; }
.report-item { break-inside: avoid; border: 1px solid var(--line); margin-bottom: 22px; }
.report-item img { display: block; width: 100%; max-height: 430px; object-fit: cover; }
.report-item-copy { padding: 16px; }
.report-item-copy strong { color: var(--accent-dark); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.report-item-copy p { margin: 8px 0 0; line-height: 1.55; white-space: pre-wrap; }
.report-empty-note { color: var(--muted); font-style: italic; }
.report-footer { border-top: 1px solid var(--line); margin-top: 34px; padding-top: 12px; color: var(--muted); font-size: 10px; }
.report-actions { text-align: center; padding: 22px 0 0; }
.report-actions { display: grid; gap: 10px; }
.report-actions .primary-button, .report-actions .secondary-button { width: 100%; }
.report-actions p { color: var(--muted); font-size: 12px; margin: 3px 0 0; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 98px; transform: translate(-50%, 15px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 11px 15px; border-radius: 10px; font-size: 12px; transition: .25s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { width: min(calc(100% - 34px), 410px); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 25px 80px rgba(10,25,25,.28); }
dialog::backdrop { background: rgba(14,34,35,.55); backdrop-filter: blur(3px); }
dialog form { padding: 24px; }
dialog h3 { margin: 6px 0; font: 700 25px Georgia, serif; }
dialog p:not(.kicker) { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.dialog-title-row { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; padding: 0 4px; }
.project-actions { display: grid; gap: 9px; margin-top: 20px; }
.project-actions button { width: 100%; }
.plain-danger-button { min-height: 46px; border: 0; background: transparent; color: var(--danger); font-weight: 750; }

@media (min-width: 680px) {
  main { padding-left: 34px; padding-right: 34px; }
  .observation-card { display: grid; grid-template-columns: minmax(280px, .9fr) 1fr; }
  .observation-body { padding: 22px; }
}

@media (max-width: 679px) {
  .topbar { position: relative; }
  .floating-project-button:not([hidden]) {
    position: fixed;
    z-index: 20;
    top: max(14px, env(safe-area-inset-top));
    right: 20px;
    display: flex;
    background: rgba(255,255,255,.96);
    box-shadow: 0 8px 22px rgba(19,39,42,.18);
  }
  main { padding-bottom: 100px; }
  .bottom-bar { width: auto; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); padding: 0; background: none; border: 0; backdrop-filter: none; box-shadow: none; }
  .bottom-bar .save-status { display: none; }
  .review-button { min-height: 52px; padding: 0 22px; box-shadow: 0 8px 22px rgba(19,39,42,.24); white-space: nowrap; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

.bottom-bar[hidden] { display: none; }

@media print {
  body { background: white; }
  .topbar, .floating-project-button, .bottom-bar, .report-toolbar, .report-actions { display: none !important; }
  main { padding: 0; }
  .app-shell { width: 100%; }
  .view { display: none !important; }
  #reportView.active { display: block !important; }
  .report-paper { border: 0; box-shadow: none; padding: 0; }
}

/* Project storage and account surfaces */
.menu-group { margin: 18px 0; padding: 18px; border: 1px solid #c4d8dd; border-left: 4px solid #26788a; border-radius: 12px; }
.menu-group h4, .my-reports h4 { margin: 0; font-size: 1.05rem; }
.menu-group p { font-size: .9rem; line-height: 1.5; }
.device-group { border-color: #d4d7dc; border-left-color: #687282; }
.account-group { background: #edf6f8; }
button:disabled { opacity: .5; cursor: not-allowed; }
a.text-button { text-decoration: none; }
.account-page { padding: 34px clamp(18px, 5vw, 42px) 90px; }
.account-page[hidden] { display: none; }
.account-page-head, .section-title-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.account-page-head h2 { font: 700 clamp(30px, 5vw, 42px)/1.1 Georgia, serif; margin: 8px 0; }
.account-page-head p:last-child { color: var(--muted); margin: 0; }
.account-page-head .secondary-button { text-decoration: none; white-space: nowrap; }
.account-section { margin-top: 28px; padding: 26px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.account-section h3 { margin: 0; font: 700 23px Georgia, serif; }
.account-section p { color: var(--muted); line-height: 1.5; }
#templateUploadForm { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; margin-top: 22px; }
#templateUploadForm .field { min-width: 0; }
#templateUploadForm input[type=file] { width: 100%; padding: 9px; background: white; border: 1px solid var(--line); border-radius: 9px; }
#templateUploadForm button { min-height: 46px; }
.template-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.template-row div:first-child { min-width: 0; overflow-wrap: anywhere; }
.template-row small { display: block; color: var(--muted); margin-top: 5px; }
.template-actions { display: flex; gap: 12px; flex: none; }
.template-help { font-size: 14px; padding-top: 6px; }
#templatesStatus[data-error=true] { color: var(--danger); }
.template-menu-group { background: #edf6f8; }
.template-menu-group select { display: block; width: 100%; min-height: 44px; margin-top: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: white; color: var(--ink); font: inherit; }
.template-menu-group label { display: block; margin-top: 12px; font-weight: 700; }
.template-menu-group a { color: var(--green-dark); font-weight: 700; }
.template-guest { opacity: .68; }
.template-guest a { opacity: 1; }
#templateMember[hidden], #templateGuest[hidden] { display: none; }
#signInOptions { display: grid; gap: 12px; }
#signInOptions[hidden], #signOutLink[hidden] { display: none; }
#signInOptions .primary-button, #signInOptions .secondary-button { width: 100%; min-height: 48px; display: grid; place-items: center; text-align: center; text-decoration: none; }
#signOutLink { display: inline-block; margin-top: 18px; }
.my-reports { margin-top: 28px; }
.saved-report { padding: 16px 0; border-top: 1px solid var(--line); display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.saved-report div { min-width: 0; overflow-wrap: anywhere; }
.saved-report small { display: block; margin-top: 6px; color: #52606b; }
#reportsStatus[data-error="true"], #cloudSaveStatus[data-error="true"] { color: #a52929; }
@media(max-width: 720px) { #templateUploadForm { grid-template-columns: 1fr; } }
@media(max-width: 540px) { .account-page-head { align-items: flex-start; } .account-page-head .secondary-button { font-size: 13px; } .account-section { padding: 19px; } .template-row { align-items: flex-start; flex-direction: column; gap: 8px; } }
#accountIdentity { margin: 18px 0 0; }
#signInOptions { display: grid; gap: 12px; margin-top: 20px; }
#signInOptions > p:first-child { margin: 0 0 8px; }
#signInOptions .primary-button, #signInOptions .secondary-button { width: 100%; min-height: 48px; display: grid; place-items: center; }
#signInOptions #googleStatus { margin: 0; font-size: 14px; }
#signInOptions[hidden], #signOutLink[hidden] { display: none; }
#signInOptions a { text-align: center; text-decoration: none; }
.my-reports { margin-top: 26px; border-top: 1px solid #d4d7dc; padding-top: 22px; }
.my-reports .dialog-title-row { min-height: 40px; }
.my-reports .text-button { padding: 8px; font-size: 14px; }
.my-reports > p { margin: 12px 0 0; }
#reportsStatus:empty { display: none; }
#signOutLink { display: inline-block; margin-top: 18px; }
.saved-report { padding: 16px 0; border-bottom: 1px solid #d4d7dc; display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.saved-report div { min-width: 0; overflow-wrap: anywhere; }
.saved-report small { display: block; margin-top: 6px; color: #52606b; }
#reportsStatus[data-error="true"], #cloudSaveStatus[data-error="true"] { color: #a52929; }
#accountIdentity, #accountState { overflow-wrap: anywhere; }
@media(max-width: 540px) { .topbar { flex-wrap: wrap; } #manageAccountButton { margin-left: auto; } .saved-report { align-items: flex-start; } }
@media(max-width: 540px) { #accountDialog .project-menu-dialog { padding: 22px 20px; } }

main[hidden], #manageAccountButton[hidden], #projectMenuButton[hidden], #floatingProjectButton[hidden] { display: none !important; }
.account-page-head { align-items: flex-start; }
.account-page .field span { font-size: 14px; letter-spacing: 0; text-transform: none; }
.account-page .field input { min-height: 46px; }
@media(max-width:540px) { .account-page-head { flex-wrap: wrap; } .account-page-head .secondary-button { width: 100%; text-align: center; } }
