/* Kifmaster AI controls. Existing home controls and layout remain authoritative. */
.home-modern .right { position: relative; }

.home-modern #ai-analysis-menu-btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 0 1 460px;
  width: 460px;
  min-width: 360px;
  height: 90px !important;
  min-height: 90px !important;
  padding: 12px 18px 12px 14px !important;
  justify-content: flex-start;
  gap: 14px !important;
  border: 2px solid #7c3aed !important;
  border-radius: 12px !important;
  background: linear-gradient(118deg, #0b1735 0%, #111a4b 48%, #2a0d63 100%) !important;
  color: #f8fafc !important;
  text-align: left;
  box-shadow:
    0 0 5px rgba(124, 58, 237, 0.78),
    0 0 18px rgba(109, 40, 217, 0.52),
    0 0 34px rgba(76, 29, 149, 0.28),
    0 8px 24px rgba(43, 20, 104, 0.32),
    inset 0 0 8px rgba(139, 92, 246, 0.24),
    inset 0 -8px 18px rgba(2, 6, 23, 0.28) !important;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

body.writer-article-flow #ai-analysis-menu-btn,
body.writer-article-flow #ai-analysis-dialog,
body.writer-article-flow #ai-full-complete-dialog,
body.writer-article-flow #ai-analysis-panel {
  display: none !important;
}

.home-modern #ai-analysis-menu-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(116deg, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.05) 23%, transparent 47%);
  pointer-events: none;
}

.home-modern #ai-analysis-menu-btn > * {
  position: relative;
  z-index: 1;
}

.home-modern .ai-analysis-cta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(#071126, #071126) padding-box,
    linear-gradient(145deg, #67e8f9 4%, #60a5fa 44%, #a78bfa 100%) border-box;
  color: #f8fafc;
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.34),
    0 0 18px rgba(139, 92, 246, 0.22);
}

.home-modern .ai-analysis-cta-icon svg {
  width: 35px;
  height: 35px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-modern .ai-analysis-cta-copy {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.home-modern .ai-analysis-cta-title {
  color: #ffffff;
  font-size: 27px;
  font-weight: 675;
  line-height: 1.08;
  white-space: nowrap;
}

.home-modern .ai-analysis-cta-subtitle {
  display: -webkit-box;
  overflow: hidden;
  color: #dbe2ea;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-modern .ai-analysis-cta-arrow {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-modern #ai-analysis-menu-btn:hover {
  transform: translateY(-2px);
  border-color: #8b5cf6 !important;
  background: linear-gradient(118deg, #0e1d43 0%, #17215d 48%, #381181 100%) !important;
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.76),
    0 10px 28px rgba(43, 20, 104, 0.4),
    0 0 26px rgba(139, 92, 246, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -8px 18px rgba(2, 6, 23, 0.25) !important;
}

.home-modern #ai-analysis-menu-btn:active {
  transform: translateY(0) scale(0.99);
}

.home-modern #ai-analysis-menu-btn:focus-visible {
  outline: 3px solid rgba(129, 140, 248, 0.95);
  outline-offset: 3px;
}

.home-modern #ai-analysis-menu-btn.active,
.home-modern #ai-analysis-menu-btn[aria-expanded="true"] {
  border-color: #7c3aed !important;
  color: #ffffff !important;
  background: linear-gradient(118deg, #13255a 0%, #28216f 50%, #4c1d95 100%) !important;
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.82),
    0 8px 24px rgba(43, 20, 104, 0.42),
    0 0 30px rgba(139, 92, 246, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -8px 18px rgba(2, 6, 23, 0.24) !important;
}

.home-modern #ai-analysis-menu-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.home-modern .ai-analysis-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
}

.home-modern .ai-analysis-dialog.hidden { display: none; }

.home-modern .ai-analysis-dialog-card {
  width: min(420px, calc(100vw - 32px));
  padding: 18px;
  box-sizing: border-box;
  border: 1px solid rgba(56, 189, 248, 0.48);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(8, 15, 32, 0.99), rgba(2, 6, 23, 0.99));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58), 0 0 28px rgba(14, 165, 233, 0.14);
}

