/* ==========================================================================
   DevTools — dashboard shell
   --------------------------------------------------------------------------
   Fonts and tokens come from assets/tokens.css (loaded first by index.html),
   the same file every tool imports through tools/main.css, so the shell and
   the tools cannot drift apart. This file only lays out and skins the shell:
   sidebar, home screen, command palette, dialogs and the tool frame.

   Finish: flat console — solid surfaces, 1px purple-tinted hairlines,
   neutral elevation, 6 / 8 / 12px radii. Purple marks the active item;
   yellow is kept for the single strongest accent (current-tool marker,
   pinned state, key caps).
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 640px at 8% 0%, rgba(139, 92, 246, 0.07), transparent 60%),
    radial-gradient(800px 520px at 100% 100%, rgba(255, 215, 0, 0.03), transparent 60%),
    var(--bg);
  font-family: var(--font-body);
  font-size: var(--chrome-md);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  color: var(--heading);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

code,
kbd {
  font-family: var(--font-mono);
}

/* ==========================================================================
   App grid
   ========================================================================== */

.app {
  height: 100vh;
  /* Mobile browsers count the collapsing URL bar in 100vh, which pushed the
     bottom of every tool under the toolbar. */
  height: 100dvh;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  padding: 12px;
  position: relative;
}

.app.sidebar-collapsed {
  grid-template-columns: 72px 1fr;
}

/* Shared icon-button skin for the shell's square controls. */
.expand-btn,
.collapse-btn,
.support-btn,
.modal__close {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-e1);
  cursor: pointer;
  transition: var(--transition-control);
}

.expand-btn:hover,
.collapse-btn:hover,
.support-btn:hover,
.modal__close:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--accent-purple-light);
}

.expand-btn:active,
.collapse-btn:active,
.support-btn:active,
.modal__close:active {
  transform: translateY(1px);
}

.expand-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  display: none;
  z-index: 100;
  box-shadow: var(--shadow-e2);
}

.expand-btn svg,
.collapse-btn svg {
  display: block;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-e2);
}

.sidebar.is-collapsed {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

/* --- Collapsed rail ------------------------------------------------------ */

.app.sidebar-collapsed .expand-btn {
  display: none;
}

.app.sidebar-collapsed .sidebar__top {
  padding: 12px 8px;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.app.sidebar-collapsed .collapse-btn {
  position: static;
}

.app.sidebar-collapsed .brand {
  padding: 0;
  justify-content: center;
}

.app.sidebar-collapsed .brand__mark {
  width: 40px;
  height: 40px;
}

.app.sidebar-collapsed .brand__text,
.app.sidebar-collapsed .search {
  display: none;
}

.app.sidebar-collapsed .menu {
  padding: 10px 6px;
  scrollbar-width: none;
}

.app.sidebar-collapsed .menu::-webkit-scrollbar {
  width: 0;
}

.app.sidebar-collapsed .menu__item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 8px;
}

.app.sidebar-collapsed .menu__row {
  grid-template-columns: 1fr;
}

.app.sidebar-collapsed .menu__section-title,
.app.sidebar-collapsed .menu__divider,
.app.sidebar-collapsed .menu__label,
.app.sidebar-collapsed .menu__pin,
.app.sidebar-collapsed .sidebar__version,
.app.sidebar-collapsed .hint {
  display: none;
}

.app.sidebar-collapsed .menu__icon {
  width: 36px;
  height: 36px;
}

.app.sidebar-collapsed .sidebar__bottom {
  padding: 10px;
}

.app.sidebar-collapsed .sidebar__footer {
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* The rail is one icon wide, so the footer buttons stack instead of sitting
   side by side. */
.app.sidebar-collapsed .sidebar__footer-actions {
  flex-direction: column;
}

/* --- Top: brand + search ------------------------------------------------- */

.sidebar__top {
  padding: 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
  position: relative;
}

.collapse-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  box-shadow: none;
}

.collapse-btn svg {
  transition: transform var(--dur-slow) var(--ease-out);
}

.sidebar.is-collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.brand {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 44px 14px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.brand__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-card);
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
  background: var(--accent-purple);
  border: 1px solid var(--accent-line);
  box-shadow: var(--shadow-e1);
  transition: var(--transition-control);
}

