:root { --tool-accent: #d94f7c; --tool-tint: #ffe1eb; }

html, body { width: 100%; height: 100%; }

body.tool-detail-page {
  margin: 0;
  overflow: hidden;
  background: #fdf7f9;
  color: #30272b;
}

.tool-detail-shell {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr);
  width: min(1540px, calc(100% - 32px));
  height: calc(100dvh - 32px);
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid rgba(91, 61, 72, .14);
  border-radius: 8px;
  background: rgba(250, 250, 252, .92);
  box-shadow: 0 24px 70px rgba(77, 47, 58, .2);
  opacity: 1;
  transform: none;
  transition: opacity 360ms cubic-bezier(.2, 0, 0, 1), transform 420ms cubic-bezier(.2, 0, 0, 1);
  animation: toolShellIn 420ms cubic-bezier(.2, 0, 0, 1) both;
}

.tool-detail-shell.is-ready,
.tool-detail-shell:has(.tool-detail-error:not([hidden])) { opacity: 1; transform: none; }

.tool-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid rgba(87, 61, 70, .1);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
}

.tool-detail-identity { display: flex; align-items: center; min-width: 0; gap: 13px; }
.tool-detail-icon {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--tool-tint);
  color: var(--tool-accent);
  font-size: 1.18rem;
}
.tool-detail-copy { min-width: 0; }
.tool-detail-copy h1 { margin: 0; overflow: hidden; font-size: 1.12rem; text-overflow: ellipsis; white-space: nowrap; }
.tool-detail-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; color: #81737a; font-size: .76rem; }
.tool-detail-type { color: var(--tool-accent); font-weight: 800; }

.tool-detail-close {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(87, 61, 70, .13);
  border-radius: 50%;
  background: #fff;
  color: #55464c;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(75, 45, 56, .1);
  transition: transform 260ms cubic-bezier(.2, 0, 0, 1), background 180ms ease, box-shadow 260ms ease;
}
.tool-detail-close:hover { transform: scale(1.06); background: #fff6f9; box-shadow: 0 12px 28px rgba(75, 45, 56, .15); }
.tool-detail-close:active { transform: scale(.92); }
.tool-detail-close:disabled { cursor: wait; opacity: .65; }

.tool-detail-content { position: relative; min-height: 0; background: #f7f8fa; }
.tool-detail-frame { display: block; width: 100%; height: 100%; border: 0; background: #f7f8fa; }

.tool-detail-loading,
.tool-detail-error {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(250, 250, 252, .96);
  text-align: center;
}
.tool-detail-loading[hidden], .tool-detail-error[hidden] { display: none; }
.tool-detail-spinner {
  width: 42px;
  height: 42px;
  margin: auto;
  border: 4px solid #f1d7e0;
  border-top-color: var(--tool-accent);
  border-radius: 50%;
  animation: toolSpin 780ms linear infinite;
}
.tool-detail-error h2 { margin: 0; }
.tool-detail-error p { margin: 0; color: #77686e; }
.tool-detail-retry { min-height: 42px; padding: 0 18px; border: 0; border-radius: 7px; background: var(--tool-accent); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }

body.is-page-closing .tool-detail-shell,
.tool-detail-shell.is-page-closing {
  opacity: 0;
  filter: blur(7px);
  transform: translateY(10px) scale(.965);
  transition-duration: 560ms;
}

@keyframes toolSpin { to { transform: rotate(360deg); } }
@keyframes toolShellIn { from { opacity: 0; transform: translateY(12px) scale(.992); } }

@media (max-width: 720px) {
  .tool-detail-shell { width: 100%; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .tool-detail-header { grid-template-columns: minmax(0, 1fr) 44px; padding: 8px 10px; }
  .tool-detail-icon { width: 40px; height: 40px; }
  .tool-detail-close { width: 44px; height: 44px; }
  .tool-detail-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tool-detail-shell, .tool-detail-close { transition-duration: 1ms; }
  .tool-detail-spinner { animation-duration: 1.4s; }
}
