/* Tressence Docs Showcase — Instant Review Studio & Auth Surface */

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

[hidden] {
  display: none !important;
}

::selection {
  background: var(--blue-100);
  color: var(--blue-900);
}

html {
  font-size: 16px;
}

body.app-body {
  margin: 0;
  min-height: 100dvh;
  background: var(--neutral-50);
  color: var(--neutral-800);
  font-family: var(--font-body);
  line-height: 1.55;
  letter-spacing: 0;
  caret-color: var(--blue-700);
}

body.studio-body {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--neutral-100);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
}

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

/* ─── Login Page ─────────────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(41, 169, 223, 0.10), transparent 70%),
    var(--neutral-50);
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  height: 32px;
  width: auto;
  display: block;
  margin-bottom: 22px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--neutral-800);
  margin: 0 0 6px;
}

.auth-desc {
  font-size: 0.9375rem;
  color: var(--neutral-600);
  margin: 0 0 22px;
}

/* ─── Buttons & Inputs ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-700);
  color: var(--neutral-0);
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-800);
  color: var(--neutral-0);
}

.btn-secondary {
  background: var(--neutral-0);
  color: var(--neutral-700);
  border-color: var(--neutral-200);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--neutral-100);
  border-color: var(--neutral-300);
  color: var(--neutral-800);
}

.btn-subtle {
  background: var(--blue-50);
  color: var(--blue-700);
  border-color: rgba(28, 117, 187, 0.18);
}
.btn-subtle:hover:not(:disabled) {
  background: var(--blue-100);
  color: var(--blue-800);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(22, 163, 74, 0.28);
}

.btn-danger {
  background: var(--neutral-0);
  color: var(--error);
  border-color: rgba(220, 38, 38, 0.25);
}
.btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.8125rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.field-label {
  display: block;
  font-size: 0.84375rem;
  font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: 5px;
}

.input, .textarea {
  width: 100%;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  color: var(--neutral-800);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 7px 11px;
}
.input {
  height: 36px;
}
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: var(--shadow-focus);
}
.input::placeholder, .textarea::placeholder {
  color: var(--neutral-500);
}

.alert-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--error-bg);
  color: #991B1B;
  font-size: 0.875rem;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ─── Studio Header Bar ──────────────────────────────────────────────────── */
.studio-topbar {
  height: 52px;
  flex-shrink: 0;
  background: var(--neutral-0);
  border-bottom: 1px solid var(--neutral-200);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 30;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  height: 24px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--neutral-200);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.breadcrumbs::-webkit-scrollbar { display: none; }

.crumb-btn {
  background: transparent;
  border: none;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--neutral-600);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.crumb-btn:hover {
  background: var(--neutral-100);
  color: var(--blue-700);
}
.crumb-btn.is-current {
  color: var(--neutral-800);
  font-weight: 700;
}
.crumb-sep {
  color: var(--neutral-400);
  font-size: 0.8rem;
}

.domain-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  border: 1px solid var(--neutral-200);
  color: var(--neutral-700);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.domain-chip:hover {
  border-color: var(--blue-400);
  color: var(--blue-800);
}

/* ─── Split Studio Body (Sidebar + Live Review Stage) ────────────────────── */
.studio-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.studio-sidebar {
  width: 310px;
  flex-shrink: 0;
  background: var(--neutral-0);
  border-right: 1px solid var(--neutral-200);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: margin-left 180ms var(--ease-out);
}
.studio-sidebar.is-collapsed {
  margin-left: -310px;
}

.sidebar-tools {
  padding: 10px 12px;
  border-bottom: 1px solid var(--neutral-100);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-search {
  position: relative;
}
.sidebar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--neutral-500);
  pointer-events: none;
}
.sidebar-search .input {
  height: 32px;
  padding-left: 32px;
  font-size: 0.84375rem;
  background: var(--neutral-50);
}

.sidebar-quick-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.inline-folder-form {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--blue-50);
  border-bottom: 1px solid var(--blue-100);
}
.inline-folder-form .input {
  height: 30px;
  font-size: 0.8125rem;
}

.upload-mini-bar {
  padding: 8px 12px;
  background: var(--blue-50);
  border-bottom: 1px solid var(--blue-100);
  font-size: 0.8rem;
}
.progress-track {
  width: 100%;
  height: 5px;
  margin-top: 5px;
  background: var(--neutral-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--blue-700);
  width: 0%;
  transition: width 120ms ease-out;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
  transition: background 100ms ease-out;
}
.tree-row:hover {
  background: var(--neutral-50);
}
.tree-row.is-selected {
  background: var(--blue-50);
  box-shadow: inset 0 0 0 1px rgba(28, 117, 187, 0.24);
}