.brand:hover .brand__mark {
  border-color: var(--accent-yellow);
}

.brand:active .brand__mark {
  transform: translateY(1px);
}

.brand:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 4px;
  border-radius: var(--radius-card);
}

.brand__mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand__title {
  color: var(--heading);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: var(--tracking-title);
}

.brand__subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.search {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control-border);
  background: var(--bg);
  transition: var(--transition-control);
}

.search:hover {
  border-color: var(--border-light);
}

.search__icon {
  color: var(--text-hint);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: color var(--dur) var(--ease-out);
}

.search__icon svg {
  display: block;
}

.search__input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--heading);
  font-size: var(--chrome-base);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.search__input:focus-visible {
  outline: none;
  outline-offset: 0;
}

/* Remove browser-native inner borders/decoration on <input type="search"> */
.search__input::-webkit-search-decoration,
.search__input::-webkit-search-cancel-button,
.search__input::-webkit-search-results-button,
.search__input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search__input::-ms-clear,
.search__input::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.search__input::placeholder {
  color: var(--text-hint);
}

.search:focus-within {
  border-color: var(--focus-border);
  box-shadow: var(--focus-ring);
}

.search:focus-within .search__icon {
  color: var(--accent-purple-light);
}

/* --- Tool menu ----------------------------------------------------------- */

.menu {
  min-height: 0;
  padding: 10px 8px;
  overflow: auto;
}

.menu__section {
  padding: 0 4px;
}

.menu__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.menu__section-title {
  padding: 10px 10px 6px;
  color: var(--text-hint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.menu__divider {
  height: 1px;
  margin: 8px 10px;
  background: var(--divider);
}

.menu__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 4px;
  align-items: center;
}


.menu__item {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  position: relative;
  transition: var(--transition-control);
}

.menu__item:hover {
  background: var(--accent-softer);
  color: var(--heading);
}

.menu__item[aria-current="true"] {
  background: var(--accent-purple);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-e1);
}

.menu__item[aria-current="true"]::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  background: var(--accent-yellow);
  border-radius: 0 2px 2px 0;
}

.menu__icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: var(--transition-control);
}

.menu__item:hover .menu__icon {
  border-color: var(--border-light);
}

.menu__item[aria-current="true"] .menu__icon {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.menu__icon img {
  width: 22px;
  height: 22px;
  display: block;
}

.menu__label {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.menu__name {
  font-weight: 500;
  font-size: var(--chrome-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu__pin {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-hint);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition-control);
}

.menu__row:hover .menu__pin,
.menu__row:focus-within .menu__pin,
.menu__pin[data-pinned="true"] {
  opacity: 1;
}

.menu__pin:hover,
.menu__pin:focus-visible {
  background: var(--yellow-soft);
  border-color: rgba(255, 215, 0, 0.24);
  color: var(--accent-yellow);
  outline: none;
}

.menu__pin[data-pinned="true"] {
  color: var(--accent-yellow);
}

.menu__pin svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
}

/* --- Bottom -------------------------------------------------------------- */

.sidebar__bottom {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}

.sidebar__footer {
  margin-top: 6px;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar__footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar__version {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.sidebar__version:hover {
  color: var(--accent-yellow);
}

.support-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  box-shadow: none;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ==========================================================================
   Dialogs (support, settings, tool info)
   The shell does not load tools/main.js, so these carry their own markup;
   the look matches the shared tool modal.
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: var(--scrim-blur);
  -webkit-backdrop-filter: var(--scrim-blur);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out);
  padding: 20px;
}

.modal-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-modal);
  max-width: 480px;
  max-height: calc(100vh - 40px);
  width: 100%;
  overflow-y: auto;
  box-shadow: var(--shadow-e3);
  transform: translateY(8px) scale(0.98);
  transition: transform var(--dur-slow) var(--ease-out);
}

/* The same short brand marker the tool modals carry. */
.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  width: 3rem;
  height: 2px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--accent-purple-light), var(--accent-yellow));
  pointer-events: none;
}

.modal-overlay[aria-hidden="false"] .modal {
  transform: none;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  box-shadow: none;
  z-index: 1;
}

.modal__header {
  padding: 32px 32px 16px;
  text-align: center;
}

.modal__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-purple-light);
}