.home-modern .ai-analysis-dialog-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: #f8fafc;
  font-size: 20px;
}

.home-modern .ai-analysis-dialog-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.home-modern .ai-analysis-dialog-options .ai-btn {
  min-width: 0;
  min-height: 56px;
  border-color: rgba(56, 189, 248, 0.38);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.94));
  color: #dbeafe;
}

.home-modern .ai-analysis-dialog-options .ai-btn:hover,
.home-modern .ai-analysis-dialog-options .ai-btn.active {
  border-color: rgba(56, 189, 248, 0.86);
  color: #f0f9ff;
  background: linear-gradient(180deg, rgba(8, 47, 73, 0.96), rgba(12, 74, 110, 0.88));
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.home-modern .ai-full-complete-card {
  display: grid;
  gap: 14px;
  text-align: center;
}

.home-modern .ai-full-complete-card > strong {
  color: #f8fafc;
  font-size: 22px;
}

.home-modern .ai-full-complete-card > p {
  margin: 0;
  color: #cbd5e1;
  font-size: 16px;
}

.home-modern .ai-full-complete-card > .btn {
  min-height: 42px;
}

.home-modern .ai-analysis-panel {
  position: fixed;
  top: 148px;
  right: 28px;
  z-index: 1100;
  width: min(560px, calc(100% - 28px));
  height: 496px;
  min-width: 300px;
  min-height: 132px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: visible;
  resize: none;
  box-sizing: border-box;
  container-type: size;
  container-name: ai-panel;
  padding: 0;
  border: 1px solid rgba(56, 189, 248, 0.48);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(8, 15, 32, 0.98), rgba(2, 6, 23, 0.98));
  color: #e2e8f0;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.56), 0 0 30px rgba(14, 165, 233, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.home-modern .ai-panel-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
  padding: 16px;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.34) transparent;
}

.home-modern .ai-panel-scroll::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}

.home-modern .ai-panel-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.home-modern .ai-panel-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
}

.home-modern .ai-panel-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.46);
}

.home-modern .ai-resize-handle {
  position: absolute;
  z-index: 46;
  display: block;
  touch-action: none;
  user-select: none;
}

.home-modern .ai-resize-handle::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.38);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.home-modern .ai-resize-handle:hover::after,
.home-modern .ai-analysis-panel.is-resizing .ai-resize-handle::after {
  background: rgba(125, 211, 252, 0.82);
  box-shadow: 0 0 7px rgba(56, 189, 248, 0.48);
}

.home-modern .ai-resize-n,
.home-modern .ai-resize-s {
  left: 22px;
  right: 22px;
  height: 10px;
  cursor: ns-resize;
}
.home-modern .ai-resize-n { top: 0; }
.home-modern .ai-resize-s { bottom: 0; }
.home-modern .ai-resize-n::after,
.home-modern .ai-resize-s::after {
  left: 50%;
  width: 34px;
  height: 2px;
  transform: translateX(-50%);
}
.home-modern .ai-resize-n::after { top: 2px; }
.home-modern .ai-resize-s::after { bottom: 2px; }

.home-modern .ai-resize-e,
.home-modern .ai-resize-w {
  top: 22px;
  bottom: 22px;
  width: 10px;
  cursor: ew-resize;
}
.home-modern .ai-resize-e { right: 0; }
.home-modern .ai-resize-w { left: 0; }
.home-modern .ai-resize-e::after,
.home-modern .ai-resize-w::after {
  top: 50%;
  width: 2px;
  height: 34px;
  transform: translateY(-50%);
}
.home-modern .ai-resize-e::after { right: 2px; }
.home-modern .ai-resize-w::after { left: 2px; }

