:root {
  color-scheme: light;
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #eef3f1;
  color: #182626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

button {
  border: 1px solid #b8c7c3;
  background: #ffffff;
  color: #183433;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: #176b70;
  border-color: #176b70;
  color: #ffffff;
}

button.subtle {
  background: #f7f9f8;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #5e7471;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.actions,
.filter-panel {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions {
  align-items: center;
}

.cloud-status {
  color: #5e7471;
  font-size: 12px;
  font-weight: 700;
}

.cloud-status.syncing {
  color: #8a6117;
}

.cloud-status.connected {
  color: #176b70;
}

.cloud-status.error {
  color: #a2352b;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.workspace:has(.cloud-notice:not([hidden])) {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #d6e0dd;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(41, 66, 64, 0.08);
}

.import-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr)) auto;
  gap: 12px;
  padding: 12px;
  align-items: end;
}

.cloud-notice {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-color: #9fc7bf;
  background: #f5fbf9;
}

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

.cloud-notice[hidden] {
  display: none;
}

.cloud-notice div {
  display: grid;
  gap: 3px;
}

.cloud-notice span {
  color: #526966;
  font-size: 13px;
}

.file-box {
  display: grid;
  gap: 6px;
}

.file-box label,
.check-row {
  color: #334947;
  font-size: 13px;
  font-weight: 700;
}

.file-box input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c7d4d1;
  border-radius: 6px;
  background: #ffffff;
  padding: 7px;
}

.map-area {
  position: relative;
  height: calc(100vh - 156px);
  min-height: 560px;
  max-height: 760px;
  overflow: hidden;
  border: 1px solid #cbd8d5;
  border-radius: 8px;
  background: #dce7e5;
}

.map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  font-family: inherit;
  overflow: hidden;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  border: 0;
  display: block;
  max-width: none;
  max-height: none;
  user-select: none;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-attribution {
  font-size: 11px;
}

.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 500;
  display: grid;
  gap: 6px;
}

.map-controls button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-color: #95aaa5;
  background: rgba(255, 255, 255, 0.94);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.empty-state {
  position: absolute;
  left: 50%;
  bottom: 18px;
  max-width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  color: #2f4643;
  font-weight: 700;
  text-align: center;
  padding: 10px 14px;
  border: 1px solid rgba(129, 154, 149, 0.72);
  border-radius: 8px;
  pointer-events: none;
  z-index: 600;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(21, 38, 36, 0.16);
}

.side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
}

.summary div {
  display: grid;
  gap: 2px;
  padding: 14px 10px;
  background: #ffffff;
}

.summary span {
  font-size: 25px;
  font-weight: 800;
}

.summary small {
  color: #637774;
  font-size: 12px;
  font-weight: 700;
}

.filter-panel {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
}

.trip-filter {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
}

.trip-filter label,
.storage-status {
  color: #637774;
  font-size: 12px;
  font-weight: 700;
}

.trip-filter select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c7d4d1;
  border-radius: 6px;
  background: #ffffff;
  color: #183433;
  padding: 0 9px;
}

.selection-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.selection-actions button {
  flex: 1;
}

.selection-actions .danger {
  border-color: #b63a2b;
  background: #fff5f3;
  color: #9f2e23;
}

.selection-actions .danger:disabled {
  border-color: #cfd8d7;
  background: #f5f8f7;
  color: #879391;
}

.storage-status {
  grid-column: 1 / -1;
  padding-top: 2px;
}

.mymaps-toggle {
  color: #285f7b;
}

.mymaps-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mymaps-controls .mymaps-toggle {
  flex: 1;
}

.mymaps-delete {
  display: grid;
  width: 30px;
  min-height: 30px;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: #8a4540;
  padding: 0;
}

.mymaps-delete svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.mymaps-delete:hover {
  border-color: #edcbc7;
  background: #fff3f1;
}

.mymaps-toggle span {
  min-width: 24px;
  border-radius: 10px;
  background: #e4f0f5;
  color: #285f7b;
  padding: 1px 6px;
  text-align: center;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
}

