:root {
  --bg: #05251f;
  --bg-2: #0b3c34;
  --panel: #d8fff0;
  --panel-2: #aef0d5;
  --panel-3: #6bc7ab;
  --ink: #062c28;
  --muted: #3b6a61;
  --line: #095547;
  --shadow: rgba(0, 0, 0, .35);
  --glow: rgba(123, 255, 204, .55);
  --accent: #ffef6b;
  --accent-2: #59e7ff;
  --danger: #ff6e75;
  --white: #f7fff9;
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--white);
  font-family: var(--font);
  background:
    radial-gradient(circle at 15% 12%, rgba(89, 231, 255, .22), transparent 32%),
    radial-gradient(circle at 82% 7%, rgba(255, 239, 107, .18), transparent 26%),
    linear-gradient(135deg, #031b18 0%, #074034 48%, #031e21 100%);
  overflow-x: hidden;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  opacity: .12;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.15) 0,
    rgba(255,255,255,.15) 1px,
    transparent 1px,
    transparent 5px
  );
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.top-bar,
.layout,
.dex-header,
.panel-title-row,
.top-actions,
.dex-tools,
.dialog-head,
.dialog-actions,
.list-caption,
.detail-top,
.page-nav,
.stat-row,
.chip-row,
.missing-grid,
.character-row,
.world-card,
.timeline-item,
.relation-item {
  display: flex;
}

.top-bar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 2px solid rgba(216, 255, 240, .45);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(8, 83, 70, .8), rgba(5, 45, 40, .9));
  box-shadow: 0 18px 50px var(--shadow), inset 0 1px rgba(255,255,255,.16);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.35rem); letter-spacing: .05em; }
