:root {
  color-scheme: light;
  color: #173c32;
  background: #d8ece5;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
}

.island-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
}

.island-map { position: relative; min-height: 0; }

#island {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at 49% 45%, #f5f9ed 0%, #dfefe4 44%, #c5e2dc 99%);
}

#island::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 56px, #3f7d7210 56px 57px),
    repeating-linear-gradient(90deg, transparent 0 56px, #3f7d7210 56px 57px);
  mask-image: radial-gradient(ellipse, #0000 22%, #000 100%);
}

#island.is-dragging { cursor: grabbing; }
#island:focus { outline: 0; }
#island:focus-visible { outline: 2px solid #a17338; outline-offset: -4px; }
#island canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.island-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.island-label, .island-label-line {
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 160ms ease;
}
.island-label.is-flight-overlap:not(:focus), .island-label-line.is-flight-overlap { opacity: 0; }
.island-label-workshop.is-flight-overlap:not(:focus) { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .island-label, .island-label-line { transition: none; }
}
.island-label {
  z-index: 1;
  padding: 2px 6px 3px;
  border: 1px solid #84734b66;
  border-radius: 3px;
  background: #fffaeefa;
  box-shadow: 0 1px 3px #273b2f30;
  color: #243e31;
  font: 650 clamp(11px, .89vw, 14px)/1.28 "Noto Serif SC", "Songti SC", "SimSun", serif;
  letter-spacing: .035em;
  white-space: nowrap;
}
.island-label-line {
  height: 1px;
  transform-origin: left center;
  background: #786544;
  box-shadow: 0 1px 0 #fff7dba8;
}
@media (max-width: 520px) {
  .island-label { padding: 1px 4px 2px; }
}

#landmark-name {
  position: absolute;
  z-index: 1;
  top: max(clamp(17px, 4.2vh, 44px), env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 10px 20px 11px;
  border: 1px solid #a58c528c;
  border-radius: 10px;
  color: #1b493a;
  background: #fff9e9;
  box-shadow: 0 7px 22px #274b4420, inset 0 1px #fff;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: clamp(16px, 2.2vw, 24px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .075em;
  white-space: nowrap;
  pointer-events: none;
}

#scene-status, .scene-error {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  color: #365b4e;
  font-size: 14px;
  pointer-events: none;
}

#scene-status[hidden], #landmark-name[hidden] { display: none; }

.island-map { min-width: 0; }
.island-layout.has-receipt { grid-template-columns: minmax(0, 1fr) auto; }
.island-layout.has-receipt .planner-open { display: none; }

.planner-open, #planner-show-receipt {
  position: absolute;
  z-index: 3;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid #adbbac;
  border-radius: 24px;
  background: #fdfdf7;
  color: #204b3d;
  box-shadow: 0 3px 14px #233c3026;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
#planner-show-receipt { right: auto; left: max(22px, env(safe-area-inset-left)); }
.planner-open:hover, #planner-show-receipt:hover { background: #edf4e8; }
.island-layout [hidden] { display: none !important; }

