:root {
  --ink: #1c1915;
  --muted: #6b645b;
  --line: #d9d0c3;
  --paper: #f4efe6;
  --panel: #fffdf8;
  --forest: #1f4d3a;
  --leaf: #2f7a58;
  --leaf-hover: #256349;
  --sand: #efe6d6;
  --danger: #b42318;
  --ad: #fff6d8;
  --shadow: 0 16px 40px rgba(47, 38, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: var(--leaf);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar,
.register-bar,
.sheet-toolbar,
.home-actions,
.form-actions,
.map-toolbar,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.quota-status {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--forest);
}

.quota-status.is-blocked {
  color: var(--danger);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--sand);
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 20px;
}

.account-badge {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: #e8f3ec;
  color: var(--forest);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.account-badge.unsynced {
  background: #f8e8d8;
  color: #8a4b12;
}

.account-status {
  margin: 0 0 12px;
  font-weight: 600;
}

.home {
  flex: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 20px;
  padding: 48px 24px 80px;
  text-align: center;
}

.home-lead,
.home-note,
.fine,
.count,
.ad-caption,
.ad-kicker {
  color: var(--muted);
}

.home-lead {
  margin: 0;
  font-size: 16px;
}

.home-actions {
  justify-content: center;
}

.btn,
.import-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.huge {
  min-width: 220px;
  padding: 22px 28px;
  border-radius: 18px;
  font-size: 20px;
}

.btn.primary {
  background: var(--forest);
  color: #fff;
}

.btn.secondary {
  background: var(--leaf);
  color: #fff;
}

.btn.primary:hover,
.btn.secondary:hover {
  background: var(--leaf-hover);
}

.btn.ghost,
.import-btn {
  background: var(--sand);
  color: var(--ink);
}

.btn.compact,
.import-btn.compact {
  padding: 8px 12px;
  font-size: 13px;
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  padding: 0 6px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.linkish {
  border: 0;
  background: none;
  color: var(--leaf);
  font: inherit;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.workspace.map-open {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #ead7a0;
  border-radius: 12px;
  background: #fff8e1;
  color: #5c4a16;
  font-size: 13px;
  line-height: 1.7;
}

.notice.warn {
  border-color: #f0b4ae;
  background: #fff1ef;
  color: #7a1f18;
}

.count.warn {
  color: var(--danger);
  font-weight: 700;
}

.sheet-pane {
  padding: 20px 24px 24px;
  overflow: auto;
}

.register-bar {
  margin-bottom: 12px;
}

.location-mode {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}

.location-mode legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
}

.location-mode label {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

.location-mode input {
  width: auto;
  margin: 0;
}

.map-name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 220px;
  font-size: 13px;
  font-weight: 600;
}

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

.sheet-toolbar {
  margin-bottom: 10px;
}

.sheet-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sheet {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

.sheet th,
.sheet td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #f0eae0;
  padding: 0;
  text-align: left;
  font-size: 13px;
}

.sheet th {
  padding: 10px 8px;
  background: #f7f1e6;
  font-weight: 600;
}

.sheet td {
  min-width: 0;
  vertical-align: top;
}

.sheet textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: calc(1.45em * 2 + 16px);
  max-height: calc(1.45em * 2 + 16px);
  border: 0;
  border-radius: 0;
  padding: 8px;
  background: transparent;
  resize: none;
  overflow: hidden;
  line-height: 1.45;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sheet textarea:focus {
  overflow-y: auto;
}

.sheet tr:focus-within {
  background: #fff8e8;
}

.col-num {
  width: 44px;
  text-align: center;
}

.col-action {
  width: 76px;
}

.col-color {
  width: 48px;
}

.color-header-btn {
  appearance: none;
  display: inline-block;
  margin: 0;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--leaf);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.color-header-btn:hover,
.color-header-btn:focus-visible {
  background: var(--sand);
  color: var(--leaf-hover);
}

.col-progress {
  width: 92px;
}

.sheet .col-num,
.sheet .col-action,
.sheet .col-color,
.sheet .col-progress {
  text-align: center;
  padding: 8px;
  color: var(--muted);
}

.sheet .col-action {
  display: grid;
  gap: 4px;
  justify-items: center;
  align-content: center;
}

.sheet .col-color,
.sheet .col-progress {
  vertical-align: middle;
}

.pin-color-swatch {
  display: block;
  width: 32px;
  height: 28px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.pin-color-menu {
  position: fixed;
  z-index: 40;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.pin-color-menu-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.pin-color-presets {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.pin-color-preset {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}

.pin-color-preset.is-selected,
.pin-color-preset:focus-visible {
  border-color: var(--ink);
}

.pin-color-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 12px;
}

.pin-color-custom .pin-color {
  width: 42px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.sheet .col-progress select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 4px;
  background: #fff;
  font: inherit;
}

.fine {
  margin: 10px 0 0;
  font-size: 12px;
}

.map-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  border-left: 1px solid var(--line);
}

.workspace.map-open .map-pane {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
}

.workspace.map-open #map {
  flex: 1;
  height: auto;
  min-height: 0;
}

#map {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 70vh;
}

body.map-fullscreen {
  overflow: hidden;
}

.workspace.map-fullscreen .map-pane {
  position: fixed;
  inset: 0;
  z-index: 800;
  min-height: 0;
  border: 0;
  background: var(--paper);
}

.workspace.map-fullscreen #map {
  flex: 1;
  height: auto;
  min-height: 0;
}

