:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #20262d;
  background: #f2f3f3;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { min-width: 320px; margin: 0; }
button, input, textarea { font: inherit; }

.auth-screen {
  position: fixed;
  z-index: 2000;
  top: 74px;
  right: 16px;
  width: min(380px, calc(100vw - 32px));
}
.auth-screen[hidden], .auth-name-field[hidden] { display: none; }
.auth-card {
  position: relative;
  display: grid;
  gap: 18px;
  width: 100%;
  max-height: calc(100dvh - 90px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid #aeb6bb;
  background: #fff;
  box-shadow: 4px 4px 0 #c5cbce;
}
.auth-brand { width: max-content; }
.auth-card h1 { margin: 0; font-size: 24px; }
.auth-card p { margin: 7px 0 0; color: #5c666e; line-height: 1.5; }
.auth-card .form-status { margin: -7px 0 0; color: #a23f32; }
.auth-close-button {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 32px;
  border: 0;
  color: #4f5a62;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
}
.auth-divider {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #7a858d;
  font-size: 11px;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  height: 1px;
  background: #d5dadd;
  content: "";
  flex: 1;
}
.google-login-button {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid #9ca5aa;
  color: #20262d;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}
.google-login-button:hover { background: #edf0f1; }
.google-mark { display: block; width: 28px; height: 28px; object-fit: contain; }
.auth-mode-button {
  padding: 0;
  border: 0;
  color: #246d5b;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
}
.auth-mode-button:hover { text-decoration: underline; }
.auth-terms-field {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: #4f5a62;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}
.auth-terms-field[hidden] { display: none; }
.auth-terms-field input { width: 17px; height: 17px; margin: 1px 0 0; flex: 0 0 auto; accent-color: #246d5b; }
.auth-terms-field a, .auth-legal-copy a { color: #1f6554; }
.auth-legal-copy { margin: -6px 0 0 !important; color: #68727a !important; font-size: 11px; line-height: 1.45 !important; }

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  padding: 0 20px;
  border-bottom: 1px solid #c9ced0;
  background: #fff;
}

.brand { display: flex; gap: 9px; align-items: center; color: #20262d; text-decoration: none; }
.brand__mark { display: block; width: 32px; height: 32px; }
.brand strong { font-size: 16px; letter-spacing: 0.01em; }
.location-count { color: #5c666e; font-size: 13px; }
.appbar__account { display: flex; gap: 14px; align-items: center; }
.appbar__account[hidden], .guest-actions[hidden] { display: none; }
.guest-actions { display: flex; gap: 8px; }
.guest-actions button {
  padding: 7px 10px;
  border: 1px solid #9ca5aa;
  color: #343d44;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.guest-actions button:last-child {
  border-color: #246d5b;
  color: #fff;
  background: #246d5b;
}
.guest-actions button:hover { filter: brightness(0.96); }
.current-user-name { font-size: 13px; font-weight: 700; }
.logout-button, .account-button {
  padding: 6px 9px;
  border: 1px solid #9ca5aa;
  color: #343d44;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.logout-button:hover, .account-button:hover { background: #edf0f1; }

.workspace { position: relative; height: calc(100dvh - 62px); min-height: 600px; }
.map-panel { position: relative; width: 100%; height: 100%; background: #dfe3e5; }
.map-panel.is-selecting #map { cursor: crosshair; }
#map { width: 100%; height: 100%; }

.map-actions {
  position: absolute;
  z-index: 500;
  top: 16px;
  left: 16px;
  display: flex;
  border: 1px solid #7d878e;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 16%);
}

.map-actions button, .selection-hint button, .save-button, .edit-button, .danger-button, .close-button {
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-weight: 700;
}

.map-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: #20262d;
  background: #fff;
}

.map-actions button + button { border-left: 1px solid #c9ced0; }
.map-actions button:hover { background: #edf0f1; }

.selection-hint {
  position: absolute;
  z-index: 500;
  top: 62px;
  left: 16px;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #8c969d;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 16%);
  font-size: 13px;
}
.selection-hint[hidden] { display: none; }
.selection-hint button { padding: 5px 8px; border: 1px solid #8c969d; color: #20262d; background: #fff; }

.side-panel {
  position: absolute;
  z-index: 700;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  overflow-y: auto;
  border-left: 1px solid #bfc7cb;
  background: #fff;
  box-shadow: -3px 0 14px rgb(0 0 0 / 14%);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.workspace.is-panel-open .side-panel { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid #d9dddf;
}
.panel-header h1 { margin: 0; font-size: 18px; }
.close-button { width: 32px; height: 32px; color: #4b555d; background: transparent; font-size: 25px; line-height: 1; }
.close-button:hover { background: #eef0f1; }

#locations-view, #form-view { padding: 16px; }
.locations-list { display: grid; border-top: 1px solid #d9dddf; }
.location-list-item {
  display: grid;
  gap: 4px;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid #d9dddf;
  color: #20262d;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.location-list-item:hover { background: #f3f5f5; }
.location-list-item strong { font-size: 14px; }
.location-list-item span { overflow: hidden; color: #68727a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { margin: 0; color: #68727a; font-size: 13px; }

.selection-status { margin: 0 0 18px; padding: 10px 12px; border-left: 3px solid #7a858d; color: #4f5a62; background: #f2f3f3; font-size: 13px; line-height: 1.4; }
.selection-status.is-selected { border-color: #246d5b; color: #174b3e; background: #eaf3ef; }
form { display: grid; gap: 15px; }
.field { display: grid; gap: 6px; }
label, summary { color: #343d44; font-size: 12px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid #aeb6bb; border-radius: 3px; outline: none; color: #20262d; background: #fff; }
input { height: 40px; padding: 0 10px; }
textarea { min-height: 104px; padding: 10px; resize: vertical; }
input:focus, textarea:focus { border-color: #246d5b; box-shadow: 0 0 0 2px rgb(36 109 91 / 16%); }

.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid #dfe2e4; border-bottom: 1px solid #dfe2e4; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: #246d5b; }
.check-row strong, .check-row small { display: block; }
.check-row strong { color: #343d44; font-size: 12px; }
.check-row small { margin-top: 3px; color: #68727a; font-size: 11px; }
.coordinate-details summary { cursor: pointer; user-select: none; }
.coordinate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.save-button { min-height: 42px; color: #fff; background: #246d5b; }
.save-button:hover { background: #1a5547; }
.save-button:disabled, .danger-button:disabled { cursor: wait; opacity: 0.65; }
.form-status { min-height: 16px; margin: -7px 0 0; color: #a23f32; font-size: 12px; }

.location-popup { max-height: min(520px, calc(100dvh - 150px)); overflow-y: auto; padding-right: 6px; color: #20262d; font-size: 15px; }
.location-popup h2 { margin: 0 0 7px; font-size: 23px; }
.location-popup p { margin: 7px 0; line-height: 1.45; }
.popup-label { margin-top: 12px !important; color: #69737b; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.conditions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.condition-card { padding: 8px; border: 1px solid #d5dadd; border-radius: 2px; background: #f8f9f9; }
.condition-card small, .condition-card strong { display: block; }
.condition-card small { color: #69737b; font-size: 9px; text-transform: uppercase; }
.condition-card strong { margin-top: 3px; font-size: 13px; }
.photo-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photo-gallery__item { min-width: 0; }
.photo-thumbnail { display: block; overflow: hidden; width: 100%; height: 72px; padding: 0; border: 1px solid #d5dadd; background: #f8f9f9; cursor: pointer; }
.photo-gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-thumbnail:hover { border-color: #246d5b; }
.empty-photo-gallery { color: #69737b; font-size: 12px; }
.remove-photo-button { width: 100%; margin-top: 3px; padding: 4px; border: 1px solid #b94b42; color: #9f3329; background: #fff; cursor: pointer; font-size: 10px; }
.remove-photo-button:hover { color: #fff; background: #a23f32; }
.photo-upload-form { gap: 8px; }
.photo-upload-form[hidden] { display: none; }
.show-photo-upload-button { width: 100%; min-height: 34px; margin-top: 10px; border: 1px solid #59656c; color: #20262d; background: #fff; cursor: pointer; font-weight: 700; }
.show-photo-upload-button:hover { background: #edf0f1; }
.photo-upload-form input[type="file"] { height: auto; padding: 7px; font-size: 12px; }
.upload-photo-button { min-height: 34px; border: 1px solid #246d5b; color: #174b3e; background: #fff; cursor: pointer; font-weight: 700; }
.upload-photo-button:hover { color: #fff; background: #246d5b; }
.upload-photo-button:disabled, .remove-photo-button:disabled { cursor: wait; opacity: 0.65; }
.photo-upload-status { min-height: 14px; margin: 0; color: #68727a; font-size: 11px; }
.danger-button { width: 100%; min-height: 36px; margin-top: 12px; border: 1px solid #b94b42; color: #9f3329; background: #fff; }
.danger-button:hover { color: #fff; background: #a23f32; }
.street-view-link { display: block; width: 100%; min-height: 36px; margin-top: 12px; padding: 9px; border: 1px solid #59656c; color: #20262d; background: #fff; cursor: pointer; font-weight: 700; text-align: center; text-decoration: none; }
.street-view-link:hover { background: #edf0f1; }
.edit-button { width: 100%; min-height: 36px; margin-top: 12px; border: 1px solid #246d5b; color: #174b3e; background: #fff; }
.edit-button:hover { color: #fff; background: #246d5b; }

.toast { position: fixed; z-index: 1000; right: 18px; bottom: 18px; max-width: 320px; padding: 11px 14px; border: 1px solid #7c858b; opacity: 0; color: #fff; background: #2a3137; box-shadow: 0 3px 12px rgb(0 0 0 / 22%); pointer-events: none; transform: translateY(8px); transition: opacity 150ms ease, transform 150ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.account-dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid #8f999f;
  background: #fff;
  box-shadow: 0 16px 55px rgb(0 0 0 / 34%);
}
.account-dialog:not([open]) { display: none; }
.account-dialog::backdrop { background: rgb(20 26 30 / 48%); }
.account-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #d5dadd;
}
.account-dialog__header h2 { margin: 5px 0 0; font-size: 22px; }
.account-dialog__kicker { margin: 0; color: #246d5b; font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.account-dialog__email { margin: 0; padding: 14px 20px; color: #536068; background: #f1f4f4; font-size: 13px; }
.account-section { padding: 20px; border-top: 1px solid #e0e4e6; }
.account-section h3 { margin: 0 0 7px; font-size: 16px; }
.account-section p { margin: 0 0 13px; color: #5b666e; font-size: 13px; line-height: 1.5; }
.account-action-link {
  display: block;
  padding: 10px 12px;
  border: 1px solid #246d5b;
  color: #174b3e;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.account-action-link:hover { color: #fff; background: #246d5b; }
.account-legal-links { display: flex; gap: 16px; flex-wrap: wrap; }
.account-legal-links a { color: #1f6554; font-size: 13px; font-weight: 700; }
.account-danger-zone { background: #fff8f7; }
.account-danger-zone button { width: 100%; min-height: 40px; border: 1px solid #b94b42; color: #9f3329; background: #fff; cursor: pointer; font-weight: 700; }
.account-danger-zone button:hover { color: #fff; background: #a23f32; }
.account-danger-zone button:disabled { cursor: wait; opacity: 0.65; }
.account-danger-zone .form-status { margin: 10px 0 0; }

.photo-viewer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; width: min(1000px, calc(100vw - 32px)); max-width: none; height: min(760px, calc(100dvh - 32px)); padding: 16px; border: 1px solid #59656c; background: #171c20; box-shadow: 0 18px 60px rgb(0 0 0 / 45%); }
.photo-viewer:not([open]) { display: none; }
.photo-viewer::backdrop { background: rgb(0 0 0 / 62%); }
.photo-viewer__figure { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; height: 100%; margin: 0; }
.photo-viewer__figure img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.photo-viewer__figure figcaption { padding-top: 10px; color: #fff; font-size: 13px; text-align: center; }
.photo-viewer__navigation, .photo-viewer__close { border: 0; color: #fff; background: transparent; cursor: pointer; }
.photo-viewer__navigation { width: 46px; height: 46px; font-size: 30px; }
.photo-viewer__navigation:disabled { cursor: default; opacity: 0.35; }
.photo-viewer__close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; font-size: 30px; }

@media (max-width: 820px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .appbar { height: 58px; padding: 0 12px; }
  .location-count, .current-user-name { display: none; }
  .auth-screen { top: 66px; right: 8px; width: calc(100vw - 16px); }
  .auth-card { max-height: calc(100dvh - 74px); padding: 20px; }
  .guest-actions { gap: 5px; }
  .guest-actions button { padding: 6px 7px; font-size: 11px; }
  .appbar__account { gap: 6px; }
  .account-button, .logout-button { padding: 6px 7px; font-size: 11px; }
  .workspace { height: calc(100dvh - 58px); min-height: 0; }
  .map-actions { top: 12px; left: 12px; }
  .selection-hint { top: 58px; left: 12px; }
  .side-panel {
    /* Leaflet places its zoom and attribution controls on layer 1000. */
    z-index: 1100;
    top: auto;
    right: 0;
    left: 0;
    width: auto;
    max-width: 100dvw;
    max-height: min(46dvh, 390px);
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
    border-top: 1px solid #bfc7cb;
    border-left: 0;
    transform: translateY(100%);
    box-shadow: 0 -3px 14px rgb(0 0 0 / 14%);
  }
  .side-panel.side-panel--form { max-height: 78dvh; }
  .workspace.is-panel-open .side-panel { transform: translateY(0); }
  .location-popup { max-height: calc(100dvh - 150px); }
  .photo-viewer { width: calc(100vw - 16px); height: calc(100dvh - 16px); padding: 8px; }
  .photo-viewer__navigation { width: 34px; font-size: 24px; }
  .account-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
}
