/* Power DevBox "Console" design system.
   Taken from CopilotReview Pro and shared by the workspace and every reviewer.
   Neutral palette lives here; each tool sets only its accent variables:
   --accent, --accent-deep, --accent-soft, --accent-bright, --accent-strong, --accent-shade.
   Light by default, .dark-mode on <html> switches palettes. */

:root {
  --charcoal: #24282c;
  --charcoal-2: #2f3439;
  --charcoal-3: #3b4147;
  --menu-ink: #e6ecec;
  --menu-muted: #9fb2b3;
  --canvas: #eef2f2;
  --card: #ffffff;
  --card-2: #f6f9f9;
  --ink: #1f2a2c;
  --muted: #687679;
  --line: #dde5e5;
  --amber: #f4a63a;
  --amber-soft: #fff4e3;
  --red: #e2574c;
  --red-soft: #fde4e1;
  --green: #22b07d;
  --flag-error: #fde4e1;
  --flag-warning: #fff4e3;
  --shadow: 0 6px 24px rgba(20, 40, 42, 0.07);
  --shadow-pop: 0 12px 40px rgba(20, 40, 42, 0.22);
  --font: "Albert Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --radius: 10px;
  --transition: 140ms ease;

  /* Workspace accent (neutral). Reviewers override these. */
  --accent: #24282c;
  --accent-deep: #000000;
  --accent-soft: #e6ecec;
  --accent-bright: #ffffff;
  --accent-strong: #3b4147;
  --accent-shade: #2f3439;
  --on-accent: #ffffff;

  /* Reviewer colours, used wherever the workspace refers to a tool. */
  --tool-app: #8e4ec6;
  --tool-app-bright: #cf9ff5;
  --tool-auto: #0b63b6;
  --tool-auto-bright: #7cc0ff;
  --tool-copilot: #0f8b8d;
  --tool-copilot-bright: #5ce1cf;
  --tool-solutions: #c77a1a;
  --tool-solutions-bright: #f4c27a;
}

.dark-mode {
  --charcoal: #15181a;
  --charcoal-2: #1f2326;
  --charcoal-3: #2c3236;
  --canvas: #1b1f22;
  --card: #24292d;
  --card-2: #1f2427;
  --ink: #e6ecec;
  --muted: #98a6a9;
  --line: #343b40;
  --amber-soft: #3d3220;
  --red-soft: #45272a;
  --flag-error: #45272a;
  --flag-warning: #3d3220;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.5);

  --accent: #e6ecec;
  --accent-deep: #ffffff;
  --accent-soft: #2c3236;
  --accent-bright: #ffffff;
  --accent-strong: #2c3236;
  --accent-shade: #1f2326;
  --on-accent: #15181a;

  --tool-app: #b583e6;
  --tool-auto: #4c9ee8;
  --tool-copilot: #2bb3b1;
  --tool-solutions: #e69a3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
}

input,
select,
textarea {
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

button {
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

button:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

/* Keep the default contrast rule weaker than component-specific hover colours. */
:where(.dark-mode) button:hover {
  color: var(--charcoal);
}

button:focus-visible,
.menu-link:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button.ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ---------- Top nav (page header) ---------- */
.top-nav {
  background: var(--charcoal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 20;
  min-width: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin: 0;
}

.app-logo-img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: contain;
}

.header-filter {
  flex: 0 1 560px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.header-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.filter-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--charcoal-2);
  border: 1px solid var(--charcoal-3);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--menu-muted);
  min-width: 0;
}

.filter-input-wrapper:focus-within {
  border-color: var(--accent-bright);
}

.filter-input-wrapper input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  padding: 9px 0;
  outline: none;
}

.filter-input-wrapper input::placeholder {
  color: #8d999b;
}

.header-filter button,
.top-nav .header-tool {
  background: var(--charcoal-2);
  border-color: var(--charcoal-3);
  color: #fff;
  padding: 8px 12px;
}

.header-filter button:hover,
.top-nav .header-tool:hover {
  background: var(--accent-strong);
  border-color: var(--accent-bright);
  color: #fff;
}

.filter-intellisense {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
}

.filter-intellisense.visible {
  display: block;
}

.filter-intellisense li {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.88rem;
}

.filter-intellisense li:hover,
.filter-intellisense li.selected {
  background: var(--accent);
  color: var(--on-accent);
}

.filter-intellisense .operator-symbol {
  font-family: var(--mono);
  font-weight: 600;
  margin-right: 8px;
}

.filter-intellisense .operator-desc {
  opacity: 0.8;
  font-size: 0.85em;
}

.nav-right {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
}

.who {
  font-size: 0.85rem;
  color: #c7d0d1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.who:empty {
  display: none;
}

.tabs-actions {
  display: flex;
  gap: 4px;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 1.05rem;
  padding: 0;
  text-decoration: none;
}