.workspace.map-fullscreen .sheet-pane {
  position: fixed;
  z-index: 850;
  left: 12px;
  top: 56px;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 72px);
  overflow: auto;
  padding: 12px 16px 16px;
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: var(--shadow);
}

.workspace.map-fullscreen .notice,
.workspace.map-fullscreen .fine {
  display: none;
}

.sheet tbody tr {
  cursor: pointer;
}

.sheet tbody tr textarea,
.sheet tbody tr button,
.sheet tbody tr input,
.sheet tbody tr select {
  cursor: auto;
}

.sheet .col-num {
  cursor: pointer;
  font-weight: 600;
  color: var(--leaf);
}

.sheet tbody tr.is-focused {
  background: #d5efe0;
  outline: 2px solid var(--leaf);
  outline-offset: -2px;
}

.sheet tbody tr.is-focused .col-num {
  background: var(--leaf);
  color: #fff;
}

.group-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}

.group-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: var(--paper);
}

.group-item h3 {
  margin: 0;
  font-size: 15px;
}

.group-item p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.group-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.map-controls {
  position: static;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  padding: 10px 12px 8px;
  box-sizing: border-box;
}

.map-search {
  display: flex;
  gap: 6px;
  width: 100%;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.map-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 6px 8px;
}

.map-toolbar {
  position: static;
  z-index: auto;
  top: auto;
  left: auto;
}

@media (min-width: 981px) {
  .map-search {
    max-width: 420px;
  }
}

.map-hint {
  margin: 8px 12px 10px;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.map-locate {
  position: fixed;
  z-index: 860;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(48px, calc(env(safe-area-inset-bottom) + 16px));
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-locate span {
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border: 3px solid var(--leaf);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(47, 122, 88, 0.18);
}

.pin-popup {
  min-width: 180px;
  line-height: 1.5;
}

.pin-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pin-popup-nav,
.pin-popup-delete {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
}

.pin-popup-search {
  max-width: min(280px, 72vw);
  word-break: break-word;
}

.pin-popup-register {
  padding: 6px 14px;
}

a.pin-popup-nav,
a.pin-popup-nav:link,
a.pin-popup-nav:visited,
a.pin-popup-nav:hover,
a.pin-popup-nav:active {
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.pin-popup-delete {
  background: #fff1ef;
}

.map-pin-search {
  background: #1c7ed6;
}

.map-user-dot {
  position: relative;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.map-user-dot::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(28, 126, 214, 0.22);
  animation: locate-pulse 1.8s ease-out infinite;
}

.map-user-dot span {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #1c7ed6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

@keyframes locate-pulse {
  from {
    transform: scale(0.6);
    opacity: 0.8;
  }
  to {
    transform: scale(1.8);
    opacity: 0;
  }
}

.leaflet-div-icon {
  background: none;
  border: 0;
}

.map-pin {
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(28, 25, 21, 0.45);
}

.dialog-card {
  padding: 24px;
  max-height: min(88vh, 760px);
  overflow: auto;
}

.settings-block {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.settings-label {
  font-size: 13px;
  font-weight: 600;
}

.settings-block .fine {
  margin: 0;
  font-weight: 400;
}

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

.progress-option-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress-option-row input {
  flex: 1;
  min-width: 0;
}

.dialog-card p,
.perk-list {
  color: var(--muted);
  line-height: 1.7;
}

.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 8px;
  background: rgba(28, 25, 21, 0.45);
}

.ad-overlay .ad-card {
  width: min(520px, calc(100vw - 16px));
  max-width: 100%;
  padding: 16px 8px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.home.is-away {
  flex: 0 0 auto;
  padding: 0;
  gap: 0;
  min-height: 0;
}

.home-rest {
  display: grid;
  justify-items: center;
  gap: 20px;
}

.ad-slot.is-parked {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 0;
  width: min(728px, calc(100vw - 48px));
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.ad-slot.is-pinned {
  position: fixed;
  z-index: 3100;
  margin: 0;
  pointer-events: auto;
}

.ad-slot.is-pinned .ad-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.ad-overlay .ad-frame {
  visibility: hidden;
}

.ad-card {
  background: var(--ad);
}

.ad-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.ad-slot {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 0 auto;
  width: min(728px, calc(100vw - 48px));
}

html.imobile-sp .ad-slot {
  width: 100%;
  max-width: 640px;
}

html.imobile-sp .ad-frame,
html.imobile-sp #home-ad {
  min-height: 100px;
}

html.imobile-sp #home-ad {
  overflow: hidden;
}

.ad-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.ad-frame,
#home-ad {
  width: 100%;
  min-height: 250px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: visible;
}

.ad-frame {
  padding: 0;
  min-width: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .home {
    padding: 32px 8px 64px;
  }

  .ad-slot {
    width: 100%;
    max-width: 640px;
  }

  .ad-frame,
  #home-ad {
    min-height: 100px;
  }

  .workspace,
  .workspace.map-open {
    grid-template-columns: 1fr;
  }

  .workspace.map-open .sheet-pane,
  .workspace.map-open .map-pane {
    min-width: 0;
  }

  .workspace.map-open .map-pane {
    position: relative;
    top: auto;
    align-self: stretch;
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .map-pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .map-controls {
    padding: 8px;
  }

  #map,
  .workspace.map-open #map {
    height: 72vh;
    min-height: 72vh;
  }

  .workspace.map-fullscreen .sheet-pane {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: 38vh;
  }
}

.yahoo-credit {
  margin: 16px 24px 24px;
  text-align: center;
  font-size: 12px;
}
