:root {
  color-scheme: dark;
  --bg: #121418;
  --bg-2: #1a1f27;
  --panel: #1f2630;
  --text: #e7edf5;
  --muted: #9aa8b9;
  --line: #2e3947;
  --accent: #5fb0ff;
  --ok: #7be495;
  --warn: #ffd166;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-2: #eaf0f8;
  --panel: #ffffff;
  --text: #1f2a37;
  --muted: #5b6b7f;
  --line: #d6deea;
  --accent: #216ff3;
  --ok: #0d9f4f;
  --warn: #b37400;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 1120px;
}

.topbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.clock-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-controls {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
}

input,
select,
button,
textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

button {
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}

#center-now span {
  width: 21px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

#center-now span::after {
  content: "";
  width: 5px;
  height: 5px;
  position: absolute;
  border-radius: 999px;
  background: currentColor;
}

.icon-button.info-button {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-style: italic;
  font-weight: 800;
}

input[type="search"] {
  min-width: 520px;
  width: min(58vw, 760px);
  font-size: 15px;
  padding: 8px 10px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
}

.theme-toggle-topbar {
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}

.theme-toggle-topbar input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-icon {
  display: none;
}

body[data-theme="light"] .theme-icon.sun {
  display: inline;
}

body[data-theme="dark"] .theme-icon.moon {
  display: inline;
}

.patch-filter {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  padding: 6px 14px;
  height: 38px;
  display: flex;
  align-items: center;
  z-index: 30;
}

.patch-filter details {
  position: relative;
}

.patch-filter summary {
  cursor: pointer;
}

.patch-filter details[open] summary {
  margin-bottom: 0;
}

#patch-list {
  display: none;
}

.patch-filter details[open] #patch-list {
  display: grid;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(1180px, calc(100vw - 28px));
  max-height: 62vh;
  overflow: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: grid;
  gap: 10px;
}

.patch-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.patch-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.patch-group-header button {
  padding: 4px 8px;
  font-size: 12px;
  min-width: 200px;
  text-align: left;
}

.patch-group-patches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.patch-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.layout {
  --fish-pane-width: 320px;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--fish-pane-width) 8px 1fr;
}

.fish-pane {
  min-height: 0;
  background: var(--bg-2);
  position: relative;
}

#pane-resizer {
  cursor: col-resize;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

#pane-resizer:hover {
  background: rgba(95, 176, 255, 0.18);
}

.fish-header {
  height: 34px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
}

#fish-rows {
  position: relative;
  overflow: hidden;
  height: calc(100% - 34px);
}

.fish-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 36px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
}

.fish-row .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.fish-row.intuition-child {
  background: rgba(255, 255, 255, 0.02);
}

.req-count {
  min-width: 24px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}

.child-indent {
  width: 52px;
  flex: 0 0 auto;
}

.item-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #000;
  object-fit: cover;
  flex: 0 0 auto;
}

.fish-row button {
  padding: 2px 6px;
  font-size: 12px;
}

.fish-row .pin.active,
.fish-row .caught.active {
  border-color: var(--accent);
  color: var(--accent);
}

.timeline-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 34px 1fr;
}

.time-header {
  border-bottom: 1px solid var(--line);
  position: relative;
  background: var(--bg-2);
}

#header-canvas {
  width: 100%;
  height: 34px;
  display: block;
}

#timeline-scroll {
  position: relative;
  overflow: auto;
  background: var(--bg);
}

#timeline-virtual {
  position: relative;
}

#timeline-canvas {
  position: absolute;
  inset: 0 auto auto 0;
  pointer-events: none;
}

.timeline-tooltip {
  position: fixed;
  z-index: 1200;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  max-width: 360px;
  white-space: nowrap;
}

.timeline-tooltip .k {
  color: var(--muted);
  margin-right: 6px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(860px, calc(100vw - 20px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dialog-card {
  margin: 0;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.dialog-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fish-title {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.fish-title .item-icon {
  width: 28px;
  height: 28px;
}

.fish-title-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

#dialog-fish-name {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.1;
}

.dialog-card h2,
.dialog-card h3 {
  margin: 0;
  font-size: 16px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-grid > label,
.settings-group {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.settings-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented-control button {
  position: relative;
  border-radius: 999px;
  padding: 8px 13px;
  background: color-mix(in srgb, var(--panel) 86%, var(--bg));
  color: var(--muted);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    color 120ms ease,
    background 120ms ease;
}

.segmented-control button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  font-weight: 700;
}

.segmented-control button.active::before {
  content: "✓";
  margin-right: 6px;
  font-weight: 800;
}

.settings-io-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-io-actions button {
  border-radius: 999px;
  padding: 8px 12px;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-note a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.about-block {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.about-block:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.about-block p {
  margin: 6px 0;
}

.about-block a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.about-footer {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.fish-meta {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
}

#dialog-fish-meta-fields {
  display: grid;
  gap: 6px;
}

.meta-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 8px;
  font-size: 15px;
  align-items: center;
}

.meta-row .label {
  color: var(--muted);
  font-size: 14px;
}

.bait-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bait-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px 2px 2px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}

.bait-arrow {
  font-size: 16px;
  color: var(--muted);
  align-self: center;
}

.hookset-tug {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hookset-pill,
.tug-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 13px;
}

.tug-pill.heavy {
  color: #ffb3b3;
  border-color: #d68a8a;
}

.tug-pill.light {
  color: #9edff7;
  border-color: #7dbbcf;
}

.tug-pill.medium {
  color: #b8e9b6;
  border-color: #94c693;
}

.map-preview-wrap {
  position: relative;
}

#dialog-map-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}

.map-status {
  position: absolute;
  inset: auto 10px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #e7edf5;
  font-size: 13px;
  text-align: center;
}

#dialog-windows {
  max-height: 350px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.window-row {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  font-size: 13px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.window-row:last-child {
  border-bottom: 0;
}

.window-row .downtime {
  color: var(--muted);
  white-space: nowrap;
}

textarea#io-text {
  width: 100%;
  resize: vertical;
}
