:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  color: #314a3d;
  background: #eef1ed;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  height: 100dvh;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
  background: #eef1ed;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  color: #f7faf7;
  background: #395b4c;
  box-shadow: 0 2px 12px rgb(37 66 51 / 24%);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 52%);
  border-radius: 12px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  background: rgb(255 255 255 / 12%);
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0.04em;
}

.brand p {
  margin-top: 2px;
  color: #d6e2d9;
  font-size: 11px;
}

.tool-strip {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tool-strip::-webkit-scrollbar { display: none; }

.workspace-mode {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgb(255 255 255 / 26%);
  border-radius: 11px;
  background: rgb(16 48 32 / 18%);
}

.mode-button,
.help-button {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  color: #dce9df;
  font-weight: 720;
  background: transparent;
}

.mode-button { padding: 6px 9px; }

.mode-button.is-active {
  color: #294c3b;
  background: #eef4ef;
}

.help-button {
  display: grid;
  width: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 34%);
  font-size: 18px;
  line-height: 1;
}

.mode-button:hover,
.mode-button:focus-visible,
.help-button:hover,
.help-button:focus-visible {
  background: rgb(255 255 255 / 14%);
}

.mode-button.is-active:hover,
.mode-button.is-active:focus-visible { background: #ffffff; }

body[data-workspace-mode="map"] .tool-strip,
body[data-workspace-mode="notes"] .tool-strip { display: none; }

body[data-workspace-mode="map"] .pdf-button { margin-left: auto; }

body[data-workspace-mode="map"] #undoLine,
body[data-workspace-mode="map"] #redoLine { display: none; }

body[data-workspace-mode="notes"] .pdf-button { display: none; }

.tool-button,
.pdf-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #e7f0e9;
  font-weight: 650;
  white-space: nowrap;
  background: transparent;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tool-button:hover,
.tool-button:focus-visible {
  background: rgb(255 255 255 / 12%);
}

.tool-button.is-active {
  color: #294c3b;
  background: #dce9df;
}

.pdf-button {
  flex: 0 0 auto;
  color: #315442;
  background: #e0ece3;
}

.pdf-button:hover,
.pdf-button:focus-visible {
  background: #cbded0;
  transform: translateY(-1px);
}

.workspace {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 385px);
  overflow: hidden;
}

body[data-workspace-mode="notes"] .workspace {
  display: block;
  overflow: auto;
}

body[data-workspace-mode="notes"] .map-panel,
body[data-workspace-mode="notes"] .side-panel { display: none; }

.map-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 16px 12px 11px 16px;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #b9d2dd;
  border-radius: 18px;
  background: linear-gradient(145deg, #d4e9f1, #f1f8fa 60%, #dcecf2);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 76%), 0 8px 24px rgb(48 91 112 / 13%);
}

#mapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.map-status {
  position: absolute;
  top: 14px;
  left: 50%;
  max-width: min(80%, 520px);
  padding: 8px 12px;
  transform: translateX(-50%);
  border: 1px solid rgb(63 116 138 / 25%);
  border-radius: 999px;
  color: #3b667a;
  font-size: 13px;
  text-align: center;
  background: rgb(255 255 255 / 86%);
  box-shadow: 0 2px 8px rgb(44 77 95 / 11%);
  pointer-events: none;
}

.map-status.is-hidden { display: none; }

.map-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  overflow: hidden;
  border: 1px solid #c4d4c8;
  border-radius: 11px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 3px 12px rgb(40 70 53 / 16%);
}

.map-controls button {
  min-width: 40px;
  min-height: 38px;
  border: 0;
  border-right: 1px solid #d8e2da;
  color: #365b47;
  font-size: 18px;
  background: transparent;
}

.map-controls button:last-child {
  min-width: 52px;
  border-right: 0;
  font-size: 13px;
  font-weight: 700;
}

.map-controls button:hover { background: #edf4ee; }

.map-utility-controls {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  gap: 5px;
}

.map-utility-controls button {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #c4d4c8;
  border-radius: 9px;
  color: #365b47;
  font-size: 12px;
  font-weight: 720;
  background: rgb(255 255 255 / 93%);
  box-shadow: 0 3px 12px rgb(40 70 53 / 12%);
}

.map-utility-controls button:hover:not(:disabled),
.map-utility-controls button[aria-pressed="true"] {
  border-color: #86a992;
  color: #315b42;
  background: #e0ece3;
}

.map-utility-controls button:disabled {
  cursor: default;
  opacity: 0.48;
}

.map-hint {
  min-height: 23px;
  margin: 8px 5px 0;
  color: #62766a;
  font-size: 12px;
}

.side-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 16px 12px;
  background: #f6f7f5;
  box-shadow: -4px 0 18px rgb(44 72 55 / 8%);
  scrollbar-gutter: stable;
}

