:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #10231c;
  --accent: #0f8f63;
  --line: #c7d6cf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% -20%, #d6eee4 0%, var(--bg) 48%);
}

.topbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}

.file-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  font-size: 0.9rem;
}

.file-btn {
  display: block;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  margin-bottom: 0.4rem;
  transition: background 0.15s, border-color 0.15s;
}

.file-btn:hover {
  background: #ecfaf5;
  border-color: var(--accent);
}

.topbar input[type="text"] {
  min-width: 220px;
}

#server-content-select {
  min-width: 220px;
}

#publish-status {
  color: #355d50;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 0.75rem;
  padding: 0.75rem;
  min-height: calc(100vh - 72px);
}

.player-layout {
  grid-template-columns: 1fr 320px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  overflow: auto;
}

.canvas-wrap {
  background: #e9f2ee;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 70vh;
  display: flex;
}

svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  min-height: 42px;
  cursor: pointer;
}

button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.danger {
  border-color: #c76363;
  color: #842b2b;
}

.hotspot-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#hotspot-list {
  max-height: 34vh;
  overflow: auto;
}

#geometry-list {
  max-height: 20vh;
  overflow: auto;
  margin-bottom: 0.5rem;
}

.hotspot-list li {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  margin-bottom: 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}

.hotspot-list li.active {
  border-color: var(--accent);
  background: #ecfaf5;
}

label {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.5rem;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.65rem;
  min-height: 42px;
  font: inherit;
}

select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  min-height: 42px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 120px;
}

/* ── Markdown editor ── */

.md-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.md-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: #f8fbf9;
  border-bottom: 1px solid var(--line);
}

.md-toolbar button {
  width: 30px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background 0.1s, border-color 0.1s;
}

.md-toolbar button:hover {
  background: #e3efe9;
  border-color: var(--line);
}

.md-toolbar button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.md-toolbar__sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
}

#md-preview-toggle {
  width: auto;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.md-editor textarea {
  border: none;
  border-radius: 0;
  min-height: 200px;
  resize: vertical;
  padding: 0.6rem 0.65rem;
}

.md-preview {
  padding: 0.75rem;
  min-height: 200px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
  overflow-y: auto;
}

.md-preview strong {
  font-weight: 700;
}

.md-preview em {
  font-style: italic;
}

.field-group {
  border: 1px solid var(--line);
  padding: 0.5rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.hidden {
  display: none;
}

.hotspot {
  fill: rgba(15, 143, 99, 0.18);
  stroke: #0f8f63;
  stroke-width: 2;
  cursor: pointer;
}

.hotspot.selected {
  stroke: #ff5f00;
  fill: rgba(255, 95, 0, 0.14);
}

.hotspot.selected-geometry {
  stroke: #225df7;
  fill: rgba(34, 93, 247, 0.14);
}

.hotspot.draft {
  stroke-dasharray: 6 4;
}

.hotspot.player {
  fill: rgba(15, 143, 99, 0.18);
}

.hotspot.player.hidden-geometry {
  fill: rgba(0, 0, 0, 0);
  stroke: rgba(0, 0, 0, 0);
  pointer-events: all;
}

.hotspot.player.visible-geometry {
  fill: rgba(15, 143, 99, 0.18);
  stroke: #0f8f63;
}

.hotspot.player.active-geometry {
  fill: rgba(255, 95, 0, 0.2);
  stroke: #ff5f00;
}

/* ── Topbar back link ── */

.topbar-back {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: background 0.15s;
}

.topbar-back:hover {
  background: #ecfaf5;
}

.topbar-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  flex-shrink: 0;
}

.topbar-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.topbar-primary:hover {
  background: #0b7a55;
}

.topbar-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── List page ── */

.list-page {
  min-height: 100vh;
  padding: 2.5rem 3rem 2rem;
}

.list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.list-title {
  margin: 0 0 0.2rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--ink);
  line-height: 1.2;
}

