:root {
  color-scheme: light;
  --paper: #f4f0e6;
  --ink: #24251f;
  --muted: #73705f;
  --moss: #4f6f52;
  --fern: #708c57;
  --rose: #c35d67;
  --gold: #d5a03a;
  --line: rgba(36, 37, 31, 0.16);
  --white: #fffdf8;
  --shadow: 0 18px 50px rgba(57, 61, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(213, 160, 58, 0.18), transparent 28rem),
    linear-gradient(135deg, #f4f0e6 0%, #e8eadf 42%, #f8eadf 100%);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.panel-heading,
.actions,
.status-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: env(safe-area-inset-top) 0 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--rose);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 6vw, 4.8rem);
  line-height: 0.9;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.05;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
}

.capture-panel,
.result-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.capture-panel {
  position: relative;
  min-height: 640px;
  padding: 26px;
  overflow: hidden;
}

.result-panel,
.history-panel {
  padding: 22px;
}

.history-panel {
  grid-column: 1 / -1;
}

.leaf-mark {
  position: absolute;
  inset: auto -80px -150px auto;
  width: 340px;
  height: 500px;
  border-radius: 52% 48% 50% 50% / 62% 62% 38% 38%;
  background: linear-gradient(150deg, rgba(79, 111, 82, 0.22), rgba(112, 140, 87, 0.04));
  transform: rotate(22deg);
  pointer-events: none;
}

.capture-copy {
  max-width: 520px;
  position: relative;
  z-index: 1;
}

.capture-copy p:last-child,
.empty-state,
.result-card p {
  color: var(--muted);
  line-height: 1.65;
}

.preview-frame {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 480px);
  aspect-ratio: 4 / 5;
  margin: 24px auto;
  border: 1px solid rgba(79, 111, 82, 0.22);
  border-radius: 8px;
  background: #fbfaf4;
  overflow: hidden;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.primary-action input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.primary-action,
.secondary-action,
.save-button,
.icon-text-button,
.ghost-button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-action,
.save-button,
.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  background: var(--ink);
  color: var(--white);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-weight: 800;
}

.secondary-action,
.ghost-button,
.icon-button {
  padding: 0 16px;
  background: rgba(255, 253, 248, 0.82);
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 46px;
  padding: 0;
  font-size: 1.35rem;
}

button:hover,
.primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(36, 37, 31, 0.12);
}

.status-grid {
  margin-top: 18px;
}

.status-grid div {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.56);
}

.status-grid span,
.notes-label,
.history-meta {
  display: block;
  color: var(--muted);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.78rem;
}

.status-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.result-card {
  display: grid;
  gap: 16px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(195, 93, 103, 0.26);
  border-radius: 8px;
  background: #fffaf5;
}

.confidence {
  float: right;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(213, 160, 58, 0.2);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-weight: 800;
}

.result-card h3 {
  margin-bottom: 3px;
  font-size: 1.8rem;
}

.result-card ul {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.result-card li {
  padding-left: 16px;
  border-left: 3px solid var(--fern);
}

.suggestions-list {
  display: grid;
  gap: 8px;
}

.suggestion-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  text-align: left;
}

.suggestion-option strong,
.suggestion-option span {
  overflow-wrap: anywhere;
}

.suggestion-option span {
  color: var(--muted);
  font-size: 0.86rem;
}

.suggestion-option em {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  color: var(--moss);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-style: normal;
  font-weight: 800;
}

.suggestion-option.is-active {
  border-color: rgba(79, 111, 82, 0.55);
  background: rgba(112, 140, 87, 0.13);
}

textarea {
  width: 100%;
  margin: 8px 0 14px;
  padding: 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  color: var(--ink);
}

.save-button {
  width: 100%;
}

.proximity-card {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.proximity-card h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.proximity-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.proximity-controls label,
.proximity-controls div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.56);
}

.proximity-controls select {
  width: 100%;
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.proximity-controls strong {
  display: block;
  margin-top: 6px;
}

.nearby-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.nearby-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(79, 111, 82, 0.35);
  border-radius: 8px;
  background: rgba(112, 140, 87, 0.12);
  color: var(--ink);
  text-align: left;
}

.nearby-item span {
  color: var(--moss);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-weight: 800;
  white-space: nowrap;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 14px;
  margin-top: 18px;
}

.map-canvas {
  position: relative;
  min-height: 360px;
  border: 1px solid rgba(79, 111, 82, 0.24);
  border-radius: 8px;
  background: #dfe7d9;
  overflow: hidden;
}

.map-frame,
.map-pin-layer,
.map-fallback {
  position: absolute;
  inset: 0;
}

.map-frame {
  width: 100%;
  height: 100%;
  border: 0;
  filter: saturate(0.85) contrast(0.96);
}

.map-pin-layer {
  pointer-events: none;
}

.map-fallback {
  display: block;
  inset: auto 12px 12px 12px;
  padding: 24px;
  border: 1px solid rgba(36, 37, 31, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--ink);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.4;
  pointer-events: none;
  z-index: 1;
}

.map-canvas:not(.is-offline) .map-fallback {
  display: none;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.map-pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 24px;
  height: 24px;
  border: 3px solid var(--white);
  border-radius: 50% 50% 50% 0;
  background: var(--rose);
  box-shadow: 0 10px 22px rgba(36, 37, 31, 0.24);
  transform: translate(-50%, -100%) rotate(-45deg);
  cursor: pointer;
  pointer-events: auto;
  z-index: 3;
}

.map-pin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.map-pin.is-active {
  background: var(--moss);
  transform: translate(-50%, -100%) rotate(-45deg) scale(1.18);
  z-index: 2;
}

.map-detail {
  min-height: 360px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.68);
}

.map-detail img {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
  border-radius: 6px;
  object-fit: cover;
  background: #efe9dc;
}

.map-detail h3 {
  margin-bottom: 4px;
  font-size: 1.35rem;
}

.map-detail p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--ink);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.danger-action {
  color: #9f3440;
}

.edit-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.edit-form input,
.edit-form textarea {
  width: 100%;
  margin: 6px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.8);
  color: var(--ink);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manage-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(2, minmax(130px, 0.7fr)) minmax(132px, auto) repeat(3, auto);
  gap: 10px;
  align-items: end;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.52);
}

.search-field,
.date-field {
  display: grid;
  gap: 6px;
}

.search-field input,
.date-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--ink);
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--ink);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.86rem;
  font-weight: 800;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--moss);
}

.history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-family: Avenir, "Gill Sans", sans-serif;
  font-size: 0.84rem;
}

.history-summary span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.62);
}

.history-summary strong {
  color: var(--ink);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.history-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.66);
  cursor: pointer;
}

.history-item.is-active {
  border-color: rgba(79, 111, 82, 0.55);
  box-shadow: 0 10px 24px rgba(79, 111, 82, 0.16);
}

.history-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
  background: #efe9dc;
}

.history-item h3 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.history-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
  }

  main,
  .history-list,
  .map-layout,
  .manage-bar {
    grid-template-columns: 1fr;
  }

  .capture-panel {
    min-height: auto;
    padding: 20px;
  }

  .actions,
  .status-grid,
  .proximity-controls {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .map-canvas,
  .map-detail {
    min-height: 280px;
  }
}