.home-modern .ai-resize-nw,
.home-modern .ai-resize-ne,
.home-modern .ai-resize-se,
.home-modern .ai-resize-sw {
  width: 20px;
  height: 20px;
}
.home-modern .ai-resize-nw { top: 0; left: 0; cursor: nwse-resize; }
.home-modern .ai-resize-ne { top: 0; right: 0; cursor: nesw-resize; }
.home-modern .ai-resize-se { right: 0; bottom: 0; cursor: nwse-resize; }
.home-modern .ai-resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.home-modern .ai-resize-nw::after,
.home-modern .ai-resize-ne::after,
.home-modern .ai-resize-se::after,
.home-modern .ai-resize-sw::after {
  width: 6px;
  height: 6px;
}
.home-modern .ai-resize-nw::after { top: 3px; left: 3px; }
.home-modern .ai-resize-ne::after { top: 3px; right: 3px; }
.home-modern .ai-resize-se::after { right: 3px; bottom: 3px; }
.home-modern .ai-resize-sw::after { bottom: 3px; left: 3px; }

.home-modern .ai-panel-head,
.home-modern .ai-quota-row,
.home-modern .ai-panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-modern .ai-panel-head {
  cursor: move;
  user-select: none;
  touch-action: none;
}

.home-modern .ai-analysis-panel.is-dragging .ai-panel-head {
  cursor: grabbing;
}