.all-notes-view {
  min-height: 100%;
  padding: 26px max(28px, env(safe-area-inset-right)) 34px max(28px, env(safe-area-inset-left));
  background: #f6f7f5;
}

.all-notes-view[hidden] { display: none; }

.all-notes-shell {
  width: min(100%, 980px);
  margin: 0 auto;
}

.all-notes-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.all-notes-header h2 {
  margin: 0;
  color: #365744;
  font-size: clamp(21px, 2.4vw, 28px);
}

.all-notes-header .compact-copy {
  max-width: 620px;
  margin-bottom: 0;
}

.panel-card {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid #d9e2da;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(41 67 51 / 5%);
}

.card-heading,
.section-heading,
.group-row,
.note-actions,
.filter-actions,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: #728078;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

h2,
h3,
p { overflow-wrap: anywhere; }

.card-heading h2,
.section-heading h3 {
  margin: 0;
  color: #365744;
}

.card-heading h2 { font-size: 17px; }
.section-heading h3 { font-size: 14px; }

.object-kind {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: #5f7166;
  font-size: 11px;
  font-weight: 700;
  background: #e7ece7;
}

.object-details { margin-top: 13px; }

.empty-state,
.compact-copy,
.data-note,
.field-help {
  color: #697a70;
  font-size: 12px;
  line-height: 1.55;
}

.empty-state { margin: 0; }
.compact-copy { margin: 7px 0 10px; }
.data-note { margin: 14px 7px 0; }
.field-help { margin: 5px 0 0; }

.field { margin: 12px 0; }

.field label,
.field-label {
  display: block;
  margin-bottom: 5px;
  color: #496555;
  font-size: 12px;
  font-weight: 740;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cad7ce;
  border-radius: 9px;
  color: #314a3d;
  background: #fbfcfa;
}

input,
select { min-height: 36px; padding: 7px 9px; }

textarea {
  min-height: 76px;
  padding: 9px;
  line-height: 1.45;
  resize: vertical;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgb(81 134 97 / 34%);
  outline-offset: 1px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 720;
}