.timeline-panel {
  min-height: 410px;
  max-height: calc(100vh - 292px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #e2ebe8;
}

h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: #637774;
  font-size: 13px;
  font-weight: 700;
}

.timeline-tabs {
  display: flex;
  gap: 2px;
  min-width: 0;
}

.timeline-tabs button {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: #637774;
  padding: 0 8px;
  font-weight: 800;
}

.timeline-tabs button.active {
  border-color: #a9c8c4;
  background: #eef8f6;
  color: #176b70;
}

.timeline-tabs button span {
  color: inherit;
  font-size: 12px;
}

.deleted-actions {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #e2ebe8;
  padding: 8px 14px;
}

.deleted-actions[hidden] {
  display: none;
}

.deleted-actions button {
  flex: 1;
}

.deleted-actions .danger {
  border-color: #b63a2b;
  background: #fff5f3;
  color: #9f2e23;
}

.timeline {
  overflow: auto;
  padding: 8px;
}

.timeline-empty {
  color: #637774;
  margin: 16px;
  text-align: center;
}

.timeline-item {
  display: grid;
  grid-template-columns: 22px 16px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px 8px;
  border-bottom: 1px solid #edf2f0;
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.timeline-item:hover {
  background: #f5faf8;
}

.timeline-item.focused {
  background: #fff2ba;
  box-shadow: inset 4px 0 #d69b17;
  outline: none;
}

.timeline-item.deleted {
  background: #fafbfb;
}

.pin-select {
  width: 16px;
  height: 16px;
  margin: 4px 0 0;
}

.pin-icon {
  width: 16px;
  height: 16px;
  margin-top: 4px;
  color: #246b52;
}

.timeline-item.catch .pin-icon {
  color: #d7442e;
}

.pin-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.timeline-item.catch .pin-icon path:last-of-type,
.timeline-item.catch .pin-icon circle {
  fill: #ffffff;
}

.item-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.name-line {
  display: flex;
  gap: 6px;
  align-items: start;
}

.pin-name {
  min-width: 0;
  min-height: 0;
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0;
  color: #183433;
  font-weight: 800;
  text-align: left;
  overflow-wrap: anywhere;
}

.pin-name:hover {
  color: #176b70;
  text-decoration: underline;
}

.deleted-name {
  min-width: 0;
  flex: 1;
  color: #4e605e;
  overflow-wrap: anywhere;
}

.deleted-description {
  color: #637774;
  font-size: 12px;
  white-space: pre-wrap;
}

.delete-pin {
  width: 26px;
  min-height: 26px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #8a4540;
  display: grid;
  place-items: center;
}

.pin-detail {
  display: grid;
  width: 26px;
  min-height: 26px;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: #176b70;
  padding: 0;
}

.delete-pin svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.pin-detail svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.delete-pin:hover {
  border-color: #edcbc7;
  background: #fff3f1;
}

.pin-detail:hover {
  border-color: #b9d8d5;
  background: #eef8f6;
}

.item-main small {
  color: #627572;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pin-description {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  border: 1px solid #d7e1de;
  border-radius: 5px;
  background: #ffffff;
  color: #314845;
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 7px;
}

.pin-description:focus {
  border-color: #176b70;
  outline: 2px solid rgba(23, 107, 112, 0.16);
}

.fishpin-marker {
  background: transparent;
  border: 0;
  pointer-events: auto;
}

.marker-symbol {
  position: absolute;
  top: 0;
  left: 50%;
  width: 30px;
  height: 30px;
  transform: translateX(-50%);
}

.fishpin-marker svg {
  display: block;
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 2px rgba(19, 39, 37, 0.28));
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fishpin-marker.catch svg {
  fill: #d7442e;
}

.fishpin-marker.saved_point svg {
  fill: #246b52;
}

.fishpin-marker.selected svg {
  transform: scale(1.15);
  transform-origin: center;
}

.marker-name {
  position: absolute;
  top: 32px;
  left: 0;
  width: 160px;
  overflow: hidden;
  color: #183433;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 0 3px #ffffff, 0 0 3px #ffffff, 0 0 3px #ffffff;
  white-space: nowrap;
}

.fishpin-marker.catch path:last-of-type,
.fishpin-marker.catch circle {
  fill: #ffffff;
}

.fishpin-cluster {
  background: transparent;
  border: 0;
}

.fishpin-cluster > span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #0f6f87;
  box-shadow: 0 2px 5px rgba(19, 39, 37, 0.35);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
}