.modal__icon svg {
  width: 24px;
  height: 24px;
}

.modal__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--heading);
  margin: 0;
}

.modal__body {
  padding: 0 32px 32px;
}

.modal__text {
  font-size: var(--chrome-md);
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 20px;
  text-align: center;
}

.modal__email-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  transition: var(--transition-control);
}

.modal__email-box:hover {
  border-color: var(--border-strong);
}

.modal__email-box svg {
  color: var(--accent-purple-light);
  flex-shrink: 0;
}

.modal__email {
  font-family: var(--font-mono);
  font-size: var(--chrome-base);
  font-weight: 500;
  color: var(--heading);
  text-decoration: none;
  word-break: break-all;
}

.modal__email:hover {
  color: var(--accent-purple-light);
  text-decoration: underline;
}

.modal__subtext {
  font-size: var(--chrome-base);
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
  text-align: center;
}

/* --- Settings ------------------------------------------------------------ */

.settings-section__title {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.settings-storage {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.settings-storage__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-2);
}

.settings-storage__label {
  color: var(--heading);
  font-size: var(--chrome-md);
  font-weight: 500;
}

.settings-storage__detail {
  color: var(--accent-yellow);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.settings-storage__note {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--chrome-base);
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-e1);
  cursor: pointer;
  transition: var(--transition-control);
}

.settings-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--heading);
}

.settings-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* display: inline-flex above would otherwise beat the [hidden] default, so
   the Cancel button would sit there before the clear is even armed. */
.settings-btn[hidden] {
  display: none;
}

.settings-btn--danger {
  border-color: rgba(255, 107, 157, 0.4);
  color: var(--accent-pink);
}

.settings-btn--danger:hover:not(:disabled) {
  border-color: var(--accent-pink);
  background: rgba(255, 107, 157, 0.1);
  color: var(--accent-pink);
}

/* Armed is the confirmation state: the same button, now clearly the one that
   destroys something. */
.settings-btn--danger.is-armed {
  border-color: var(--accent-pink);
  background: var(--accent-pink);
  color: var(--bg);
}

.settings-btn--danger.is-armed:hover:not(:disabled) {
  background: #ff85ae;
  color: var(--bg);
}

.settings-section .modal__subtext {
  margin-top: 24px;
}

.settings-status {
  margin: 12px 0 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--chrome-base);
  line-height: 1.5;
}

/* --- Tool info ----------------------------------------------------------- */

.modal__tool-about {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
}

.modal__tool-about-label {
  margin: 0 0 8px;
  color: var(--accent-yellow);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.modal__tool-about-title {
  margin: 0 0 8px;
  color: var(--heading);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.modal__tool-about-description,
.modal__tool-about-capabilities li,
.modal__tool-about-privacy {
  color: var(--text-muted);
  font-size: var(--chrome-base);
  line-height: 1.6;
}

.modal__tool-about-description {
  margin: 0;
}

.modal__tool-about-capabilities {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding-left: 20px;
}

.modal__tool-about-privacy {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}

/* ==========================================================================
   Command palette
   ========================================================================== */

.command-palette {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  background: var(--scrim);
  backdrop-filter: var(--scrim-blur);
  -webkit-backdrop-filter: var(--scrim-blur);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  z-index: 1200;
}

.command-palette[aria-hidden="false"] {
  opacity: 1;
  pointer-events: all;
}

.command-palette__panel {
  width: min(640px, 100%);
  max-height: min(620px, 76vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-e3);
  transform: translateY(-6px) scale(0.98);
  transition: transform var(--dur) var(--ease-out);
}

.command-palette[aria-hidden="false"] .command-palette__panel {
  transform: none;
}

.command-palette__header {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}

.command-palette__icon {
  display: grid;
  place-items: center;
  color: var(--accent-purple-light);
}

.command-palette__input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--heading);
  font-size: 16px;
  font-weight: 500;
}

.command-palette__input:focus,
.command-palette__input:focus-visible {
  border: 0;
  outline: none;
  box-shadow: none;
}

.command-palette__input::placeholder {
  color: var(--text-hint);
}

.command-palette__input::-webkit-search-decoration,
.command-palette__input::-webkit-search-cancel-button,
.command-palette__input::-webkit-search-results-button,
.command-palette__input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.command-palette__key,
.empty__cta kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