.primary-button { color: #fff; background: #4d7b60; }
.primary-button:hover { background: #3d6850; }
.secondary-button { color: #3c654d; border-color: #c8d7cb; background: #f3f7f3; }
.secondary-button:hover { background: #e6efe8; }
.danger-button { color: #a14845; border-color: #eccbc8; background: #fff7f6; }
.danger-button:hover { background: #feecea; }
.text-button { min-height: 29px; padding: 4px 6px; color: #4b7d60; background: transparent; }
.text-button:hover { text-decoration: underline; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  color: #456a52;
  font-size: 11px;
  background: #e4eee6;
}

.note-list { display: grid; gap: 9px; margin-top: 10px; }

.note-card {
  padding: 10px;
  border: 1px solid #d9e4da;
  border-radius: 10px;
  background: #fbfcfa;
}

.note-card h4 {
  margin: 0;
  color: #466751;
  font-size: 12px;
}

.note-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.legacy-badge {
  padding: 3px 6px;
  border-radius: 999px;
  color: #68776d;
  font-size: 10px;
  font-weight: 700;
  background: #edf1ed;
}

.note-content {
  margin: 8px 0 0;
  color: #405b4b;
  font-size: 13px;
  line-height: 1.65;
  white-space: normal;
}

.detail-block { margin-top: 12px; }

.line-color-readonly {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #405b4b;
  font-size: 13px;
}

.line-color-field { margin-top: 14px; }

.line-color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.line-color-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid #cedbd1;
  border-radius: 8px;
  color: #4b6253;
  font-size: 11px;
  font-weight: 700;
  background: #fbfcfa;
}

.line-color-option:hover { background: #f0f6f1; }

.line-color-option.is-active {
  border-color: #5d8a6a;
  color: #335b42;
  background: #e7f0e8;
  box-shadow: inset 0 0 0 1px rgb(82 126 95 / 18%);
}

.line-color-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 1px solid rgb(35 55 43 / 24%);
  border-radius: 50%;
  background: var(--line-color);
}

.area-component-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 10px;
}

.completion-controls {
  margin-top: 16px;
  padding: 10px;
  border: 1px solid #d6e4d9;
  border-radius: 10px;
  background: #f5f9f5;
}

.completion-controls .field-help { margin-bottom: 0; }

.note-card textarea { min-height: 60px; margin-top: 7px; }
.note-card input { margin-top: 7px; }
.note-actions { margin-top: 7px; }

.ink-preview {
  display: block;
  width: 100%;
  height: 100px;
  margin-top: 7px;
  border: 1px solid #d8e4da;
  border-radius: 8px;
  background: repeating-linear-gradient(0deg, #fdfefd, #fdfefd 24px, #eef5ef 25px);
}

.draw-mode-note {
  margin: 8px 0 0;
  padding: 8px;
  border-radius: 8px;
  color: #3e6a4d;
  font-size: 12px;
  line-height: 1.45;
  background: #e6f0e8;
}

.group-members {
  max-height: 130px;
  margin: 9px 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid #d9e4da;
  border-radius: 9px;
  color: #4d6c57;
  font-size: 12px;
  line-height: 1.55;
  background: #fbfcfa;
}

.filter-card-details { width: 100%; }

.filter-card-details > summary {
  display: block;
  position: relative;
  padding-right: 22px;
  cursor: pointer;
  list-style: none;
}

.filter-card-details > summary::-webkit-details-marker { display: none; }

.filter-card-details > summary .section-heading { width: 100%; }

.filter-card-details > summary::after {
  position: absolute;
  top: 50%;
  right: 0;
  color: #668071;
  content: "⌄";
  font-size: 16px;
  line-height: 1;
  transform: translateY(-50%);
}

.filter-card-details[open] > summary::after { content: "⌃"; }

.filter-card-body { padding-top: 8px; }

.filter-actions { justify-content: flex-start; margin-top: 10px; }

.filter-summary {
  margin: 9px 0 0;
  color: #4d7659;
  font-size: 11px;
  line-height: 1.45;
}

.filter-sections { display: grid; gap: 8px; }

.all-notes-filters {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d9e2da;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(41 67 51 / 5%);
}

.all-notes-sort { margin: 0; }

.all-notes-filter-block {
  min-width: 0;
}

.all-notes-filter-block .field-label { margin: 0 0 5px; }

.memo-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
}

.memo-type-options .visibility-option {
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 28px;
}

.memo-tag-filter {
  grid-column: 1 / -1;
  overflow: hidden;
  border: 1px solid #dce6de;
  border-radius: 10px;
  background: #fbfcfa;
}

.memo-tag-filter summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 37px;
  padding: 7px 9px;
  color: #446451;
  cursor: pointer;
  font-size: 12px;
  font-weight: 740;
}

.memo-tag-filter summary::-webkit-details-marker { display: none; }

.memo-tag-filter[open] summary {
  border-bottom: 1px solid #e1e8e2;
  background: #f3f7f3;
}

.memo-tag-filter .empty-state { padding: 8px; }

.memo-tag-mode {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 2px;
  color: #68796f;
  font-size: 11px;
}

.memo-tag-mode button {
  min-height: 27px;
  padding: 4px 7px;
  border: 1px solid #cad8cd;
  border-radius: 7px;
  color: #4c6d58;
  font-size: 11px;
  font-weight: 700;
  background: #ffffff;
}

.memo-tag-mode button.is-active {
  border-color: #89a996;
  color: #305b42;
  background: #e3eee5;
}

.filter-section {
  border: 1px solid #dce6de;
  border-radius: 10px;
  background: #fbfcfa;
}

.filter-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 37px;
  padding: 7px 9px;
  color: #446451;
  cursor: pointer;
  font-size: 12px;
  font-weight: 740;
}

.filter-section summary::-webkit-details-marker { display: none; }

.filter-section[open] summary {
  border-bottom: 1px solid #e1e8e2;
  background: #f3f7f3;
}

.filter-count,
.filter-item-count {
  color: #77877d;
  font-size: 11px;
  font-weight: 650;
}

.filter-check-actions {
  display: flex;
  gap: 3px;
  padding: 5px 8px 2px;
}

.filter-options {
  display: grid;
  max-height: 225px;
  overflow: auto;
  padding: 4px 8px 8px;
}

.visibility-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 4px 2px;
  color: #466551;
  font-size: 12px;
}

.visibility-option input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: #4d7b60;
}

.groups-card .section-heading { margin-bottom: 9px; }

.group-list-items { display: grid; gap: 6px; }

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 39px;
  padding: 7px 9px;
  border: 1px solid #d6e1d8;
  border-radius: 9px;
  color: #486954;
  text-align: left;
  background: #fbfcfa;
}