.fishpin-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  background: #ffffff;
  color: #183433;
}

.fishpin-popup .leaflet-popup-tip {
  background: #ffffff;
}

.mymaps-popup .leaflet-popup-content-wrapper,
.mymaps-popup .leaflet-popup-tip {
  background: #ffffff;
}

.mymaps-popup-details {
  padding: 3px 2px;
}

.mymaps-popup-details h3 {
  margin: 0;
  color: #285f7b;
  font-size: 15px;
  letter-spacing: 0;
}

.mymaps-popup-details p {
  margin: 7px 0 0;
  color: #4e605e;
  line-height: 1.5;
  white-space: pre-wrap;
}

.mymaps-popup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.fishpin-popup .leaflet-popup-content {
  width: 300px !important;
  margin: 20px 18px;
}

.popup-details {
  padding: 5px 0;
}

.popup-details h3 {
  margin: 0 0 15px;
  color: #183433;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.popup-details dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.popup-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
}

.popup-row dt {
  color: #496563;
  font-size: 12px;
  font-weight: 800;
}

.popup-row dd {
  min-width: 0;
  margin: 0;
  color: #183433;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.popup-row.preserve-linebreak dd {
  white-space: pre-wrap;
}

.popup-actions {
  display: flex;
  justify-content: end;
  gap: 6px;
  margin-top: 16px;
}

.popup-icon-button {
  display: grid;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  place-items: center;
  padding: 0;
}

.popup-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.popup-icon-button.danger {
  color: #9f2e23;
}

.popup-editor {
  display: grid;
  gap: 12px;
}

.popup-editor label {
  display: grid;
  gap: 5px;
  color: #496563;
  font-size: 12px;
  font-weight: 800;
}

.popup-editor input,
.popup-editor textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #b9cdca;
  border-radius: 4px;
  color: #183433;
  font: inherit;
  padding: 7px;
}

.popup-form-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.detail-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-sizing: border-box;
  border: 1px solid #b9cdca;
  border-radius: 8px;
  background: #ffffff;
  color: #183433;
  padding: 0;
  box-shadow: 0 18px 48px rgba(19, 39, 37, 0.24);
}

.auth-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid #cad8d4;
  border-radius: 8px;
  background: #ffffff;
  padding: 0;
  box-shadow: 0 24px 70px rgba(18, 39, 36, 0.28);
}

.auth-dialog::backdrop {
  background: rgba(23, 38, 37, 0.68);
}

.auth-dialog form {
  display: grid;
  gap: 8px;
  padding: 24px;
}

.auth-dialog h2 {
  margin-bottom: 10px;
  font-size: 24px;
}

.auth-dialog label {
  color: #334947;
  font-size: 13px;
  font-weight: 700;
}

.auth-dialog input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bfcfcb;
  border-radius: 6px;
  padding: 8px 10px;
}

.auth-dialog button {
  margin-top: 8px;
}

.form-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: #a2352b;
  font-size: 13px;
}

.detail-dialog::backdrop {
  background: rgba(19, 39, 37, 0.38);
}

.detail-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #dce7e5;
  padding: 12px 14px;
}

.detail-dialog-header h2 {
  margin: 0;
  font-size: 16px;
}

.detail-dialog-header button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.detail-dialog-body {
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 16px;
}

.detail-dialog-body dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .map-area {
    height: 560px;
    max-height: none;
  }

  .import-panel {
    grid-template-columns: 1fr;
  }

  .timeline-panel {
    max-height: none;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button {
    flex: 1;
  }

  h1 {
    font-size: 25px;
  }

  .summary {
    grid-template-columns: repeat(2, 1fr);
  }
}