.command-palette__body {
  min-height: 0;
  padding: 8px;
  overflow: auto;
}

.command-palette__title,
.command-palette__section-title {
  color: var(--text-hint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.command-palette__title {
  margin: 4px 8px 8px;
}

.command-palette__section-title {
  padding: 10px 8px 4px;
}

.command-palette__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.command-palette__item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition-control);
}

.command-palette__item[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--heading);
}

.command-palette__item-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--divider);
  border-radius: var(--radius-control);
  background: var(--surface-2);
}

.command-palette__item-icon img {
  width: 22px;
  height: 22px;
}

.command-palette__item-label {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.command-palette__item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--chrome-md);
  font-weight: 500;
}

.command-palette__item-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.command-palette__item[aria-selected="true"] .command-palette__item-meta {
  color: var(--text-secondary);
}

.command-palette__empty {
  padding: 18px 12px;
  color: var(--text-muted);
  font-size: var(--chrome-md);
  text-align: center;
}

.command-palette__footer {
  display: flex;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
  color: var(--text-hint);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 768px) {
  .modal__header {
    padding: 28px 20px 16px;
  }

  .modal__body {
    padding: 0 20px 28px;
  }

  .modal__title {
    font-size: 18px;
  }

  .command-palette {
    padding-top: 8vh;
  }

  .command-palette__footer {
    display: none;
  }
}

/* ==========================================================================
   Main panel + home screen
   ========================================================================== */

.main {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-e2);
}

.main__content {
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 56px;
  overflow: auto;
}

.empty__content {
  max-width: 1100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.empty__header {
  display: flex;
  align-items: center;
  gap: 20px;
  animation: fadeInUp 0.4s var(--ease-out);
}

.empty__icon {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-panel);
  background: var(--accent-purple);
  border: 1px solid var(--accent-line);
  color: #fff;
  box-shadow: var(--shadow-e2);
}

.empty__icon svg {
  width: 32px;
  height: 32px;
}

.empty__header-text {
  flex: 1;
  text-align: left;
}

.empty__title {
  color: var(--heading);
  font-weight: 700;
  font-size: 36px;
  margin: 0 0 6px;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.empty__subtitle {
  max-width: 60ch;
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 400;
  margin: 0;
  line-height: 1.55;
}

.empty__privacy {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: var(--chrome-base);
  font-weight: 500;
  line-height: 1.4;
}

.empty__privacy svg {
  flex-shrink: 0;
  color: var(--accent-green);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.empty__feature:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 2px;
}

.empty__section {
  display: grid;
  gap: 12px;
  animation: fadeInUp 0.4s var(--ease-out) 0.08s backwards;
}

.empty__section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.empty__section-title {
  margin: 0;
  color: var(--heading);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-title);
}

.empty__section-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: var(--chrome-base);
}

.empty__section-meta {
  flex-shrink: 0;
  padding: 3px 8px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.empty__tool-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.empty__features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* A clickable card: solid surface, hairline, shallow shadow; hover lifts the
   border and shadow rather than the card. */
.empty__feature {
  appearance: none;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  box-shadow: var(--shadow-e1);
  transition: var(--transition-control);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.empty__feature:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  box-shadow: var(--shadow-e2);
}

.empty__feature:active {
  transform: translateY(1px);
}

.empty__feature.has-badge {
  padding-right: 66px;
}

/* Icon-only pin badge needs less room than the text badges. */
.empty__feature.has-pin.has-badge {
  padding-right: 44px;
}

.empty__feature-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-card);
  background: var(--accent-softer);
  border: 1px solid var(--accent-line);
  color: var(--accent-purple-light);
  font-size: 12px;
  font-weight: 700;
  transition: var(--transition-control);
}

.empty__feature-icon img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.empty__feature:hover .empty__feature-icon {
  background: var(--accent-soft);
}

.empty__feature-icon svg {
  color: var(--accent-purple-light);
}

.seo-tool-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.seo-tool-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--chrome-base);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  transition: var(--transition-control);
}

.seo-tool-link:hover,
.seo-tool-link:focus-visible {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--heading);
  outline: none;
}

