:root {
  --bg: #14171a;
  --bg-panel: #1c2024;
  --bg-panel-alt: #23282d;
  --border: #333a40;
  --text: #e6e8ea;
  --text-dim: #9aa3ab;
  --accent: #d98c2b;
  --accent-dim: #8a5c1c;
  --danger: #c0483f;
  --ok: #4a9d5f;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.app-header h1 {
  font-size: 18px;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.header-status {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-dim);
}

.back-button {
  background: var(--bg-panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.back-button:hover { border-color: var(--accent); color: var(--accent); }

#app-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: auto;
}

.screen[hidden] {
  display: none;
}

.screen-lead {
  color: var(--text-dim);
  margin: 0 0 16px;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.map-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.map-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.map-card .map-card-name-ja {
  font-size: 16px;
  font-weight: 600;
}
.map-card .map-card-name-en {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.map-card .map-card-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-panel-alt);
  color: var(--text-dim);
}
.map-card.no-image .map-card-badge {
  color: #c99a4e;
  background: #3a2c14;
}

.task-map-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 16px;
}

.sidebar {
  flex: 0 0 340px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar h2 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 18px;
}

.sidebar-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0 0 12px;
}

.task-list {
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
}

.trader-group {
  border-bottom: 1px solid var(--border);
}
.trader-group:last-child { border-bottom: none; }

.trader-group-header {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-panel-alt);
  position: sticky;
  top: 0;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.task-row:hover { background: rgba(255,255,255,0.03); }

.task-row input[type="checkbox"] {
  margin-top: 3px;
  flex: 0 0 auto;
  cursor: pointer;
}

.task-row .task-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.task-row .task-name {
  font-size: 13.5px;
  line-height: 1.35;
}

.task-row .task-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-row .task-meta .kappa {
  color: #c99a4e;
}

.task-row .task-meta .no-location {
  color: var(--text-dim);
  font-style: italic;
}

.task-row .pin-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  visibility: hidden;
}
.task-row.checked .pin-swatch { visibility: visible; }

.map-viewer-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.map-viewer-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.map-viewer-toolbar button {
  background: var(--bg-panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
}
.map-viewer-toolbar button:hover { border-color: var(--accent); color: var(--accent); }

.map-viewer {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c0e10;
  overflow: hidden;
  position: relative;
  cursor: grab;
}
.map-viewer.grabbing { cursor: grabbing; }

.map-viewer-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.map-image {
  display: block;
  user-select: none;
  pointer-events: none;
  line-height: 0;
}
.map-image svg {
  display: block;
}

.pin-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pin {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 0;
  border: 2px solid #fff;
  transform: translate(-50%, -100%) rotate(-45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.6);
  pointer-events: auto;
  cursor: pointer;
}

.no-image-notice {
  margin-top: 10px;
  padding: 12px 14px;
  background: #3a2c14;
  border: 1px solid #6b4c1f;
  border-radius: 8px;
  color: #e6c88a;
  font-size: 13px;
}

.pin-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.pin-tooltip .tt-task-name {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.loading-notice, .error-notice {
  padding: 16px;
  color: var(--text-dim);
}
.error-notice { color: var(--danger); }

@media (max-width: 860px) {
  .task-map-layout { flex-direction: column; }
  .sidebar { flex: 0 0 auto; max-height: 40vh; }
}