.planner {
  --ink: #23382f;
  --muted: #5b6b61;
  --rule: #dce2d9;
  --accent: #255b48;
  width: min(590px, calc(100vw - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 40px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #c6d0c4;
  border-radius: 23px;
  background: #fcfcf8;
  color: var(--ink);
  box-shadow: 0 24px 85px #112c2745;
}
.planner[open] { display: flex; flex-direction: column; }
.planner::backdrop { background: #152f284d; backdrop-filter: blur(3px); }
.planner :is(button, select, input, textarea) { color: inherit; font: inherit; }
.planner button { cursor: pointer; }
.planner :is(button, select, input, textarea):focus-visible, .planner-open:focus-visible, #planner-show-receipt:focus-visible {
  outline: 2px solid #947130;
  outline-offset: 2px;
}
.planner-header, .planner-header-actions, .planner-identity, .planner-advanced-heading, .planner-composer-actions {
  display: flex; align-items: center;
}
.planner-header { flex: none; padding: 13px 18px 13px 23px; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--rule); }
.planner-identity { gap: 9px; font-size: 14px; font-weight: 650; }
.planner-identity svg { color: var(--accent); }
.planner-header-actions { gap: 5px; }
.planner-header-actions button, #planner-advanced-done {
  padding: 6px 9px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 13px;
}
.planner-header-actions .planner-close { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; }
.planner-header-actions button:hover, #planner-advanced-done:hover { background: #eaf0e8; }
.planner-thread { flex: 1 1 auto; min-height: 0; max-height: 36dvh; overflow-y: auto; overscroll-behavior: contain; }
#planner-welcome { padding: clamp(28px, 5vh, 50px) 28px 16px; text-align: center; }
#planner-title { margin: 0; font-size: clamp(24px, 3.5vw, 32px); line-height: 1.3; letter-spacing: -.035em; font-weight: 650; }
#planner-welcome p { margin: 11px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.planner-examples, .planner-options { display: flex; flex-wrap: wrap; gap: 7px; }
.planner-examples { justify-content: center; }
.planner-examples button, .planner-option {
  border: 1px solid var(--rule); border-radius: 18px; color: #465b50; background: #fff; font-size: 13px;
}
.planner-examples button { min-height: 34px; padding: 4px 11px; }
.planner-examples button:hover, .planner-option:hover { border-color: #9fb8a9; background: #f1f6ef; }
#planner-history:not(:empty) { display: grid; gap: 12px; padding: 22px; }
#planner-history p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.7; }
.planner-user-turn { justify-self: end; max-width: 87%; border-radius: 16px 16px 4px 16px; padding: 8px 13px; background: #e7efe6; }
.planner-reply { padding: 0 3px; }
#planner-form { display: flex; flex-direction: column; min-height: 0; padding: 14px 18px 18px; gap: 10px; }
.planner:has(#planner-advanced:not([hidden])) .planner-thread { display: none; }
#planner-advanced { overflow: auto; overscroll-behavior: contain; padding: 4px 5px 12px; }
.planner-advanced-heading { justify-content: space-between; margin-bottom: 10px; }
.planner-advanced-heading h2 { margin: 0; font-size: 17px; }
.planner-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.planner-field { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.planner-wide { grid-column: 1 / -1; }
.planner-field :is(select,input) {
  width: 100%; min-width: 0; height: 39px; padding: 5px 9px; border: 1px solid #bfcfc2;
  border-radius: 8px; background: white; font-size: 15px; font-weight: 400;
}
.planner-easy, .planner-option { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.planner-easy { align-self: end; min-height: 39px; font-size: 13px; }
.planner input[type=checkbox] { flex: none; width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.planner fieldset { margin: 13px 0 0; padding: 0; border: 0; }
.planner legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.planner-option { min-height: 32px; padding: 4px 10px; }
.planner-option:has(input:checked) { color: #234e3e; border-color: #83a792; background: #e8f2e7; }
.planner-composer { flex: none; padding: 12px 12px 8px; border: 1px solid #bac8ba; border-radius: 17px; background: #fff; box-shadow: 0 2px 6px #263c2609; }
.planner-composer:focus-within { border-color: #799b84; }
#planner-preferences { width: 100%; min-height: 44px; padding: 2px 3px; border: 0; resize: none; background: transparent; outline: none; font-size: 16px; line-height: 1.55; }
#planner-preferences::placeholder { color: #758077; }
.planner-composer-actions { justify-content: flex-end; gap: 8px; }
#planner-advanced-toggle, #planner-confirm-time { display: inline-flex; gap: 6px; align-items: center; min-height: 36px; padding: 4px 11px; border-radius: 20px; border: 1px solid var(--rule); background: #fff; font-size: 13px; }
#planner-advanced-toggle:hover, #planner-advanced-toggle[aria-expanded=true], #planner-confirm-time { background: #edf3ec; }
#planner-confirm-time { margin-top: 10px; }
.planner-send { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: #fff !important; }
.planner-send:hover { background: #164331; }
#planner-message { flex: none; margin: 0; max-height: 16dvh; overflow: auto; padding: 8px 11px; border-radius: 8px; background: #f7eedc; color: #654b24; font-size: 13px; line-height: 1.6; }
.planner-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 720px) {
  .island-layout { grid-template-columns: minmax(0, 1fr); }
  .island-layout.has-receipt { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 42fr) minmax(0, 58fr); }
  .planner { width: calc(100vw - 20px); max-height: calc(100dvh - 16px); border-radius: 18px; }
  .planner-header { padding: 8px 12px 8px 16px; }
  #planner-welcome { padding: 26px 12px 9px; }
  #planner-form { padding: 10px 12px 12px; }
  .planner-open, #planner-show-receipt { bottom: max(12px, env(safe-area-inset-bottom)); min-height: 40px; }
  .planner-open { right: max(12px, env(safe-area-inset-right)); }
  #planner-show-receipt { left: max(12px, env(safe-area-inset-left)); }
}
