:root{
  --bg:#ffffff;
  --panel:#f0f0f0;
  --muted:#6b6b6b;
  --text:#111;
  --accent:#2b7cff;
  --accentT: color-mix(in srgb, var(--accent) 20%, transparent);
  --danger:#c24;
  --success:#0a0;
  --radius:10px;
  --topbar-h:56px;
}

body.dark{
  --bg:#0f1113;
  --panel:#23282d;
  --muted:#9a9a9a;
  --text:#e9eef6;
  --accent:#488eff;
  --accentT: color-mix(in srgb, var(--accent) 20%, transparent);
}

*{box-sizing:border-box}
html,body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto}
body{background:var(--bg);color:var(--text);overflow-x:hidden}

/* Top bar */
.topbar{
  position:sticky;
  top:0;
  height:var(--topbar-h);
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 16px;
  background:var(--panel);
  z-index:500;
}

.brand{font-weight:700; flex:1;}

.togglelightdark{
  justify-content: flex-end;
}

.togglelightdark:hover{
  background: var(--accentT)
}

/* Drawer */
.sidebar{
  position:fixed;
  top:var(--topbar-h);
  left:0;
  height:calc(100vh - var(--topbar-h));
  width:260px;
  background:var(--panel);
  padding:16px;
  transform:translateX(-100%);
  transition:transform .25s ease;
  z-index:600;
}

.sidebar.open{transform:translateX(0)}

.drawer-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.4);
  opacity:0;
  pointer-events:none;
  transition:.25s;
  z-index:550;
}

.drawer-overlay.open{
  opacity:1;
  pointer-events:auto;
}

/* Content */
.content{
  display:flex;
  flex-direction:column;
  gap:20px;
}

/* Buttons */
.btn{
  min-height:44px;
  padding:10px 14px;
  border:none;
  border-radius:8px;
  background:var(--accent);
  color:#fff;
  cursor:pointer;
}

.btn--tertiary{
  background:color-mix(in srgb, var(--accent) 70%, var(--bg));
  color:var(--text);
  
}

.btn--secondary{
  background:transparent;
  border:1px solid rgba(0,0,0,.2);
  color:var(--text);
}

.btn--ghost{
  background:transparent;
  border:none;
  color:var(--text);
}

.btn--panel{
  background:var(--panel);
  color:var(--text);
}

/* Lists */
.tool-list{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.tool-list__item{
  padding:12px;
  cursor:pointer;
}

.tool-list__item.active{
  background:var(--accentT);
}

/* Color tool */
.line-list{display:flex;flex-direction:column;gap:10px}

.lineRow{
  display:flex;
  gap:8px;
  align-items:center;
  background:var(--panel);
  padding:10px;
  border-radius:8px;
}

.lineRow.dragging {
  opacity: 0.6;
  background: rgba(255,255,255,0.08);
}

.dragHandle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: inline-block;   /* Ensure it's visible */
}

.dragHandle:active {
  cursor: grabbing;
}

.lineText{
  flex:1;
  padding:10px;
  border-radius:6px;
  border:1px solid rgba(0,0,0,.2);
  background:transparent;
  color:var(--text);
}

.preview{
  background:var(--panel);
  padding:12px;
  border-radius:8px;
  word-break:break-word;
}

.formatted{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.formatted__pre{
  background:var(--panel);
  padding:12px;
  border-radius:8px;
  white-space:pre-wrap;
}

/* Move checker */
.mc-input{
  width:100%;
  padding:10px;
  border-radius:8px;
  border:1px solid rgba(0,0,0,.2);
}

.mc-search-wrapper{position:relative}

.mc-autocomplete{
  position:absolute;
  top:100%;
  left:0;
  right:0;
  background:var(--panel);
  border:1px solid rgba(0,0,0,.2);
  max-height:200px;
  overflow-y:auto;
  z-index:300; /* below sidebar */
}

.mc-autocomplete div{
  padding:6px;
  cursor:pointer;
}

.mc-autocomplete div:hover, .mc-autocomplete div.active{
  background:rgba(0,0,0,.1);
}

/* Filters */
.filters-panel {
  background: color-mix(in srgb, var(--accentT) 50%, var(--bg));
  border-radius: 20px;
  padding: 5px;
  padding-left: 15px;
  margin-bottom: 6px;

  display: flex;
  flex-direction: column;

  overflow: hidden;

  /* animation properties */
  max-height: 1000px;          /* large enough to fit content */
  opacity: 1;
  transform: translateY(0);

  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    transform 0.25s ease;
}

/* Hidden state */
.filters-panel.collapsed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  padding-top: 0;
  padding-bottom: 0;
}