.empty__feature-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.empty__feature-name {
  overflow: hidden;
  color: var(--heading);
  font-size: var(--chrome-md);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: var(--tracking-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty__feature-meta {
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty__feature-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  border: 0;
  border-radius: var(--radius-xs);
  background: rgba(0, 208, 156, 0.12);
  color: var(--accent-green);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.empty__feature-badge.is-pinned {
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  background: var(--yellow-soft);
  color: var(--accent-yellow);
}

.empty__feature-badge.is-pinned svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty__recent-empty {
  grid-column: 1 / -1;
  min-height: 78px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: var(--chrome-base);
  font-weight: 500;
  text-align: center;
}

.empty__tool-row .empty__feature {
  min-height: 80px;
  padding-right: 14px;
}

.empty__tool-row .empty__feature.has-pin {
  padding-right: 40px;
}

.empty__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-card);
  background: var(--accent-softer);
  border: 1px solid var(--accent-line);
  color: var(--text-secondary);
  font-size: var(--chrome-base);
  font-weight: 500;
  text-align: center;
  animation: fadeInUp 0.4s var(--ease-out) 0.16s backwards;
  align-self: center;
}

.empty__cta svg {
  color: var(--accent-purple-light);
}

.empty__cta kbd {
  margin: 0 2px;
  color: var(--accent-yellow);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .empty__tool-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .empty__features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .empty {
    padding: 24px;
  }

  .empty__content {
    gap: 24px;
  }

  .empty__header {
    flex-direction: column;
    text-align: center;
  }

  .empty__header-text {
    text-align: center;
  }

  .empty__subtitle {
    margin-inline: auto;
    font-size: 15px;
  }

  .empty__icon {
    width: 56px;
    height: 56px;
  }

  .empty__icon svg {
    width: 28px;
    height: 28px;
  }

  .empty__title {
    font-size: 28px;
  }

  .empty__privacy {
    justify-content: center;
    font-size: 12px;
  }

  .empty__section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .empty__section-meta {
    width: max-content;
  }

  .empty__tool-row,
  .empty__features {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .empty__feature {
    flex-direction: row;
    justify-content: flex-start;
  }

  .empty__feature-copy {
    text-align: left;
  }
}

/* ==========================================================================
   Tool frame + loader
   ========================================================================== */

.frame {
  position: absolute;
  inset: 0;
  width: 111.11%;
  height: 111.11%;
  border: 0;
  background: transparent;
  display: none;
  transform: scale(0.9);
  transform-origin: 0 0;
}

.frame.is-visible {
  display: block;
  pointer-events: auto;
}

.frame-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.frame-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 11, 15, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  z-index: 5;
}

.frame-loader.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.frame-loader__card {
  display: grid;
  gap: 12px;
  place-items: center;
  min-width: 200px;
  padding: 20px 24px;
  border-radius: var(--radius-panel);
  background: var(--surface);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-e3);
}

.frame-loader__spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent-yellow);
  animation: spin 0.8s linear infinite;
}

.frame-loader__text {
  font-size: var(--chrome-md);
  color: var(--text-secondary);
  font-weight: 500;
}

.frame-loader__meta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.frame-loader__stage {
  font-weight: 500;
}

.frame-loader__percent {
  font-variant-numeric: tabular-nums;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 340px 1fr;
  }

  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app.sidebar-collapsed .sidebar {
    display: none;
  }

  .app.sidebar-collapsed .main {
    grid-row: 2;
  }

  /* In flow rather than fixed: fixed at the top-left it sat on top of the
     open tool's title and first controls. */
  .app.sidebar-collapsed .expand-btn {
    display: grid;
    position: static;
    grid-row: 1;
    justify-self: start;
  }
}

/* ==========================================================================
   Scrollbars, selection, focus
   ========================================================================== */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

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

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

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

::selection {
  background: rgba(139, 92, 246, 0.32);
  color: var(--heading);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-border);
  outline-offset: 2px;
}

/* ==========================================================================
   User preferences
   The home screen used to run a 2s infinite pulse and a sliding arrow with
   no reduced-motion opt-out at all.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-property: opacity, color, background-color, border-color, box-shadow !important;
    transition-duration: 120ms !important;
  }

  .frame-loader__spinner {
    animation: spin 1.6s linear infinite !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .modal-overlay,
  .command-palette {
    background: rgba(5, 5, 8, 0.94);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