.home-modern .ai-panel-head > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.home-modern .ai-panel-head strong { color: #f8fafc; font-size: 26px; line-height: 1.15; }
.home-modern .ai-job-state { color: #7dd3fc; font-size: 16px; font-weight: 800; }
.home-modern .ai-job-state:empty { display: none; }
.home-modern .ai-job-state[data-state="error"],
.home-modern .ai-job-state[data-state="failed"] { color: #fca5a5; }
.home-modern .ai-job-state[data-state="completed"],
.home-modern .ai-job-state[data-state="saved"] { color: #86efac; }

.home-modern .ai-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.home-modern .ai-icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.home-modern .ai-quota-row { justify-content: flex-end; margin-top: 14px; color: #cbd5e1; font-size: 15px; font-weight: 700; }
.home-modern .ai-progress-track {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 5px;
  background: rgba(51, 65, 85, 0.7);
}
.home-modern .ai-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #fbbf24);
  transition: width 0.2s ease;
}

.home-modern .ai-result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 10px;
}
.home-modern .ai-candidate-card {
  min-width: 0;
  min-height: 112px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.68);
}
.home-modern .ai-candidate-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
  border-color: rgba(56, 189, 248, 0.38);
  background: linear-gradient(145deg, rgba(8, 47, 73, 0.58), rgba(8, 15, 32, 0.9));
  box-shadow: inset 0 1px 0 rgba(186, 230, 253, 0.1), 0 0 24px rgba(56, 189, 248, 0.11);
}
.home-modern .ai-candidate-primary,
.home-modern .ai-candidate-secondary {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 5px;
  box-sizing: border-box;
}
.home-modern .ai-candidate-primary {
  padding: 11px 10px;
  background: linear-gradient(145deg, rgba(120, 74, 8, 0.28), rgba(15, 23, 42, 0.22));
}
.home-modern .ai-candidate-secondary-stack {
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  border-left: 1px solid rgba(56, 189, 248, 0.24);
}
.home-modern .ai-candidate-secondary-stack.is-single { grid-template-rows: minmax(0, 1fr); }
.home-modern .ai-candidate-secondary { padding: 4px 8px; }
.home-modern .ai-candidate-secondary + .ai-candidate-secondary { border-top: 1px solid rgba(56, 189, 248, 0.2); }
.home-modern .ai-candidate-secondary-stack.hidden,
.home-modern .ai-candidate-secondary.hidden { display: none; }
.home-modern .ai-candidate-card:has(.ai-candidate-secondary-stack.hidden) { grid-template-columns: minmax(0, 1fr); }
.home-modern .ai-candidate-card span { display: block; color: #cbd5e1; font-size: 16px; font-weight: 800; }
.home-modern .ai-candidate-primary > span,
.home-modern .ai-candidate-secondary > span {
  grid-column: 1 / -1;
  width: max-content;
  padding: 2px 7px;
  border: 1px solid rgba(125, 211, 252, 0.26);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.42);
  color: #bae6fd;
  font-size: 12px;
  line-height: 1.25;
}
.home-modern .ai-candidate-primary > span {
  border-color: rgba(251, 191, 36, 0.42);
  color: #fde68a;
}
.home-modern .ai-pv-row > span { display: block; color: #e2e8f0; font-size: 13px; font-weight: 850; }
.home-modern .ai-candidate-primary strong {
  display: block;
  margin-top: 12px;
  overflow: hidden;
  color: #f8fafc;
  font-size: clamp(20px, 5cqw, 30px);
  line-height: 1.08;
  font-weight: 950;
  text-overflow: clip;
  white-space: nowrap;
}
.home-modern .ai-candidate-primary small,
.home-modern .ai-candidate-secondary small {
  display: block;
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  margin-top: 6px;
  width: max-content;
  padding: 3px 5px;
  border: 1px solid rgba(125, 211, 252, 0.3);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.54);
  color: #7dd3fc;
  font-size: clamp(26px, 5.6cqw, 34px);
  line-height: 0.95;
  font-weight: 900;
}
.home-modern .ai-candidate-secondary strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: #f8fafc;
  font-size: clamp(12px, 3.2cqw, 15px);
  line-height: 1.05;
  font-weight: 950;
  text-overflow: clip;
  white-space: nowrap;
}
.home-modern .ai-candidate-primary strong,
.home-modern .ai-candidate-secondary strong {
  grid-column: 1;
  grid-row: 2;
}
.home-modern .ai-candidate-primary small {
  border-color: rgba(251, 191, 36, 0.42);
  color: #fde68a;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.08);
}
.home-modern .ai-candidate-secondary small { margin-top: 5px; font-size: clamp(22px, 4.4cqw, 26px); }
.home-modern .ai-engine-meta {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.home-modern .ai-eval-graph {
  display: block;
  width: 100%;
  height: 165px;
  margin-top: 6px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
}
.home-modern .ai-pv-row { position: relative; margin-top: 9px; }
.home-modern .ai-pv-row p {
  min-height: 23px;
  margin: 6px 0 0;
  padding-right: 78px;
  color: #f1f5f9;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.home-modern .ai-pv-row .ai-text-btn { position: absolute; top: 0; right: 0; }
.home-modern .ai-text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: #7dd3fc;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.home-modern .ai-collapsible-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.home-modern .ai-collapsible-control { display: contents; }
.home-modern #ai-comment-menu-toggle { grid-column: 1; grid-row: 1; }
.home-modern #ai-settings-toggle { grid-column: 2; grid-row: 1; }
.home-modern #ai-reanalyze { grid-column: 3; grid-row: 1; }
.home-modern #ai-comment-menu-toggle,
.home-modern #ai-settings-toggle,
.home-modern #ai-reanalyze {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.home-modern .ai-option-menu {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.86);
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.home-modern .ai-option-menu > strong {
  display: block;
  margin-bottom: 8px;
  color: #e2e8f0;
  font-size: 15px;
}
.home-modern .ai-menu-toggle[aria-expanded="true"] {
  border-color: rgba(56, 189, 248, 0.68);
  color: #e0f2fe;
  background: rgba(8, 47, 73, 0.72);
}
.home-modern .ai-comment-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.home-modern .ai-comment-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.home-modern .ai-option-menu #ai-add-comment { margin-top: 9px; }
.home-modern .ai-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.home-modern .ai-settings-grid label { display: grid; gap: 4px; }
.home-modern .ai-settings-grid select {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  background: #020617;
  color: #e2e8f0;
  font-size: 15px;
}
.home-modern .ai-panel-actions { justify-content: flex-start; margin-top: 10px; }
.home-modern .ai-panel-actions .btn,
.home-modern .ai-option-menu .btn { min-height: 30px; padding: 5px 8px; font-size: 11px; font-weight: 800; }

@container ai-panel (max-width: 460px) {
  .home-modern .ai-panel-scroll {
    padding: 10px;
  }

  .home-modern .ai-quota-row {
    margin-top: 7px;
  }

  .home-modern .ai-result-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-top: 7px;
  }

  .home-modern .ai-candidate-card {
    min-height: 88px;
  }

  .home-modern .ai-candidate-primary {
    padding: 8px 10px;
  }

  .home-modern .ai-candidate-secondary {
    padding: 3px 8px;
  }

  .home-modern .ai-engine-meta {
    margin-top: 5px;
  }

  .home-modern .ai-eval-graph {
    margin-top: 5px;
  }
}

@container ai-panel (max-width: 340px) and (max-height: 250px) {
  .home-modern .ai-panel-scroll {
    padding: 8px;
  }

  .home-modern .ai-panel-head strong {
    font-size: 20px;
  }

  .home-modern .ai-quota-row,
  .home-modern .ai-progress-track {
    display: none;
  }

  .home-modern .ai-result-grid {
    gap: 4px;
    margin-top: 5px;
  }

  .home-modern .ai-candidate-card {
    min-height: 76px;
  }

  .home-modern .ai-candidate-primary {
    padding: 5px 8px;
  }

  .home-modern .ai-candidate-secondary {
    padding: 2px 6px;
  }
}

.home-modern .tree-node-box { position: absolute; }
@media (max-width: 768px), (orientation: portrait) and (min-width: 769px) and (max-width: 1180px) {
  .home-modern .controls-nav {
    display: flex !important;
    flex-wrap: nowrap !important;
  }
  .home-modern #ai-analysis-menu-btn {
    flex: 4.5 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    grid-column: auto !important;
  }
  .home-modern .ai-analysis-panel {
    position: relative;
    top: auto;
    right: auto;
    order: 2;
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 0;
    max-height: none;
    resize: none;
    padding: 0;
  }
  .home-modern .ai-panel-scroll { height: auto; overflow: visible; padding: 12px; }
  .home-modern .ai-resize-handle { display: none; }
  .home-modern .ai-panel-head {
    cursor: default;
    touch-action: auto;
  }
  .home-modern .tree-panel { order: 3 !important; }
  .home-modern .ai-panel-head strong { font-size: 24px; }
  .home-modern .ai-job-state { font-size: 14px; }
  .home-modern .ai-quota-row { font-size: 14px; }
  .home-modern .ai-result-grid { gap: 8px; margin-top: 10px; }
  .home-modern .ai-candidate-card { min-height: 88px; }
  .home-modern .ai-candidate-primary { padding: 8px 9px; }
  .home-modern .ai-candidate-secondary { padding: 5px 8px; }
  .home-modern .ai-candidate-primary strong { margin-top: 6px; font-size: 17px; }
  .home-modern .ai-candidate-card span { font-size: 13px; }
  .home-modern .ai-candidate-secondary strong { font-size: 11px; }
  .home-modern .ai-candidate-primary small { font-size: 14px; }
  .home-modern .ai-candidate-secondary small { font-size: 12px; }
  .home-modern .ai-eval-graph { height: 98px; }
  .home-modern .ai-engine-meta { font-size: 13px; }
  .home-modern .ai-pv-row > span { font-size: 15px; }
  .home-modern .ai-pv-row p { padding-right: 90px; font-size: 18px; line-height: 1.55; }
  .home-modern .ai-text-btn { font-size: 13px; }
  .home-modern .ai-option-menu { font-size: 14px; }
  .home-modern #ai-comment-menu-toggle,
  .home-modern #ai-settings-toggle,
  .home-modern #ai-reanalyze { min-height: 38px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .home-modern #ai-analysis-menu-btn {
    transition: none;
  }
}

/* Smartphone: keep the AI card aligned with the 720px home layer and
   place it before the control-button card. */
@media (max-width: 768px) {
  .home-modern .right > .ai-analysis-panel {
    position: relative !important;
    inset: auto !important;
    order: 1 !important;
    width: 720px !important;
    min-width: 720px !important;
    max-width: 720px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    transform: none !important;
    container-type: inline-size !important;
    box-sizing: border-box !important;
  }

  .home-modern .right > .home-control-panel {
    order: 2 !important;
  }

  .home-modern .right > .tree-panel {
    order: 3 !important;
  }
}