.group-item:hover,
.group-item.is-selected {
  border-color: #8dad95;
  background: #e5efe7;
}

.group-count {
  color: #77877d;
  font-size: 11px;
}

.all-memo-list {
  display: grid;
  gap: 10px;
}

.all-memo-card {
  padding: 15px;
  border: 1px solid #d9e2da;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(41 67 51 / 5%);
}

.all-memo-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.all-memo-card-heading > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
}

.all-memo-card h3 {
  margin: 0;
  color: #365744;
  font-size: 15px;
}

.all-memo-card time {
  flex: 0 0 auto;
  color: #75847b;
  font-size: 11px;
  line-height: 1.45;
  text-align: right;
}

.memo-kind {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 999px;
  color: #4c7058;
  font-size: 10px;
  font-weight: 740;
  background: #e5eee6;
}

.all-memo-card .note-content {
  margin-top: 11px;
  font-size: 14px;
}

.all-memo-editor textarea {
  min-height: 94px;
  margin-top: 11px;
}

.all-memo-editor input { margin-top: 7px; }

.all-memo-editor .note-actions { margin-top: 8px; }

.all-memo-notice {
  margin: -5px 0 14px;
  padding: 9px 11px;
  border: 1px solid #c9decf;
  border-radius: 10px;
  color: #3f6950;
  font-size: 12px;
  line-height: 1.5;
  background: #edf5ef;
}

.memo-tags { margin-top: 9px; }
.memo-tags .field-label { margin-bottom: 2px; }
.memo-tags .tag-list { margin-bottom: 0; }

.memo-legacy-note { margin-top: 11px; }
.all-notes-ink-preview { height: 132px; }

.all-memo-empty {
  padding: 24px;
  border: 1px dashed #cbd8cd;
  border-radius: 14px;
  text-align: center;
  background: #ffffff;
}

.split-field { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: end; }

.help-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #ccd9cf;
  border-radius: 16px;
  color: #314a3d;
  background: #ffffff;
  box-shadow: 0 18px 50px rgb(28 50 38 / 28%);
}

.help-dialog::backdrop { background: rgb(20 42 30 / 42%); }

.help-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid #dbe5dd;
  background: #f4f8f4;
}

.help-dialog h2,
.help-dialog h3 { margin: 0; color: #365744; }
.help-dialog h2 { font-size: 18px; }
.help-dialog h3 { font-size: 14px; }

.help-close {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid #cbd8ce;
  border-radius: 9px;
  color: #456552;
  font-size: 21px;
  line-height: 1;
  background: #ffffff;
}

.help-content { display: grid; gap: 11px; padding: 16px 18px 20px; }

.help-content section {
  padding: 12px;
  border: 1px solid #dbe6dd;
  border-radius: 11px;
  background: #fbfcfa;
}

.help-content p {
  margin: 6px 0 0;
  color: #597062;
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 900px) {
  body { height: auto; overflow: auto; }

  .app-shell { height: auto; min-height: 100dvh; grid-template-rows: auto auto; }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    min-height: 0;
  }

  .tool-strip { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .workspace-mode,
  .help-button { order: 2; }
  .pdf-button { margin-left: auto; }

  .workspace {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(55dvh, 1fr) auto;
  }

  .map-panel { min-height: 55dvh; padding-right: 16px; }

  .side-panel {
    max-height: 50dvh;
    padding-left: 16px;
    box-shadow: 0 -4px 18px rgb(44 72 55 / 8%);
  }

  .all-notes-view { padding: 18px 16px 28px; }
}

@media (max-width: 520px) {
  .topbar { padding-right: 10px; padding-left: 10px; }
  .brand p { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 16px; }
  .mode-button { padding-right: 7px; padding-left: 7px; font-size: 12px; }
  .tool-button { padding: 7px 9px; font-size: 12px; }
  .pdf-button { padding: 8px 9px; font-size: 12px; }
  .map-panel { padding: 10px; }
  .side-panel { padding: 10px; }
  .map-utility-controls { bottom: 58px; left: 10px; }
  .all-notes-view { padding: 14px 10px 24px; }
  .all-notes-header { gap: 10px; }
  .all-notes-header .object-kind { margin-top: 2px; }
  .all-notes-filters { grid-template-columns: 1fr; }
  .memo-tag-filter { grid-column: 1; }
  .all-memo-card { padding: 12px; }
  .all-memo-card-heading { gap: 8px; }
  .all-memo-card-heading > div { align-items: flex-start; flex-direction: column; gap: 4px; }
}