.list-subtitle {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b8a7e;
}

.list-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.list-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

.list-new-btn:hover {
  background: #0b7a55;
  transform: translateY(-1px);
}

.list-import-btn:hover {
  background: #f1f7f3;
  border-color: #b9d7c7;
  transform: translateY(-1px);
}

.list-toolbar {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.list-search {
  max-width: 360px;
  flex: 1 1 280px;
}

.list-import-status {
  margin: -0.5rem 0 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #355b4c;
}

.list-import-status.success {
  color: #0b7a55;
}

.list-import-status.error {
  color: #9f2f2f;
}

.list-search input {
  width: 100%;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.list-search input:focus {
  border-color: var(--accent);
}

.list-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.list-view-btn {
  min-height: unset;
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #5c766b;
  font-size: 0.82rem;
  font-weight: 700;
}

.list-view-btn:hover {
  background: #edf4f0;
}

.list-view-btn.active {
  background: var(--accent);
  color: #fff;
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.list-grid--detail {
  display: block;
}

.list-card {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.15s;
}

.list-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(16, 35, 28, 0.1);
}

.list-card__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.list-card__delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  min-height: unset;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: #842b2b;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.list-card:hover .list-card__delete {
  opacity: 1;
}

.list-card__delete:hover {
  background: #fde8e8;
  border-color: #c76363;
}

.list-card__thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e9f2ee;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.list-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}

.list-card__badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  background: rgba(15, 143, 99, 0.12);
  color: var(--accent);
}

.list-card__info {
  padding: 1rem 1.1rem;
}

.list-card__title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1.3;
}

.list-card__meta {
  margin: 0;
  font-size: 0.75rem;
  color: #6b8a7e;
  line-height: 1.4;
}

.list-table {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}

.list-table__row {
  display: grid;
  grid-template-columns: 92px minmax(220px, 1.3fr) minmax(160px, 1fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) 90px 96px;
  gap: 0;
  align-items: center;
  border-top: 1px solid var(--line);
}

.list-table__row:first-child {
  border-top: none;
}

.list-table__row--head {
  background: #eef5f1;
}

.list-table__cell {
  min-width: 0;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.list-table__cell--thumb {
  padding-right: 0;
}

.list-table__cell--label {
  font-weight: 700;
  color: #5c766b;
}

.list-table__sort {
  min-height: unset;
  padding: 0;
  border: none;
  background: transparent;
  color: #5c766b;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.list-table__sort:hover {
  color: var(--accent);
}

.list-table__sort.active {
  background: transparent;
  border: none;
  color: var(--accent);
  box-shadow: none;
}

.list-table__link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.list-table__link:hover {
  color: var(--accent);
}

.list-table__thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #e9f2ee;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.list-table__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.2rem;
}

.list-table__thumb-placeholder {
  font-size: 0.62rem;
  font-weight: 700;
  color: #7b9389;
  text-align: center;
  line-height: 1.2;
}

.list-table__cell--action {
  text-align: right;
}

.list-table__delete {
  min-height: unset;
  padding: 0.45rem 0.7rem;
  border: 1px solid #d7b0b0;
  border-radius: 9px;
  background: #fff5f5;
  color: #842b2b;
  font-size: 0.75rem;
  font-weight: 700;
}

.list-table__delete:hover {
  background: #fde8e8;
  border-color: #c76363;
}

.list-empty {
  text-align: center;
  color: #6b8a7e;
  font-size: 0.9rem;
  padding: 3rem 0;
}

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

  .player-layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    min-height: 50vh;
  }

  .list-page {
    padding: 1.5rem 1rem;
  }

  .list-title {
    font-size: 1.2rem;
  }

  .list-toolbar {
    align-items: stretch;
  }

  .list-view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .list-view-btn {
    flex: 1 1 0;
  }

  .list-table {
    overflow-x: auto;
  }

  .list-table__row {
    min-width: 950px;
  }
}