.tree-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.item-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.item-icon svg {
  width: 16px;
  height: 16px;
}
.icon-folder   { background: var(--blue-50); color: var(--blue-700); }
.icon-html     { background: #E6F4FA; color: #0B6E99; }
.icon-slides   { background: #FEF3E2; color: #B45309; }
.icon-pdf      { background: #FCE8E8; color: #B91C1C; }
.icon-doc      { background: #EEF2F5; color: #2F363D; }
.icon-markdown { background: #EEF2F5; color: #4A535D; }
.icon-image    { background: #E8F7EE; color: #15803D; }
.icon-archive  { background: #F3F4F6; color: #4B5563; }
.icon-other    { background: #F3F4F6; color: #6C7682; }

.tree-info {
  min-width: 0;
  flex: 1;
}
.tree-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--neutral-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-row.is-selected .tree-name {
  color: var(--blue-800);
}
.tree-meta {
  font-size: 0.74rem;
  color: var(--neutral-500);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-copy-mini {
  opacity: 0;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--neutral-200);
  background: var(--neutral-0);
  color: var(--blue-700);
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.tree-row:hover .tree-copy-mini,
.tree-row.is-selected .tree-copy-mini {
  opacity: 1;
}
.tree-copy-mini:hover {
  background: var(--blue-700);
  border-color: var(--blue-700);
  color: #fff;
}

.sidebar-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--neutral-500);
  font-size: 0.84375rem;
}

/* ─── Right Main Pane: Instant Review Stage ──────────────────────────────── */
.studio-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #E7ECF2;
}

.stage-toolbar {
  height: 46px;
  flex-shrink: 0;
  background: var(--neutral-0);
  border-bottom: 1px solid var(--neutral-200);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-doc-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.stage-kind-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--blue-50);
  color: var(--blue-700);
  text-transform: uppercase;
  flex-shrink: 0;
}
.stage-doc-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--neutral-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segmented-group {
  display: inline-flex;
  background: var(--neutral-100);
  padding: 2px;
  border-radius: 7px;
  border: 1px solid var(--neutral-200);
}
.segmented-group button {
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--neutral-600);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented-group button.is-active {
  background: var(--neutral-0);
  color: var(--blue-700);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.viewport-canvas {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: auto;
}

.viewport-canvas.is-mobile-preview {
  padding: 18px 12px;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #FFFFFF;
  display: block;
}

.viewport-canvas.is-mobile-preview .preview-iframe {
  width: 393px;
  max-width: 100%;
  height: min(852px, 100%);
  border-radius: 24px;
  border: 6px solid #1E293B;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.24);
}

/* ─── Live HTML Composer / Instant Split Sandbox ─────────────────────────── */
.composer-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--neutral-50);
}

.composer-bar {
  min-height: 48px;
  padding: 6px 14px;
  background: var(--neutral-0);
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}
.composer-inputs .input {
  height: 32px;
  font-size: 0.84375rem;
}

.composer-split {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.composer-code-pane {
  width: 42%;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--neutral-200);
  background: #0F1722;
}
.composer-split.is-preview-only .composer-code-pane {
  display: none;
}

.code-pane-head {
  height: 32px;
  padding: 0 12px;
  background: #16202E;
  color: #94A3B8;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-editor-area {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 14px;
  background: #0F1722;
  color: #E2E8F0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  outline: none;
}

.composer-preview-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #E7ECF2;
  overflow: auto;
}
.composer-preview-pane.is-mobile-preview {
  padding: 18px 12px;
}
.composer-preview-pane.is-mobile-preview .preview-iframe {
  width: 393px;
  max-width: 100%;
  height: min(852px, 100%);
  border-radius: 24px;
  border: 6px solid #1E293B;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.24);
}

/* ─── Global Drag Overlay & Modals ───────────────────────────────────────── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(14, 63, 102, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  place-items: center;
  padding: 24px;
}
.drop-overlay.is-active {
  display: grid;
}
.drop-box {
  width: 100%;
  max-width: 500px;
  padding: 44px 32px;
  border-radius: var(--radius-2xl);
  background: var(--neutral-0);
  border: 2px dashed var(--blue-600);
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(26, 31, 37, 0.48);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  padding: 16px;
}
.modal-backdrop.is-open {
  display: grid;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--neutral-0);
  border-radius: var(--radius-xl);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-xl);
  padding: 22px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.share-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.share-link-box .input {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--neutral-50);
}

.qr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  margin: 12px 0;
}
.qr-preview img {
  width: 164px;
  height: 164px;
  border-radius: 8px;
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--neutral-800);
  color: var(--neutral-0);
  font-size: 0.84375rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
}
.toast.is-error {
  background: #991B1B;
}

/* ─── Collection & Read Viewer Helpers ───────────────────────────────────── */
.explorer-surface {
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
}
.empty-state {
  padding: 48px 20px;
  text-align: center;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--blue-50);
  color: var(--blue-700);
}
.tag-slides {
  background: #FEF3E2;
  color: #B45309;
}

@media (max-width: 860px) {
  .studio-sidebar {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    z-index: 35;
    box-shadow: var(--shadow-xl);
  }
  .domain-chip span, .hide-mobile {
    display: none;
  }
  .composer-split {
    flex-direction: column;
  }
  .composer-code-pane {
    width: 100%;
    height: 42%;
    border-right: none;
    border-bottom: 1px solid var(--neutral-200);
  }
}