h2 { font-size: 1.2rem; letter-spacing: .04em; }
h3 { font-size: 1rem; color: var(--line); }
.eyebrow {
  color: var(--accent);
  font-weight: 900;
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.soft { opacity: .72; }
.push { flex: 1; }

.button,
.icon-button,
select,
input,
textarea {
  font: inherit;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  font-weight: 900;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.button:hover,
.icon-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.button:active,
.icon-button:active { transform: translateY(1px); }

.button {
  border-radius: 999px;
  padding: 10px 14px;
  color: #05352d;
  background: var(--panel);
  box-shadow: inset 0 -3px rgba(0,0,0,.16), 0 8px 18px rgba(0,0,0,.18);
  white-space: nowrap;
}
.button.primary { background: linear-gradient(180deg, #fff783, #ffd754); }
.button.ghost { background: rgba(216,255,240,.18); color: var(--white); border: 1px solid rgba(216,255,240,.32); }
.button.danger { background: linear-gradient(180deg, #ff9297, #ff6870); color: #3d080c; }
.button.danger.ghost { color: #ffd2d5; background: rgba(255,110,117,.16); border-color: rgba(255,110,117,.35); }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--ink);
  background: var(--accent);
  box-shadow: inset 0 -3px rgba(0,0,0,.18);
}
.top-actions { align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.file-button { display: inline-flex; align-items: center; }

.layout {
  gap: 14px;
  align-items: stretch;
}
.panel {
  border-radius: var(--radius-xl);
  border: 2px solid rgba(216, 255, 240, .45);
  background: linear-gradient(180deg, rgba(9, 84, 72, .88), rgba(5, 44, 39, .92));
  box-shadow: 0 18px 60px var(--shadow), inset 0 1px rgba(255,255,255,.12);
}
.world-panel {
  width: 310px;
  min-width: 290px;
  padding: 16px;
}
.panel-title-row { align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.world-list { display: grid; gap: 10px; }
.world-card {
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 18px;
  border: 2px solid rgba(216,255,240,.26);
  background: rgba(216,255,240,.10);
  color: var(--white);
  cursor: pointer;
}
.world-card.active {
  color: var(--ink);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,239,107,.18), 0 8px 20px rgba(0,0,0,.2);
}
.world-card .arrow { font-size: 1.35rem; color: var(--accent); }
.world-card.active .arrow { color: #057b69; }
.world-card strong { display: block; margin-bottom: 4px; }
.world-card small { display: block; opacity: .8; line-height: 1.55; }

.dex-panel {
  flex: 1;
  min-width: 0;
  padding: 16px;
}
.dex-header { align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dex-tools {
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(216,255,240,.14);
  border: 1px solid rgba(216,255,240,.28);
}
.search-box span {
  color: var(--accent);
  font-weight: 900;
  font-size: .75rem;
  letter-spacing: .12em;
}
input, textarea, select {
  width: 100%;
  border: 2px solid rgba(6, 84, 72, .22);
  border-radius: 12px;
  color: var(--ink);
  background: #f6fff9;
  outline: none;
  padding: 10px 12px;
}
.search-box input {
  color: var(--white);
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
.search-box input::placeholder { color: rgba(255,255,255,.65); }
select {
  max-width: 180px;
  font-weight: 800;
  background: #effff8;
}
.dex-content {
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(0, 1fr);
  gap: 12px;
  min-height: 650px;
}
.character-list-wrap,
.detail-card {
  min-height: 650px;
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  border: 4px solid #effff8;
  box-shadow: inset 0 0 0 3px var(--panel-3), 0 10px 24px rgba(0,0,0,.25);
  overflow: hidden;
}
.list-caption {
  align-items: center;
  justify-content: space-between;
  color: var(--white);
  background: linear-gradient(180deg, #0c7d6d, #07594e);
  padding: 10px 14px;
  font-weight: 900;
  font-size: .83rem;
}
.character-list {
  max-height: 600px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.character-row {
  position: relative;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid rgba(9,85,71,.14);
  background: rgba(255,255,255,.55);
  cursor: pointer;
  box-shadow: inset 0 -2px rgba(0,0,0,.06);
}
.character-row.active {
  background: linear-gradient(180deg, #fffef0, #d6fff0);
  border-color: #09836d;
  box-shadow: 0 0 0 3px rgba(255,239,107,.65), inset 0 -2px rgba(0,0,0,.09);
}
.character-row.active::before {
  content: "▶";
  color: #057b69;
  font-weight: 900;
}
.dex-no {
  min-width: 64px;
  color: #08705f;
  font-weight: 1000;
  letter-spacing: .04em;
}
.character-main { min-width: 0; flex: 1; }
.character-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.character-main small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.missing-badge {
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #05443a;
  background: #d2fff1;
  border: 2px solid rgba(9,85,71,.18);
  font-size: .8rem;
  font-weight: 900;
}

.detail-card { padding: 0; position: relative; }
.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 12px;
  min-height: 650px;
  padding: 28px;
}
.empty-state p { max-width: 410px; color: var(--muted); line-height: 1.8; }
.orb {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 28%, #ffffff, transparent 18%),
    radial-gradient(circle at 50% 60%, #4ff0c7, #067e6e 60%, #04443f);
  border: 6px solid #effff8;
  box-shadow: 0 14px 28px rgba(0,0,0,.26), 0 0 40px var(--glow);
}
.detail-screen {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 650px;
}
.detail-top {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  color: var(--white);
  background: linear-gradient(180deg, #0d8171, #07584d);
}
.detail-name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.detail-name .no { color: var(--accent); font-weight: 1000; letter-spacing: .06em; }
.detail-name h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
  background: #bff9e2;
  border-bottom: 2px solid rgba(9,85,71,.2);
}
.summary-pill {
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  padding: 10px;
  border: 2px solid rgba(9,85,71,.14);
}
.summary-pill span { display: block; color: var(--muted); font-size: .75rem; font-weight: 900; }
.summary-pill strong { display: block; margin-top: 3px; min-height: 1.4em; }
.dex-page {
  padding: 18px;
  overflow: auto;
}
.page-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--white);
  background: #08705f;
  font-weight: 900;
  box-shadow: inset 0 -3px rgba(0,0,0,.16);
  margin-bottom: 14px;
}
.data-box {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.68);
  border: 2px solid rgba(9,85,71,.16);
  box-shadow: inset 0 -3px rgba(0,0,0,.05);
  margin-bottom: 12px;
}
.data-box h3 { margin-bottom: 8px; }
.data-box p,
.data-line,
.timeline-item,
.relation-item { line-height: 1.75; }
.data-line { display: grid; grid-template-columns: 140px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px dashed rgba(9,85,71,.2); }
.data-line:last-child { border-bottom: 0; }
.data-line span:first-child { font-weight: 900; color: #08705f; }
.placeholder { color: #739990; font-weight: 800; }
.chip-row { gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  color: #06443a;
  background: #ddfff4;
  border: 2px solid rgba(9,85,71,.14);
  font-size: .82rem;
  font-weight: 900;
  padding: 3px 9px;
}
.pin-list { display: grid; gap: 8px; }
.pin-item {
  padding: 9px 11px;
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  background: #fffde0;
  font-weight: 800;
}
.missing-grid {
  flex-wrap: wrap;
  gap: 8px;
}
.missing-item {
  border-radius: 999px;
  background: rgba(7,112,95,.10);
  border: 1px dashed rgba(7,112,95,.45);
  color: #08705f;
  padding: 6px 10px;
  font-weight: 900;
  font-size: .82rem;
}
.stat-row { align-items: center; gap: 10px; margin: 8px 0; }
.stat-row span { min-width: 108px; font-weight: 900; color: #08705f; }
.stat-bar {
  flex: 1;
  height: 16px;
  border-radius: 999px;
  background: rgba(9,85,71,.14);
  overflow: hidden;
  border: 1px solid rgba(9,85,71,.18);
}
.stat-fill { height: 100%; background: linear-gradient(90deg, #28c5a1, #ffef6b); border-radius: inherit; }
.timeline-list, .relation-list { display: grid; gap: 10px; }
.timeline-item, .relation-item {
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.68);
  border: 2px solid rgba(9,85,71,.12);
}
.timeline-item strong,
.relation-item strong { color: #08705f; min-width: 86px; }
.relation-item strong { min-width: 100px; }
.page-nav {
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  color: var(--white);
  background: linear-gradient(180deg, #086557, #053e37);
}
.page-dots { display: flex; gap: 7px; align-items: center; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.35);
}
.dot.active { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-button {
  min-width: 96px;
  color: #05352d;
  background: var(--panel);
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px rgba(0,0,0,.16);
}

.editor-dialog {
  width: min(1040px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}
.editor-dialog.small { width: min(560px, calc(100% - 24px)); }
.editor-dialog::backdrop { background: rgba(0, 18, 16, .72); backdrop-filter: blur(6px); }
.editor-form {
  padding: 16px;
  border-radius: 24px;
  border: 4px solid #effff8;
  background: linear-gradient(180deg, #d8fff0, #b6f1da);
  box-shadow: inset 0 0 0 3px var(--panel-3), 0 24px 80px rgba(0,0,0,.45);
}
.dialog-head { align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: min(68vh, 760px);
  overflow: auto;
  padding-right: 4px;
}
.form-section {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.66);
  border: 2px solid rgba(9,85,71,.14);
}
.form-section.wide { grid-column: 1 / -1; }
.form-section h3 { margin-bottom: 10px; }
label { display: grid; gap: 5px; color: #08705f; font-weight: 900; margin-bottom: 10px; }
textarea { resize: vertical; }
.field-row { display: grid; gap: 10px; }
.field-row.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dialog-actions { align-items: center; gap: 10px; margin-top: 14px; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 360px;
  transform: translateY(120%);
  transition: transform .2s ease;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff783;
  border: 3px solid #fffbd0;
  border-radius: 18px;
  box-shadow: 0 14px 28px rgba(0,0,0,.35);
  font-weight: 900;
}
.toast.show { transform: translateY(0); }

@media (max-width: 1080px) {
  .layout { flex-direction: column; }
  .world-panel { width: 100%; min-width: 0; }
  .world-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .dex-content { grid-template-columns: 1fr; }
  .character-list-wrap, .detail-card, .detail-screen, .empty-state { min-height: 420px; }
  .character-list { max-height: 360px; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 16px, 1440px); padding-top: 8px; }
  .top-bar, .dex-header, .dex-tools { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: stretch; }
  .top-actions .button, .dex-header .button { width: 100%; text-align: center; justify-content: center; }
  select { max-width: none; }
  .summary-strip { grid-template-columns: 1fr; }
  .detail-top { flex-direction: column; align-items: stretch; }
  .detail-actions { justify-content: stretch; }
  .detail-actions .button { flex: 1; }
  .data-line { grid-template-columns: 1fr; gap: 2px; }
  .editor-grid { grid-template-columns: 1fr; }
  .field-row.compact { grid-template-columns: 1fr; }
  .page-nav { gap: 8px; }
  .nav-button { min-width: auto; flex: 1; }
}

/* Emerald-style character chooser */
.dex-selector-wrap {
  background:
    linear-gradient(180deg, #f6fff4 0%, #cbf4ce 100%);
}
.dex-selector {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 8px;
  height: 600px;
  padding: 10px;
  background:
    repeating-linear-gradient(0deg, rgba(6, 76, 55, .10) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #d9f6cb, #b1e3a8);
}
.selector-preview,
.selector-list-zone {
  min-width: 0;
}
.selector-preview {
  display: grid;
  align-content: stretch;
}
.preview-frame {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 100%;
  border-radius: 14px;
  border: 3px solid #29572d;
  background:
    linear-gradient(180deg, #eaffd8, #a7dd96);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, .48),
    inset 0 -8px rgba(0, 0, 0, .10),
    0 8px 18px rgba(0, 0, 0, .15);
  padding: 8px;
}
.preview-screen {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  border-radius: 10px;
  border: 2px solid #29572d;
  background:
    radial-gradient(circle at 55% 45%, rgba(255, 255, 255, .8), transparent 13%),
    radial-gradient(circle at 48% 55%, rgba(30, 95, 82, .35), transparent 34%),
    repeating-linear-gradient(0deg, rgba(2, 60, 47, .14) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #a9dfb0, #edfadc 52%, #7ac08f);
}
.preview-screen::after {
  content: "";
  position: absolute;
  inset: auto 14px 12px;
  height: 14px;
  border-radius: 50%;
  background: rgba(5, 49, 43, .22);
  filter: blur(1px);
}
.preview-no,
.preview-name,
.preview-class {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 8px 8px 0;
  padding: 3px 7px;
  border-radius: 8px;
  font-weight: 1000;
  color: #084334;
  background: rgba(255, 255, 235, .82);
  box-shadow: inset 0 -2px rgba(0, 0, 0, .08);
}
.preview-no { font-size: .76rem; }
.preview-name {
  display: block;
  width: fit-content;
  max-width: calc(100% - 16px);
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-class {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  max-width: calc(100% - 16px);
  font-size: .72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-orb {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #062c28;
  font-weight: 1000;
  font-size: 2.4rem;
  background:
    radial-gradient(circle at 34% 25%, #ffffff, transparent 17%),
    radial-gradient(circle at 48% 55%, #bfffe8, #31b58d 55%, #075549 100%);
  border: 4px solid #eaffd8;
  box-shadow: 0 8px 18px rgba(0,0,0,.22), 0 0 24px rgba(255, 239, 107, .35);
}
.preview-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}
.preview-meta div {
  border-radius: 10px;
  border: 1px solid rgba(8, 67, 52, .25);
  background: rgba(255, 255, 245, .68);
  padding: 6px;
}
.preview-meta span {
  display: block;
  color: #08705f;
  font-size: .66rem;
  font-weight: 1000;
}
.preview-meta strong {
  display: block;
  color: #063e34;
  margin-top: 2px;
}
.preview-lines {
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: hidden;
}
.preview-lines p {
  border-left: 5px solid #eb4aa8;
  border-radius: 8px;
  background: rgba(255, 255, 245, .72);
  padding: 6px 7px;
  color: #063e34;
  font-size: .74rem;
  line-height: 1.45;
  font-weight: 800;
}
.empty-preview {
  min-height: 100%;
  place-items: center;
  text-align: center;
  color: #08705f;
  font-weight: 1000;
}
.selector-list-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  min-height: 0;
}
.selector-list-zone .character-list {
  max-height: none;
  height: 100%;
  padding: 7px;
  gap: 4px;
  border-radius: 12px;
  border: 3px solid #29572d;
  background:
    repeating-linear-gradient(0deg, rgba(6, 76, 55, .18) 0 2px, transparent 2px 7px),
    #efffcf;
  scrollbar-width: thin;
  scrollbar-color: #08705f #e4ffc9;
}
.selector-list-zone .character-list::-webkit-scrollbar { width: 9px; }
.selector-list-zone .character-list::-webkit-scrollbar-track { background: #e4ffc9; }
.selector-list-zone .character-list::-webkit-scrollbar-thumb { background: #08705f; border-radius: 999px; }
.selector-list-zone .character-row {
  min-height: 44px;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  color: #073e35;
  background: rgba(255, 255, 230, .72);
  box-shadow: none;
}
.selector-list-zone .character-row.active {
  color: #062c28;
  background: linear-gradient(180deg, #fff783, #ffef6b);
  outline: 3px solid #113f2c;
  outline-offset: -2px;
  box-shadow: inset 0 -3px rgba(0,0,0,.14);
}
.selector-list-zone .character-row.active::before { content: none; }
.dex-cursor {
  width: 18px;
  color: transparent;
  font-weight: 1000;
}
.character-row.active .dex-cursor {
  color: #073e35;
  animation: cursorBlink .8s steps(2, start) infinite;
}
@keyframes cursorBlink {
  50% { opacity: .25; }
}
.selector-list-zone .dex-no {
  min-width: 58px;
  color: #08705f;
  font-size: .88rem;
}
.selector-list-zone .character-main strong {
  font-size: .94rem;
}
.selector-list-zone .character-main small {
  color: #486e4d;
  font-size: .72rem;
}
.selector-list-zone .missing-badge {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border: 0;
  background: #e6ffe0;
  color: #08705f;
  font-size: .72rem;
}
.slider-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: center;
  border-radius: 999px;
  padding: 6px 2px;
  background: linear-gradient(180deg, #f6f69a, #a1d46f);
  border: 3px solid #29572d;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.slider-arrow {
  color: #eb4aa8;
  font-size: .76rem;
  font-weight: 1000;
  line-height: 1;
}
#characterSlider {
  width: 210px;
  accent-color: #eb4aa8;
  writing-mode: vertical-rl;
  direction: rtl;
  padding: 0;
  background: transparent;
  border: 0;
}
#characterSlider:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 1080px) {
  .dex-selector { height: 360px; }
  .preview-screen { min-height: 150px; }
  .preview-orb { width: 70px; height: 70px; font-size: 2rem; }
}

@media (max-width: 720px) {
  .dex-selector {
    grid-template-columns: 1fr;
    height: auto;
  }
  .selector-preview { min-height: 240px; }
  .selector-list-zone {
    grid-template-columns: 1fr;
  }
  .selector-list-zone .character-list {
    height: 300px;
  }
  .slider-shell {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: none;
    min-height: 34px;
    padding: 4px 8px;
  }
  #characterSlider {
    width: 100%;
    writing-mode: horizontal-tb;
    direction: ltr;
  }
}

/* =========================================================
   StoryDex DP v0.3 - smartphone-first Diamond/Pearl inspired skin
   ========================================================= */
:root {
  --dp-orange: #e99114;
  --dp-orange-dark: #a95f04;
  --dp-orange-light: #ffb642;
  --dp-cream: #fff4c8;
  --dp-paper: #fffbe8;
  --dp-green: #63d36d;
  --dp-green-dark: #1f8a4e;
  --dp-blue: #82d8ff;
  --dp-blue-dark: #2584b6;
  --dp-red: #e73c48;
  --dp-ink: #49330f;
  --dp-line: #8f5d0a;
}

html {
  background: #c77a13;
}

body {
  color: var(--dp-ink);
  background:
    radial-gradient(circle at 82% 74%, rgba(255,255,255,.25), transparent 18%),
    linear-gradient(180deg, #f2a422 0%, #da8613 34%, #b85f0a 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.scanlines {
  opacity: .06;
  background-image: repeating-linear-gradient(to bottom, rgba(255,255,255,.18) 0 1px, transparent 1px 4px);
}

.app-shell {
  width: min(430px, calc(100% - 10px));
  padding: 4px 0 10px;
}

.top-bar {
  min-height: 34px;
  margin: 0 0 5px;
  padding: 5px 8px;
  gap: 6px;
  color: #fff7d9;
  border: 2px solid #ffe09b;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, #ffae20, #d97808);
  box-shadow: inset 0 -3px rgba(0,0,0,.18), 0 3px 0 rgba(100,45,0,.28);
}

.top-bar .eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff9d9;
  background: rgba(91, 45, 0, .35);
  font-size: .58rem;
  letter-spacing: .06em;
}

.top-bar h1 {
  font-size: .98rem;
  line-height: 1.1;
  text-shadow: 0 2px rgba(0,0,0,.22);
}

.top-actions {
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
.icon-button,
.nav-button {
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.5);
  box-shadow: inset 0 -2px rgba(0,0,0,.17), 0 2px 0 rgba(84,42,0,.25);
}

.button {
  min-height: 30px;
  padding: 6px 8px;
  font-size: .68rem;
}

.button.primary,
.button.ghost,
.button.danger {
  color: #fffbe7;
  background: linear-gradient(180deg, #5fd770, #24a652);
  border-color: #d8ffe1;
}

.button.danger {
  background: linear-gradient(180deg, #ff7f72, #d73e44);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.panel {
  border-radius: 12px;
  border: 2px solid #ffd783;
  background: #f6a021;
  box-shadow: inset 0 0 0 2px rgba(110,56,0,.38), 0 4px 0 rgba(87,42,0,.26);
}

.world-panel {
  width: 100%;
  min-width: 0;
  padding: 6px;
  order: 2;
}

.panel-title-row {
  margin-bottom: 5px;
}

.panel-title-row h2,
.dex-header h2 {
  color: #fff9dc;
  font-size: .84rem;
  text-shadow: 0 2px rgba(0,0,0,.18);
}

.world-list {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.world-card {
  flex: 0 0 170px;
  min-height: 44px;
  padding: 7px 8px;
  gap: 6px;
  color: #fffce6;
  border: 2px solid rgba(255,255,255,.55);
  border-radius: 12px;
  background: linear-gradient(180deg, #de8f17, #b86106);
  box-shadow: inset 0 -2px rgba(0,0,0,.18);
}

.world-card.active {
  color: #432e09;
  background: linear-gradient(180deg, #fff4a0, #ffc84c);
  border-color: #fff8c9;
}

.world-card small {
  color: inherit;
  opacity: .82;
  font-size: .62rem;
}

.dex-panel {
  overflow: hidden;
  padding: 6px;
  background: linear-gradient(180deg, #e99317, #cf7609);
  order: 1;
}

.dex-header {
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px 7px;
  border-radius: 9px 9px 0 0;
  color: #fff9de;
  background: linear-gradient(180deg, #f6a01b, #dc7c07);
}

.dex-header .eyebrow {
  color: #ffeec2;
  font-size: .56rem;
}

.dex-header .button {
  flex: 0 0 auto;
  min-height: 28px;
}

.dex-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 6px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffbf43, #e0850c);
  border: 2px solid rgba(92,45,0,.25);
  box-shadow: inset 0 -2px rgba(0,0,0,.12);
}

.search-box {
  grid-column: 1 / -1;
  min-height: 36px;
  padding: 5px 8px;
  color: #fff;
  border: 2px solid #dbfff1;
  border-radius: 10px;
  background: linear-gradient(180deg, #72d66c, #27a758);
}

.search-box span {
  color: #eaffdf;
  font-size: .58rem;
}

.search-box input {
  color: #fff;
  font-size: .82rem;
}

select {
  width: 100%;
  max-width: none;
  min-height: 34px;
  padding: 5px 7px;
  color: #fff;
  border: 2px solid #dbfff1;
  border-radius: 10px;
  background: linear-gradient(180deg, #6bd66f, #28a95a);
  font-size: .72rem;
}

.dex-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  min-height: 0;
}

.character-list-wrap,
.detail-card {
  min-height: 0;
  color: #402805;
  border: 2px solid #6f4a08;
  border-radius: 10px;
  background: #f2a31e;
  box-shadow: inset 0 0 0 2px rgba(255,236,154,.42), 0 3px 0 rgba(75,35,0,.22);
}

.list-caption {
  min-height: 24px;
  padding: 3px 8px;
  color: #fff5c7;
  background: linear-gradient(180deg, #d9850d, #ac5d05);
  font-size: .62rem;
}

.dex-selector {
  display: grid;
  grid-template-columns: 39% minmax(0, 61%);
  gap: 5px;
  height: 224px;
  padding: 6px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.22) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #f7aa21, #db7d0b);
}

.selector-preview {
  min-height: 0;
}

.preview-frame {
  min-height: 100%;
  padding: 5px;
  border: 2px solid #805207;
  border-radius: 9px;
  background: linear-gradient(180deg, #ffefb0, #f1a22a);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}

.preview-screen {
  min-height: 112px;
  border: 2px solid #6b83a6;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 58%, rgba(70,92,128,.25), transparent 26%),
    linear-gradient(180deg, #edf7ff, #d8efff);
}

.preview-screen::after {
  inset: auto 16px 10px;
  height: 10px;
  background: rgba(37,55,78,.18);
}

.preview-no,
.preview-name,
.preview-class {
  margin: 4px 4px 0;
  padding: 2px 5px;
  border-radius: 6px;
  color: #3d2b0d;
  background: rgba(255,255,255,.86);
  font-size: .58rem;
}

.preview-name {
  font-size: .78rem;
}

.preview-class {
  bottom: 4px;
  font-size: .56rem;
}

.preview-orb {
  width: 58px;
  height: 58px;
  color: #27364b;
  font-size: 1.55rem;
  border: 3px solid #fff;
  background:
    radial-gradient(circle at 36% 26%, #ffffff, transparent 19%),
    radial-gradient(circle at 55% 58%, #c2efff, #72a7ff 58%, #566fb8 100%);
  box-shadow: 0 6px 9px rgba(0,0,0,.18);
}

.preview-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin: 5px 0;
}

.preview-meta div {
  padding: 4px;
  border-radius: 6px;
  background: rgba(255,255,238,.72);
}

.preview-meta span {
  font-size: .48rem;
  color: #8c5206;
}

.preview-meta strong {
  font-size: .66rem;
}

.preview-lines {
  gap: 3px;
  max-height: 54px;
  overflow: hidden;
}

.preview-lines p {
  padding: 3px 5px;
  border-left: 4px solid #e73c48;
  border-radius: 6px;
  font-size: .56rem;
  line-height: 1.25;
}

.selector-list-zone {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  grid-template-rows: 1fr;
  gap: 4px;
}

.selector-list-zone .character-list {
  height: 100%;
  max-height: none;
  padding: 3px;
  gap: 2px;
  border: 2px solid #6d550c;
  border-radius: 7px;
  background:
    repeating-linear-gradient(0deg, rgba(128,83,8,.18) 0 2px, transparent 2px 6px),
    #fff4b6;
  overflow: hidden;
}

.selector-list-zone .character-row {
  min-height: 25px;
  gap: 4px;
  padding: 3px 5px;
  border-radius: 5px;
  color: #473008;
  background: transparent;
  box-shadow: none;
  font-size: .72rem;
}

.selector-list-zone .character-row.active {
  background: linear-gradient(180deg, #fff5c8, #f9cc69);
  outline: 2px solid #91610b;
  outline-offset: -1px;
  box-shadow: inset 0 -2px rgba(116,65,0,.14);
}

.selector-list-zone .character-row.active::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--dp-red);
  filter: drop-shadow(0 1px rgba(0,0,0,.24));
}

.dex-cursor { display: none; }

.selector-list-zone .dex-no {
  min-width: 44px;
  color: #b65623;
  font-size: .69rem;
}

.selector-list-zone .character-main strong {
  font-size: .74rem;
  line-height: 1.1;
}

.selector-list-zone .character-main small {
  display: none;
}

.selector-list-zone .missing-badge {
  width: 18px;
  min-width: 18px;
  height: 18px;
  color: #fff9d8;
  background: #e06d16;
  font-size: .54rem;
}

.slider-shell {
  width: 18px;
  min-height: 100%;
  padding: 2px 0;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, #fff0a1, #e6b64a);
  box-shadow: inset 0 0 0 2px #9a620b;
}

.slider-arrow {
  color: var(--dp-red);
  font-size: .54rem;
}

#characterSlider {
  width: 166px;
  accent-color: var(--dp-red);
  writing-mode: vertical-rl;
  direction: rtl;
}

.touch-character-nav {
  position: absolute;
  z-index: 2;
  right: 26px;
  bottom: -72px;
  display: grid;
  gap: 12px;
  pointer-events: auto;
}

.touch-round {
  width: 37px;
  height: 37px;
  border-radius: 50%;
  border: 2px solid #586b8f;
  color: #576a96;
  background:
    radial-gradient(circle at 36% 24%, #ffffff 0 15%, transparent 16%),
    linear-gradient(180deg, #e1f6ff, #8cc5f1);
  font-weight: 1000;
  box-shadow: inset 0 -3px rgba(0,0,0,.15), 0 2px 0 rgba(71,45,0,.22);
}

.detail-card {
  position: relative;
  min-height: 318px;
  overflow: hidden;
  background:
    radial-gradient(circle at 91% 47%, #ffffff 0 0, #ffffff 0 19%, #d44a50 20% 39%, transparent 40%),
    radial-gradient(circle at 91% 47%, transparent 0 28%, rgba(73,36,0,.45) 29% 30%, transparent 31%),
    linear-gradient(180deg, #fff5bd, #f2a31e);
}

.detail-card::before {
  content: "";
  position: absolute;
  right: -86px;
  top: 26px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 14%, #6d7a9a 15% 17%, transparent 18%),
    linear-gradient(180deg, #f26b71 0 48%, #6d7a9a 49% 52%, #fff7de 53% 100%);
  opacity: .58;
  border: 8px solid rgba(95,66,9,.34);
}

.detail-screen {
  position: relative;
  z-index: 1;
  min-height: 318px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.detail-top {
  min-height: 34px;
  padding: 5px 7px;
  color: #fff9df;
  background: linear-gradient(180deg, #f29a18, #c96506);
}

.detail-name .no {
  color: #fff4a0;
  font-size: .78rem;
}

.detail-name h2 {
  font-size: 1rem;
}

.detail-actions .button {
  min-height: 25px;
  padding: 4px 7px;
  font-size: .6rem;
}

.summary-strip {
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 5px;
  background: rgba(255,213,108,.7);
}

.summary-pill {
  min-height: 38px;
  padding: 5px;
  border: 1px solid rgba(129,77,5,.25);
  border-radius: 8px;
  background: rgba(255,255,240,.72);
}

.summary-pill span {
  color: #a86106;
  font-size: .5rem;
}

.summary-pill strong {
  font-size: .64rem;
  line-height: 1.2;
}

.dex-page {
  max-height: 190px;
  padding: 8px;
}

.page-title {
  margin-bottom: 6px;
  padding: 5px 9px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(180deg, #6bd66f, #24a653);
  font-size: .72rem;
}

.data-box {
  margin-bottom: 6px;
  padding: 8px;
  border: 2px solid rgba(130,80,9,.22);
  border-radius: 10px;
  background: rgba(255,255,239,.82);
}

.data-box h3 {
  margin-bottom: 4px;
  font-size: .78rem;
}

.data-box p,
.data-line,
.timeline-item,
.relation-item {
  font-size: .74rem;
  line-height: 1.5;
}

.data-line {
  grid-template-columns: 78px 1fr;
  gap: 4px;
  padding: 3px 0;
}

.data-line span:first-child,
.timeline-item strong,
.relation-item strong {
  color: #a35d06;
}

.chip {
  min-height: 22px;
  padding: 2px 7px;
  color: #fff9dc;
  border: 1px solid rgba(255,255,255,.55);
  background: linear-gradient(180deg, #6bd66f, #24a653);
  font-size: .64rem;
}

.pin-item,
.timeline-item,
.relation-item {
  padding: 6px 7px;
  border-radius: 8px;
  background: rgba(255,255,246,.78);
}

.pin-item {
  border-left-color: var(--dp-red);
  font-size: .72rem;
}

.missing-item {
  padding: 4px 7px;
  color: #a55f08;
  background: rgba(255,255,255,.5);
  font-size: .64rem;
}

.stat-row {
  margin: 4px 0;
  gap: 6px;
}

.stat-row span {
  min-width: 74px;
  color: #a35d06;
  font-size: .7rem;
}

.stat-bar {
  height: 11px;
  border-color: rgba(148,92,9,.25);
}

.stat-fill {
  background: linear-gradient(90deg, #58d86c, #ffcc4f);
}

.page-nav {
  min-height: 43px;
  gap: 6px;
  padding: 6px 8px;
  background: transparent;
}

.nav-button {
  min-width: 72px;
  color: #fff9df;
  background: linear-gradient(180deg, #69d76d, #23a553);
  font-size: .7rem;
}

.dot {
  width: 8px;
  height: 8px;
  background: rgba(97,63,9,.32);
}

.dot.active {
  background: #4aaeea;
  box-shadow: 0 0 0 2px #fff, 0 0 8px #4aaeea;
}

.editor-dialog {
  width: min(420px, calc(100% - 10px));
  max-height: calc(100vh - 10px);
}

.editor-form {
  padding: 10px;
  border: 2px solid #ffd783;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff2b8, #f0a225);
  box-shadow: inset 0 0 0 2px rgba(110,56,0,.26), 0 12px 38px rgba(0,0,0,.4);
}

.editor-grid {
  grid-template-columns: 1fr;
  gap: 7px;
  max-height: min(70vh, 640px);
}

.form-section {
  padding: 9px;
  border-radius: 10px;
  background: rgba(255,255,241,.82);
  border-color: rgba(130,80,9,.22);
}

.field-row.compact {
  grid-template-columns: 1fr;
}

label {
  color: #9b5908;
  font-size: .78rem;
}

input,
textarea,
select {
  font-size: 16px;
}

.toast {
  left: 10px;
  right: 10px;
  bottom: 10px;
  max-width: none;
  border-radius: 10px;
  background: #fff3a2;
}

@media (min-width: 760px) {
  .app-shell {
    width: min(520px, calc(100% - 32px));
  }
  .dex-selector {
    height: 250px;
  }
  .selector-list-zone .character-row {
    min-height: 29px;
  }
  .detail-card,
  .detail-screen {
    min-height: 360px;
  }
  .dex-page {
    max-height: 230px;
  }
}

@media (max-width: 370px) {
  .dex-selector {
    grid-template-columns: 38% minmax(0, 62%);
    height: 214px;
  }
  .preview-orb {
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
  }
  .selector-list-zone .dex-no {
    min-width: 39px;
    font-size: .63rem;
  }
  .selector-list-zone .character-main strong {
    font-size: .68rem;
  }
  .touch-character-nav {
    right: 24px;
  }
}

/* DP skin fixes over earlier mobile rules */
.top-bar,
.dex-header,
.detail-top {
  flex-direction: row;
  align-items: center;
}
.top-actions .button,
.dex-header .button,
.detail-actions .button {
  width: auto;
  flex: 0 0 auto;
  justify-content: center;
}
.detail-actions {
  justify-content: flex-end;
}