.nav-icon:hover,
.nav-icon[aria-expanded="true"] {
  background: var(--charcoal-2);
  color: var(--accent-bright);
}

/* ---------- Shell (left menu + main) ---------- */
.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 0;
}

.left-menu {
  background: var(--charcoal);
  color: #fff;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.menu-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px 12px;
}

.menu-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 2px 10px;
}

.menu-heading h2,
.menu-label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.menu-search {
  width: 100%;
  margin: 0 0 10px;
  background: var(--charcoal-2);
  border-color: var(--charcoal-3);
  color: #fff;
}

.menu-search::placeholder {
  color: #8d999b;
}

.menu-search:focus {
  outline-color: var(--accent-bright);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--charcoal-2);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.drop-zone:hover,
.drop-zone.drag-over {
  background: var(--charcoal-3);
  border-color: var(--accent-bright);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin: 6px 2px 4px;
}

.status {
  flex: 1;
  margin: 0;
  font-size: 0.75rem;
  color: var(--menu-muted);
}

.status.error {
  color: #ff9a8f;
}

.agent-empty,
.menu-empty {
  font-size: 0.85rem;
  color: var(--menu-muted);
  line-height: 1.5;
}

/* Selected item card at the top of a reviewer menu (agent, app, flow). */
.agent-pick {
  width: 100%;
  margin: 8px 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--charcoal-2);
  color: #fff;
  text-align: left;
  font-weight: 400;
}

.agent-pick.current,
.agent-pick.active {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-shade));
}

.agent-pick:hover {
  background: var(--charcoal-3);
  border-color: var(--accent-bright);
  color: #fff;
}

.agent-pick.current:hover,
.agent-pick.active {
  border-color: var(--accent-bright);
}

.agent-pick img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.agent-pick-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.agent-pick-text strong {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-pick-text span {
  font-size: 0.74rem;
  color: var(--menu-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.menu .group {
  margin: 14px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.92rem;
  color: var(--menu-ink);
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.menu-link i {
  width: 18px;
  text-align: center;
  color: var(--menu-muted);
}

.menu-link:hover {
  background: var(--charcoal-2);
  color: var(--menu-ink);
}

.menu-link.active {
  background: var(--accent-strong);
  color: #fff;
}

.menu-link.active i {
  color: #fff;
}

.menu-link em {
  margin-left: auto;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--menu-muted);
  font-family: var(--mono);
}

.menu-link.active em {
  color: #fff;
}

.menu-link em.hot {
  background: var(--amber);
  color: var(--charcoal);
  padding: 0 7px;
  border-radius: 10px;
  font-weight: 600;
}

.settings-container {
  position: relative;
  flex: none;
  padding-top: 8px;
  border-top: 1px solid var(--charcoal-2);
}

.settings-cog {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  padding: 4px 6px;
  color: #c7d0d1;
  transition: transform 0.3s ease, color var(--transition);
}

.settings-cog:hover {
  background: transparent;
  color: var(--accent-bright);
  transform: rotate(45deg);
}

.settings-dropdown {
  position: absolute;
  bottom: 44px;
  left: 0;
  min-width: 290px;
  display: none;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 50;
}

.settings-dropdown.show {
  display: flex;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 15px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}

.settings-item:hover,
.settings-item:focus {
  background: var(--card-2);
  color: var(--ink);
  outline: none;
}

.settings-item i {
  width: 18px;
  color: var(--accent);
}

/* ---------- Main content / tabs ---------- */
.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 22px 22px;
  overflow: hidden;
}

.tabs-container {
  display: flex;
  align-items: flex-end;
  min-height: 40px;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: none;
}

.tab:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--ink);
}

.tab[aria-hidden="true"] {
  display: none;
}

.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: inset 0 3px 0 var(--accent);
}

.tab i {
  color: var(--accent);
}

.tab-close {
  margin-left: 4px;
  width: 18px;
  height: 18px;
  line-height: 17px;
  text-align: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.95rem;
}

.tab-close:hover {
  background: var(--line);
  color: var(--ink);
}

.tab-content {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}

.tab-content[aria-hidden="false"] {
  display: flex;
}

.tab-content > * {
  flex-shrink: 0;
}

.tab-content > .diagram-wrapper {
  flex: 1 1 auto;
}

.tab-content > h2,
.card-title h2 {
  margin: 0 6px 18px 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tab-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  min-width: 170px;
  padding: 4px 0;
  overflow: hidden;
}

.tab-context-menu-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

.tab-context-menu-item:hover {
  background: var(--card-2);
  color: var(--ink);
}

/* ---------- Card content ---------- */
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.card-title h2 {
  margin-bottom: 0;
}

.card-title img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.card-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-link {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 6px 12px;
}

.tab-link i {
  color: var(--accent);
}

.tab-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  white-space: nowrap;
}

