:root {
  --bg: #f5f5f7;
  --sidebar: rgba(255, 255, 255, 0.78);
  --chrome: rgba(255, 255, 255, 0.9);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.06);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.25, 0.1, 0.25, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body.front-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 0% 0%, #e7efff 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #f3e9ff 0%, transparent 50%), var(--bg);
}

.app-root {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  height: 100vh;
  gap: 14px;
  padding: 14px;
  position: relative;
  transition: grid-template-columns 0.5s cubic-bezier(0.22, 1, 0.36, 1), gap 0.45s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.app-root.is-sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
  padding-left: 10px;
  overflow: hidden;
}

.app-root.is-sidebar-collapsed .sidebar {
  opacity: 0;
  transform: translateX(calc(-100% - 24px));
  pointer-events: none;
}

.sidebar-dock {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%) translateX(-120%);
  z-index: 80;
  width: 36px;
  height: 96px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-size: 20px;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, color 0.2s ease;
}

body.is-sidebar-collapsed .sidebar-dock {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sidebar-dock:hover {
  color: var(--accent);
}

.chrome-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--sidebar);
  box-shadow: var(--shadow-soft);
  backdrop-filter: saturate(180%) blur(22px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.side-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: conic-gradient(from 210deg, #0a84ff, #5e5ce6, #ff9f0a, #0a84ff);
  box-shadow: 0 10px 24px rgba(10, 132, 255, 0.35);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.brand-title {
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.search-wrap {
  padding: 0 14px 10px;
}

.search-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), transform 0.18s var(--ease-spring);
}

.search-input:focus {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.category-list {
  flex: 1;
  overflow: auto;
  padding: 6px 10px 12px;
  scroll-behavior: smooth;
}

.cat-block {
  border-radius: 14px;
  margin-bottom: 10px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
  transition: transform 0.28s var(--ease-spring), box-shadow 0.28s var(--ease-out), border-color 0.28s var(--ease-out);
}

.cat-block.is-dimmed {
  opacity: 0.35;
  transform: scale(0.985);
}

.cat-head {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  transition: background 0.2s var(--ease-out), transform 0.18s var(--ease-spring);
}

.cat-head:hover {
  background: rgba(0, 0, 0, 0.03);
}

.cat-head:active {
  transform: scale(0.99);
}

.chev {
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.35s var(--ease-spring);
}

.cat-block.is-open .chev {
  transform: rotate(90deg);
}

.cat-tools {
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 0.45s var(--ease-spring), opacity 0.35s var(--ease-out), transform 0.45s var(--ease-spring);
}

.cat-block.is-open .cat-tools {
  max-height: 1200px;
  opacity: 1;
  transform: translateY(0);
}

.cat-block.is-suite .cat-head {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cat-block.is-suite .tool-item--sub {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 2px solid rgba(0, 113, 227, 0.2);
}

.cat-block.is-suite .tool-item--sub .tool-title {
  font-size: 13px;
}

.cat-block.is-suite .tool-item--sub .tool-desc {
  font-size: 11px;
}

.tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  margin: 0 8px 6px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  transition: transform 0.22s var(--ease-spring), box-shadow 0.22s var(--ease-out), border-color 0.22s var(--ease-out), background 0.22s var(--ease-out), filter 0.22s var(--ease-out);
  will-change: transform;
}

.tool-item:hover {
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.tool-item.is-active {
  border-color: rgba(0, 113, 227, 0.28);
  background: var(--accent-soft);
  box-shadow: 0 10px 26px rgba(0, 113, 227, 0.12);
}

.tool-item:active {
  transform: scale(0.985);
}

.tool-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.04);
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.tool-meta {
  min-width: 0;
}

.tool-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}

.mini-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.mini-link:hover {
  color: var(--accent);
}

.preview-pane {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(180%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.collapse-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 32px));
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px) saturate(180%);
  z-index: 40;
  animation: hintPop 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.collapse-hint[hidden] {
  display: none !important;
}

.collapse-hint-text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.collapse-hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.collapse-hint .btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: transform 0.2s var(--ease-spring), opacity 0.2s ease;
}

.collapse-hint .btn-primary {
  background: var(--accent);
  color: #fff;
}

.collapse-hint .btn-ghost {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

@keyframes hintPop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.preview-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.75));
}

.preview-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 16px;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.icon-btn:hover {
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.press-spring:active {
  transform: scale(0.94);
}

.iframe-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #fff;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.45s ease;
}

body.is-focus-preview .iframe-shell {
  transform: scale(1.015);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12);
}

body.is-focus-preview .preview-chrome {
  padding-top: 8px;
  padding-bottom: 8px;
}

.tool-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  transition: opacity 0.35s var(--ease-out), transform 0.45s var(--ease-spring), filter 0.45s var(--ease-out);
  transform-origin: center;
}

.tool-frame.is-swapping {
  opacity: 0;
  transform: scale(0.985) translateY(6px);
  filter: blur(6px);
}

.iframe-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
  background: radial-gradient(circle at 30% 20%, rgba(0, 113, 227, 0.08), transparent 45%), rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(10px) saturate(160%);
  z-index: 2;
}

.iframe-loader.is-on {
  opacity: 1;
}

.loader-ring {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(0, 113, 227, 0.18);
  border-top-color: rgba(0, 113, 227, 0.95);
  animation: spin 0.85s linear infinite;
}

.loader-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.recent-block {
  margin-bottom: 10px;
}

.section-label {
  padding: 6px 12px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-enter .app-root {
  animation: rootIn 0.65s var(--ease-spring) both;
}

.page-enter .anim-sheet {
  animation: sheetIn 0.65s var(--ease-spring) both;
}

@keyframes rootIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.992);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@media (max-width: 960px) {
  .app-root {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38vh) 1fr;
    height: auto;
    min-height: 100vh;
  }

  .preview-pane {
    min-height: 62vh;
  }
}
