:root {
  color-scheme: light;
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  --ink: #1e2a2f;
  --muted: #607178;
  --line: #d7e0df;
  --panel: #ffffff;
  --wash: #edf4f1;
  --accent: #176b5d;
  --accent-strong: #0f4c43;
  --earth: #b56b35;
  --bottom-nav-height: calc(64px + env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: var(--bottom-nav-height);
  color: var(--ink);
  background: linear-gradient(135deg, #f5f8f6 0%, #e9f1ef 55%, #f6efe9 100%);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: 100vh;
}

.app-shell:not(.map-shell) {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(12px);
}

.compact-shell {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.compact-shell:not(.map-shell) {
  grid-template-rows: minmax(0, 1fr);
}

.compact-shell .sidebar {
  gap: 0;
  min-height: 0;
  border-right: 0;
  padding: 18px 28px 6px;
  background: transparent;
  backdrop-filter: none;
}

.compact-shell .sidebar h1 {
  font-size: 28px;
}

h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-box {
  display: grid;
  gap: 12px;
}

.upload-box[hidden] {
  display: none;
}

.upload-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.teacher-only[hidden] {
  display: none;
}

.account-box {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.account-box strong,
.account-box span {
  display: block;
}

.account-box span {
  color: var(--muted);
  font-size: 13px;
}

.account-box button {
  min-height: 34px;
  padding: 0 12px;
  background: #4c5d63;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  width: min(430px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 40px rgba(31, 64, 58, 0.08);
}

.auth-mode-title {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.auth-alt-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auth-link-button,
.auth-secondary-button,
.auth-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
}

.auth-link-button {
  font-size: 14px;
}

.auth-secondary-button,
.auth-secondary-link {
  width: 100%;
  font-size: 14px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.auth-message {
  min-height: 22px;
  color: #a23d32;
  font-weight: 700;
}

.demo-accounts {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbfa;
}

.demo-accounts p {
  margin-top: 4px;
}

label,
.section-title {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

input {
  padding: 10px 12px;
}

textarea {
  min-height: 52px;
  max-height: 180px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.5;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: progress;
  opacity: 0.62;
}

.inline-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.inline-action:hover {
  background: var(--accent-strong);
}

.text-action {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.text-action:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.materials {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  font-size: 13px;
  list-style: none;
}

.materials li {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.material-swipe-content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  transition: transform 180ms ease;
}

.material-item.show-delete .material-swipe-content {
  transform: translateX(76px);
}

.material-delete-button {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 76px;
  border-radius: 0;
  padding: 0 10px;
  background: #b4473f;
}

.material-open-link {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}

.material-open-link:hover strong {
  color: var(--accent-strong);
  text-decoration: underline;
}

.material-download-link {
  margin-right: 10px;
  color: var(--accent-strong);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.material-download-link:hover {
  text-decoration: underline;
}

.materials strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.materials span {
  color: var(--muted);
  font-size: 12px;
}

.chat-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  font-size: 13px;
  background: rgba(248, 251, 250, 0.54);
  overflow-x: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 34px 24px 24px;
}

.message {
  display: flex;
  width: min(900px, 100%);
  min-width: 0;
  align-items: flex-end;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-stack {
  display: grid;
  width: auto;
  min-width: 0;
  max-width: min(680px, 78%);
  gap: 6px;
}

.message.user .message-stack {
  justify-items: end;
}

.message-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.message.user .message-label {
  color: var(--accent-strong);
}

.bubble {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(31, 64, 58, 0.08);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.assistant .bubble {
  border-color: #dce7e4;
  background: #fff;
}

.message.user .bubble {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 32px rgba(23, 107, 93, 0.18);
}

.bubble.markdown-body {
  white-space: normal;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre {
  margin: 0 0 10px;
}

.markdown-body p:last-child,
.markdown-body ul:last-child,
.markdown-body ol:last-child,
.markdown-body pre:last-child {
  margin-bottom: 0;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 4px 0 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body li {
  margin: 4px 0;
}

.markdown-body code {
  border-radius: 6px;
  padding: 1px 5px;
  background: #eef4f2;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fbfa;
}

.markdown-body img,
.markdown-body table {
  max-width: 100%;
}

.markdown-body table {
  display: block;
  overflow-x: auto;
}

.sources,
.sources div,
.sources li {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.sources div {
  margin-top: 6px;
}

.composer {
  display: grid;
  gap: 10px;
  width: min(900px, calc(100% - 48px));
  justify-self: center;
  margin: 0 0 24px;
  padding: 18px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 40px rgba(31, 64, 58, 0.08);
}

.composer textarea,
.composer input {
  font-size: 13px;
}

.gps-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 10px;
}

.question-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.nav-links {
  display: grid;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4000;
  width: 100vw;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 -12px 30px rgba(31, 64, 58, 0.1);
  transform: translateZ(0);
}

.nav-links a {
  display: block;
  border: 0;
  border-radius: 8px;
  padding: 9px 2px;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.nav-links a.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.records-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
  min-width: 0;
  padding: 28px;
  overflow-y: auto;
}

.record-form,
.record-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 40px rgba(31, 64, 58, 0.08);
}

.record-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.form-header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.form-header h2,
.detail-header h2 {
  margin: 0;
  font-size: 19px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.location-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fbfa;
}

.speech-panel,
.ai-organize-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
}

.ai-organize-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ai-organize-panel textarea {
  min-height: 120px;
  background: #fff;
}

.speech-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.speech-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.speech-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.speech-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.speech-status strong {
  color: var(--accent);
}

.speech-status span {
  color: var(--muted);
  line-height: 1.5;
}

.location-status strong {
  color: var(--accent);
}

.location-status span {
  color: var(--muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 8px;
}

.coordinate-panel {
  display: grid;
  gap: 10px;
}

.coordinate-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.coordinate-fields label {
  min-width: 0;
}

.record-form label,
.record-form .photo-panel,
.record-form .section-title,
.record-detail .section-title {
  font-size: 13px;
}

.location-action {
  display: flex;
  justify-content: flex-start;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  justify-content: flex-start;
}

.photo-status {
  color: var(--muted);
  font-size: 12px;
}

.photo-action-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.photo-action-button:hover {
  background: var(--accent-strong);
}

.photo-preview-list,
.record-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.photo-panel {
  display: grid;
  gap: 8px;
}

.photo-preview-item {
  position: relative;
  display: grid;
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fbfa;
}

.photo-preview-item img {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  border-radius: 6px;
  object-fit: cover;
  cursor: zoom-in;
}

.photo-note-input {
  min-height: 54px;
  max-height: 96px;
  padding: 8px 10px;
  background: #fff;
  font-size: 12px;
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(30, 42, 47, 0.72);
}

.camera-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.form-submit {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.location-action button,
.photo-actions button,
.photo-action-button,
.form-submit button {
  min-height: 42px;
}

.form-submit button {
  min-width: 160px;
}

.span-2 {
  grid-column: 1 / -1;
}

.attitude-tools {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
}

.attitude-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.attitude-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
}

.attitude-card header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.attitude-card label {
  display: grid;
  gap: 8px;
}

.photo-preview,
.record-photo {
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #f8fbfa;
}

.photo-preview {
  margin-top: 8px;
}

.record-photo {
  margin: 18px 0 4px;
}

.record-photo-grid {
  margin: 18px 0 4px;
}

.record-photo-item {
  display: grid;
  gap: 6px;
  margin: 0;
}

.record-photo-grid .record-photo {
  height: 160px;
  margin: 0;
  cursor: zoom-in;
}

.record-photo-item figcaption {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.record-detail {
  padding: 22px;
}

.record-detail[hidden] {
  display: none;
}

.empty-state {
  color: var(--muted);
  line-height: 1.7;
}

.record-list-item {
  cursor: pointer;
}

.record-list-item:hover {
  border-color: var(--accent);
}

.record-fields {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px 16px;
  font-size: 13px;
  margin: 20px 0;
}

.record-fields dt {
  color: var(--muted);
  font-weight: 700;
}

.record-fields dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.questions {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.questions ol {
  margin: 10px 0 0;
  padding-left: 22px;
  line-height: 1.7;
}

.my-records {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.my-record-row {
  position: relative;
  border-radius: 8px;
}

.record-list-actions,
.export-records-bar,
.export-records-bar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-records-bar {
  justify-content: space-between;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #f5f9f7;
  font-size: 13px;
  font-weight: 700;
}

.word-export-dialog {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 31, 34, 0.62);
}

.word-export-dialog[hidden] {
  display: none;
}

.word-export-panel {
  position: relative;
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(20, 42, 38, 0.24);
}

.word-export-panel h2 {
  margin: 0 34px 8px 0;
  font-size: 19px;
}

.word-export-panel p {
  overflow-wrap: anywhere;
}

.word-export-actions {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.word-dialog-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  min-height: 34px;
  border-radius: 50%;
  padding: 0;
  background: #61736e;
  font-size: 21px;
}

.record-export-selector {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 4;
  display: none;
  transform: translateY(-50%);
  cursor: pointer;
}

.record-export-selector input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.record-export-selector span {
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid #71817c;
  border-radius: 50%;
  background: #fff;
}

.record-export-selector input:checked + span {
  border: 6px solid var(--accent);
}

.my-records.export-mode .record-export-selector {
  display: block;
}

.my-records.export-mode .my-record-card {
  margin-left: 42px;
}

.my-record-row.selected-for-export .my-record-card {
  border-color: var(--accent);
  background: #f5faf8;
}

.my-record-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
}

.my-record-card.has-photo {
  grid-template-columns: 1fr;
}

.my-record-photo {
  flex: 0 0 min(68vw, 220px);
  width: min(68vw, 220px);
  height: 150px;
  min-height: 140px;
  border-radius: 8px;
  object-fit: cover;
  background: #f8fbfa;
}

.my-record-photo-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.my-record-photo-carousel .my-record-photo {
  scroll-snap-align: start;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(11, 24, 27, 0.84);
}

.photo-viewer[hidden] {
  display: none;
}

.photo-viewer img {
  max-width: min(100%, 980px);
  max-height: calc(100vh - 72px);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.photo-viewer-close {
  position: fixed;
  top: 14px;
  right: 14px;
  min-width: 42px;
  min-height: 42px;
  border-radius: 999px;
  padding: 0;
  background: rgba(180, 71, 63, 0.95);
  font-size: 24px;
}

.danger-button {
  background: #b4473f;
}

.danger-button:hover {
  background: #93362f;
}

.my-record-photo-wrap {
  position: relative;
  min-height: 140px;
}

.my-record-photo-wrap span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  background: rgba(30, 42, 47, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.my-record-body {
  display: grid;
  gap: 10px;
}

.my-record-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.my-record-title h3 {
  margin: 0;
  font-size: 18px;
}

.my-record-title span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.my-record-body p {
  margin: 0;
  line-height: 1.6;
}

.my-record-meta {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 6px 10px;
  margin: 0;
}

.my-record-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.my-record-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.map-shell {
  height: calc(100vh - var(--bottom-nav-height));
  grid-template-columns: 240px 1fr;
  min-height: 0;
}

.map-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 560px;
}

.map-tools {
  display: grid;
  gap: 8px;
}

.map-layer-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.map-layer-switch button {
  min-height: 36px;
  border: 1px solid var(--line);
  padding: 0 10px;
  color: var(--ink);
  background: #f8fbfa;
  font-size: 13px;
}

.map-layer-switch button:hover,
.map-layer-switch button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.map-layer-switch button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #eef3f1;
}

.map-metrics {
  display: grid;
  grid-template-columns: minmax(82px, 0.65fr) minmax(220px, 2.35fr);
  gap: 6px;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 6px 10px;
  background: #fff;
}

.map-metrics div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.map-metrics dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.map-metrics dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.map-coords-cell dd {
  white-space: nowrap;
}

.contour-elevation-tooltip {
  border: 1px solid rgba(61, 53, 44, 0.45);
  border-radius: 4px;
  padding: 3px 6px;
  color: #2f2923;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 10px rgba(31, 64, 58, 0.14);
  font-size: 12px;
  font-weight: 700;
}

.contour-elevation-label {
  border: 0;
  padding: 1px 3px;
  color: #4f321f;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  pointer-events: none;
}

.contour-elevation-label::before {
  display: none;
}

.attitude-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.attitude-readout div {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fbfa;
}

.attitude-readout span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.attitude-readout strong {
  color: var(--accent);
  font-size: 34px;
  letter-spacing: 0;
}

.layer-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 1024px) {
  body {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px 18px;
    gap: 18px;
  }

  .nav-links {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4000;
    width: 100vw;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--line);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
    box-shadow: 0 -12px 30px rgba(31, 64, 58, 0.1);
    transform: translateZ(0);
  }

  .nav-links a {
    border: 0;
    border-radius: 8px;
    padding: 9px 2px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    background: transparent;
  }

  .nav-links a.active {
    color: #fff;
    background: var(--accent);
  }

  .messages {
    width: 100%;
    min-width: 0;
    padding: 12px 10px 18px;
  }

  .message-stack {
    max-width: 92%;
  }

  .message {
    width: 100%;
    max-width: 100%;
  }

  .bubble {
    padding: 10px 11px;
  }

  .composer {
    width: calc(100% - 24px);
    margin-bottom: 16px;
    padding: 14px;
  }

  .gps-row,
  .question-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .coordinate-fields {
    grid-template-columns: 1fr;
  }

  .records-panel {
    padding: 10px 12px 18px;
  }

  .form-header,
  .detail-header {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .speech-actions button,
  .location-action button,
  .photo-actions button,
  .photo-action-button,
  .form-submit button {
    width: 100%;
  }

  .location-action,
  .form-submit {
    flex-direction: column;
    justify-content: stretch;
  }

  .inline-action {
    width: 100%;
  }

  .attitude-tools {
    display: grid;
  }

  .attitude-compare,
  .attitude-card {
    grid-template-columns: 1fr;
  }

  .attitude-card header {
    display: grid;
  }

  .speech-header {
    display: grid;
  }

  .record-fields {
    grid-template-columns: 1fr;
  }

  .attitude-readout {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .my-record-card.has-photo {
    grid-template-columns: 1fr;
  }

  .my-record-photo {
    height: 180px;
  }

  .my-record-title {
    display: grid;
  }

  .map-shell {
    height: calc(100vh - var(--bottom-nav-height));
    grid-template-rows: auto 1fr;
    min-height: 0;
    overflow: hidden;
  }

  .map-shell .sidebar {
    gap: 6px;
    padding: 6px 8px;
  }

  .map-shell .sidebar > div:first-child {
    display: none;
  }

  .map-tools {
    gap: 6px;
  }

  .map-tools > button {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  .map-metrics {
    grid-template-columns: minmax(58px, 0.65fr) minmax(170px, 2.35fr);
    gap: 4px;
    padding: 5px 8px;
  }

  .map-metrics div {
    gap: 1px;
    min-width: 0;
  }

  .map-metrics dt {
    overflow: hidden;
    font-size: 10px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-metrics dd {
    overflow: hidden;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-coords-cell dd {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  .map-panel {
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    height: 100%;
  }

  #map {
    min-height: 0;
    height: 100%;
  }
}