.chip.muted {
  background: var(--card-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.chip.strong {
  background: var(--charcoal);
  color: #fff;
}

.chip.hot {
  background: var(--red-soft);
  color: var(--red);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
}

.stat.warn {
  border-top-color: var(--amber);
}

.tab-content .stat h3,
.stat h3 {
  margin: 0;
  padding: 0;
  border: none;
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  position: relative;
  z-index: 1;
}

.stat i {
  position: absolute;
  right: -6px;
  bottom: -10px;
  font-size: 4rem;
  color: var(--accent);
  opacity: 0.08;
}

.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.info-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--card);
  min-width: 0;
}

.info-panel.wide {
  grid-column: span 2;
}

.info-panel.alert-panel {
  border-left: 4px solid var(--red);
}

.info-panel h2,
.tab-content h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.tab-content h3 {
  margin-top: 20px;
  align-self: flex-start;
}

.panel h3,
.info-panel h3 {
  margin-top: 0;
}

.info-panel h2.spaced {
  margin-top: 18px;
}

.info-panel p {
  font-size: 0.88rem;
  color: var(--muted);
}

.info-panel .link {
  display: block;
  padding: 5px 0;
  text-decoration: none;
  color: var(--ink);
}

.info-panel .link i {
  color: var(--accent);
  width: 18px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.88rem;
}

.info-item span {
  color: var(--muted);
  flex-shrink: 0;
}

.info-item b {
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.hot {
  color: var(--red);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.88rem;
}

.toggle-row > i,
.settings-toggle .toggle-slider {
  flex-shrink: 0;
  width: 34px;
  height: 18px;
  border-radius: 10px;
  background: #cfd8d9;
  position: relative;
  transition: background var(--transition);
}

.dark-mode .toggle-row > i,
.dark-mode .settings-toggle .toggle-slider {
  background: #4a5357;
}

.toggle-row > i::after,
.settings-toggle .toggle-slider::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: left var(--transition);
}

.toggle-row.on > i,
.settings-toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-row.on > i::after,
.settings-toggle input:checked + .toggle-slider::after {
  left: 18px;
}

.settings-toggle {
  cursor: pointer;
  border-bottom: 1px dashed var(--line);
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-toggle span i {
  color: var(--accent);
  width: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 24px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.panels-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panels-container input {
  flex: 1;
}

.bar {
  display: flex;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  margin: 12px 0 14px;
  background: var(--line);
}

.b1 {
  background: var(--accent);
}

.b2 {
  background: var(--accent-bright);
}

.b3 {
  background: #8ca3a6;
}

.b4 {
  background: var(--amber);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.86rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend b {
  margin-left: auto;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4cfd0;
  margin-right: 6px;
}

.dot.on {
  background: var(--green);
}

.panel-link {
  margin: 8px 0 0;
  text-align: right;
}

.panel-link .menu-link {
  display: inline-flex;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 4px;
}

.panel-link .menu-link:hover {
  background: var(--accent-soft);
}

.sideBySide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 4px;
}

.sideBySide > * {
  min-width: 0;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  margin: 0;
  font-size: 0.88rem;
}

.detail-list dt,
.detail-list dd {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.detail-list dt {
  color: var(--muted);
  padding-right: 14px;
}

.detail-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.instructions-block,
.code-block {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 6px;
  max-height: 460px;
  overflow: auto;
}

.code-block {
  max-height: none;
}

.empty-note {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
  margin: 4px 0 10px;
}

.clickable {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.clickable:hover {
  text-decoration: underline;
}

/* ---------- Tables ---------- */
.table-responsive {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.table-responsive th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: transparent;
  padding: 7px 8px;
  border-bottom: 2px solid var(--line);
  vertical-align: bottom;
  overflow-wrap: anywhere;
}

.table-responsive td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table-responsive tbody tr:hover {
  background: var(--card-2);
}

.table-responsive td.empty-cell {
  color: var(--muted);
  font-style: italic;
}

.table-responsive td pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.sort-btn {
  background: none;
  border: none;
  padding: 0 2px;
  margin-left: 4px;
  font-size: 0.6em;
  letter-spacing: -2px;
  color: var(--line);
  vertical-align: middle;
}

.sort-btn:hover,
.sort-btn.sort-asc,
.sort-btn.sort-desc {
  background: none;
  color: var(--accent);
}

/* ---------- Tree ---------- */
.tree-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.tree-controls[hidden] {
  display: none;
}

.tree-controls button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-size: 0.8rem;
}

.tree-controls button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tree-controls input {
  flex: 1;
}

.file-tree {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}

.tree-node i {
  color: var(--accent);
}

.tree-node:hover {
  background: var(--card-2);
}

.tree-node.selected,
.tree-node:focus {
  outline: 1px solid var(--accent);
  background: var(--accent-soft);
}

.children {
  margin-left: 1.1rem;
  border-left: 1px dotted var(--line);
}

.toggle {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}

.folder.expanded > .tree-node > .toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.folder.collapsed > .children {
  display: none;
}

.file.match > .tree-node {
  background: var(--amber-soft);
}

/* ---------- Custom flags ---------- */
.custom-flags-description {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.custom-flags-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.custom-flags-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.custom-flag-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--card-2);
}

.custom-flag-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-flag-name {
  flex: 1;
  font-weight: 600;
}

.custom-flag-code {
  min-height: 200px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
  background: var(--card);
}

.custom-flag-actions {
  display: flex;
  gap: 8px;
}

.custom-flag-delete {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}

.custom-flag-delete:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.results-header h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
}

.level-filter-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

.setting-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.editable-cell {
  cursor: text;
}

.editable-cell:hover {
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  opacity: 0.6;
}

.row-deleting {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.add-row-trigger {
  opacity: 0;
  text-align: center;
  padding: 4px;
  transition: opacity 0.2s ease;
}

.tab-content:hover .add-row-trigger {
  opacity: 1;
}

.add-row-btn {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
}

/* ---------- Drawer (detail modal) and popup ---------- */
.modal {
  position: fixed;
  top: 70px;
  right: 22px;
  bottom: 22px;
  width: min(440px, calc(100vw - 44px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 18px 20px;
  overflow: auto;
  animation: drawerIn 0.2s ease-out;
}

@keyframes drawerIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
}

.modal .close {
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal .close:hover {
  color: var(--ink);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  padding-right: 28px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

#modal-detail {
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

#modal-detail pre {
  white-space: pre-wrap;
  max-width: 100%;
  overflow-x: auto;
}

#modal-detail h3 {
  font-size: 0.9rem;
  margin: 16px 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 40px));
  z-index: 60;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 20px;
}

.popup h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.description {
  width: 100%;
  height: 220px;
  resize: vertical;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0;
}

.popup-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Description cells + full text popup ---------- */
.desc-cell {
  position: relative;
  cursor: pointer;
  padding-right: 26px !important;
}

.desc-cell:hover,
.desc-cell:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.desc-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
  white-space: pre-line;
}