.mc-filters{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.mc-filters label{
  display:flex;
  align-items:center;
  gap:4px;
  cursor:pointer;
}

.filter-box{
  display:inline-block;
  width:20px;
  height:20px;
  text-align:center;
  border:none;
}

/* Pokemon results */
.pokemon-result{
  display:flex;
  gap:12px;
  align-items:flex-start;
  background:color-mix(in srgb, var(--panel) 40%, var(--accentT));
  padding:10px;
  border-radius:8px;
}

.pokemon-result img{
  width:72px;
  height:72px;
  object-fit:contain;
}

.method{
  color:var(--accent);
  font-weight:700;
}

/* Encounter Tool */
.encounter-controls{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.encounter-card{
  background:var(--panel);
  padding:12px;
  border-radius:8px;
  margin-bottom:8px;
  line-height:1.4;
}

.encounter-controls {
  position: relative;
}

/* Encounter toggle */
/* ===============================
   Encounter Controls / Layout
   =============================== */

.encounter-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.encounter-card {
  background: var(--panel);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* ===============================
   Search Mode Toggle
   =============================== */

.encounter-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.encounter-top-1, .encounter-top-2 {
  display: flex;
  align-items: left;
  flex-wrap: wrap;
  gap: 8px;
}

.encounter-top-2 > * {
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.encounter-preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.encounter-toggle {
  position: relative;
  display: flex;
  width: 160px;
  height: 38px;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}

.encounter-toggle span {
  flex: 1;
  text-align: center;
  line-height: 38px;
  color: var(--muted);
  z-index: 1;
}

.encounter-toggle span.active {
  color: var(--text);
  font-weight: 600;
}

.toggle-slider {
  position: absolute;
  inset: 3px;
  width: calc(50% - 4px);
  background: var(--accentT);
  border-radius: 6px;
  transition: transform 0.2s ease;
}

.encounter-toggle[data-mode="location"] .toggle-slider {
  transform: translateX(100%);
}

/* ===============================
   Table + Virtualization
   =============================== */

.scrollable-table {
  height: calc(100vh - 300px);
  min-height: 300px;
  overflow-y: auto;
  position: relative;
}

.mc-table {
  width: 100%;
  border-collapse: collapse;
}

.mc-table th,
.mc-table td {
  padding: 10px;
  border-right: 1px solid var(--panel);
  border-bottom: 1px solid var(--panel);
  white-space: nowrap;
  vertical-align: middle;
  --enc-row-height: 40px;
  height: var(--enc-row-height); /* MUST match ROW_HEIGHT */
}

.mc-table th {
  cursor: pointer;
}

.mc-table img {
  height: 80px;
  image-rendering: pixelated;
}

#encounterTable  {
  background: color-mix(in srgb, var(--panel) 10%, transparent);
  
}

#encounterTable th {
  background: color-mix(in srgb, var(--accent) 70%, var(--bg));
  position: sticky;
  top: 0px;
  z-index: 5;
}

#encounterTable td, #encounterTable th, #encounterTable table{
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-collapse: collapse;
}

/* ===============================
   Pokémon Cell
   =============================== */

.pokemon-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--enc-row-height);
}

/* ===============================
   Column Filters
   =============================== */

#columnFilters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

/* ===============================
   Optimized Mode Toggle
   =============================== */

.optimized-toggle {
  display: flex;
  align-items: center;
}

.opt-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.opt-label input {
  display: none;
}

.opt-slider {
  width: 42px;
  height: 22px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.opt-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.opt-label input:checked + .opt-slider {
  background: var(--accent);
}

.opt-label input:checked + .opt-slider::after {
  transform: translateX(20px);
}

/* ===============================
   Tooltip (Desktop + Mobile)
   =============================== */

.opt-tooltip {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.opt-tooltip-text {
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  background: #222;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 9999;
}

/* Desktop hover */
.opt-tooltip:hover .opt-tooltip-text,
.opt-tooltip:focus-within .opt-tooltip-text {
  opacity: 1;
}

th {
  position: relative;
}

.col-close {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 11px;
  opacity: 0.6;
  cursor: pointer;
}

.col-close:hover {
  opacity: 1;
}

.preset_label {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
}

.porysiteImage {
  border: none;
  background: none;
  cursor: pointer;

  display: flex;
  flex-direction: column;   /* stack image + text */
  align-items: center;
  justify-content: center;

  padding: 6px 8px;
  text-decoration: none;
  color: var(--text);
  border-radius: 6px;
}

.porysiteImage:hover {
  background: var(--accentT);
}


.porysiteImage img{
  height:calc(var(--topbar-h)/2);
}

.canvasWrapper {
  margin-top: 15px;
  border: 1px solid #333;
  display: inline-block;
  position: relative;
}

#hiddenCanvas {
  display: block;
  width: 100%;
  cursor: crosshair;
}

.toolRow {
  margin-top: 12px;
}

#thresholdValue {
  margin-left: 8px;
  font-weight: bold;
}

.progressWindow {
  max-height: 100px;
  max-width: fit-content;
  overflow:scroll; 
  font-size:0.9em; 
  color:var(--text);
  margin-top:0.5em; 
  border:var(--accentT); 
  padding:5px; 
  background:var(--panel);
}

.linkMenu {
  position: relative;
  display: inline-block;
}

.linkDropdown {
  position: absolute;
  top: 100%;
  right: 0;
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  background: var(--panel, #222);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: 0.2s ease;
}


.linkDropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.linkDropdown img {
  height: 24px;
  width: auto;
}

.linkLabel {
  font-size: 0.65rem;
  margin-top: 4px;
  opacity: 0.75;
  white-space: nowrap;
}

#poryBackground {
  --porybg: var(--bg);
  padding: 0px;
}

/* Base tool section */
.toolSection {
  position: relative;
  z-index: 1;
  padding: 16px;
}

/* Sections that should have glass effect */
body.pory-active .toolSection {
  background: color-mix(in srgb, var(--bg) 50%, transparent);
}

/* Dedicated background section (no translucency) */
body.pory-full #poryBackground {
  background: var(--bg);
}

.about-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* Responsive cards */
.about-card {
  flex: 1 1 320px;   /* grows, shrinks, base width */
  max-width: 700px;  /* prevents huge stretching */
  min-width: 320px;  /* prevents squishing */
  max-height: 700px;
  overflow: hidden;

  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 12px;
  padding: 10px;

  display: flex;
  flex-direction: column;
}

/* Tool container */
.about-tool-slot {
  margin-top: 0px;
  flex: 1;
  min-height: 200px;
  border-top: 1px solid rgba(0,0,0,0.1);
  padding-top: 0px;
  overflow: auto;
}

/* Make embedded tools cleaner */
.about-card .toolHeader {
  display: none;
}

/* Prevent giant tables from breaking layout */
.about-card table {
  font-size: 0.85rem;
}