.desc-expand {
  position: absolute;
  top: 9px;
  right: 7px;
  font-size: 0.72rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.desc-cell:hover .desc-expand,
.desc-cell:focus-visible .desc-expand {
  opacity: 1;
}

.desc-cell.editable-cell {
  cursor: text;
}

.text-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(20, 28, 30, 0.45);
  animation: popupFade 0.15s ease-out;
}

@keyframes popupFade {
  from {
    opacity: 0;
  }
}

.text-popup {
  width: min(860px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 18px 20px 14px;
}

.text-popup-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.text-popup-titles {
  flex: 1;
  min-width: 0;
}

.text-popup-column {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.text-popup-titles h2 {
  margin: 2px 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.dark-mode .icon-btn:hover {
  color: var(--accent-deep);
}

.icon-btn .fa-check {
  color: var(--green);
}

.instructions-block.text-popup-body {
  flex: 1 1 auto;
  min-height: 80px;
  max-height: none;
  margin: 0;
  font-size: 0.84rem;
}

.text-popup-footer {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

/* ---------- Diagram ---------- */
.diagram-wrapper {
  flex: 1 1 auto;
  min-height: 480px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 9999;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 16px 12px 20px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  position: relative;
  overflow: hidden;
  font-size: 0.88rem;
  animation: toastIn 0.25s ease-out;
}

.toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
}

.toast.success::before {
  background: var(--green);
}

.toast.information::before {
  background: var(--accent);
}

.toast.error::before {
  background: var(--red);
}

.toast.fade-out {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #b9c6c7;
  border-radius: 4px;
}

.dark-mode ::-webkit-scrollbar-thumb {
  background: #4a5357;
}

.left-menu ::-webkit-scrollbar-thumb {
  background: var(--charcoal-3);
}

* {
  scrollbar-width: thin;
  scrollbar-color: #b9c6c7 transparent;
}

.dark-mode * {
  scrollbar-color: #4a5357 transparent;
}

/* ---------- Opened in new window ---------- */
.standalone-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.header-filter.standalone {
  flex: none;
  padding: 10px 16px;
  background: var(--charcoal);
  border-bottom: 3px solid var(--accent);
}

.tab-content.standalone-content {
  margin: 16px;
}

.standalone-content .desc-clamp {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: none;
}

.standalone-content .desc-expand {
  display: none;
}

.standalone-content .desc-cell {
  cursor: auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .left-menu {
    max-height: 40vh;
  }

  .panels,
  .sideBySide {
    grid-template-columns: 1fr;
  }

  .info-panel.wide {
    grid-column: auto;
  }

  .who {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
