html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI Variable', 'Segoe UI', sans-serif;
  background: #d4d4d4;
  color: #171717;
}

* {
  box-sizing: border-box;
}

.container {
  width: 100%;
  height: 100%;
}

.stage {
  display: none;
  width: 100%;
  height: 100%;
}

.stage.active {
  display: flex;
}

#auth-stage {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#main-stage {
  padding: 0;
}

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

.viewer-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #d4d4d4;
  --viewer-control-bg: rgba(250, 250, 250, 0.94);
  --viewer-control-border: rgba(115, 115, 115, 0.65);
  --viewer-control-hover-bg: rgba(229, 229, 229, 0.96);
  --viewer-control-hover-border: rgba(64, 64, 64, 0.85);
}

.viewer-root {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.viewer-root > [data-viewer-overlay='true'] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
}

.viewer-empty-state {
  width: min(100%, 420px);
  text-align: center;
}

.viewer-empty-state h1 {
  margin: 0;
  color: #171717;
  font-size: 28px;
  font-weight: 700;
}

.viewer-empty-state p {
  margin: 12px 0 0;
  color: #404040;
  font-size: 14px;
  line-height: 1.5;
}

.html-viewer-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.viewer-action-stack {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
}

.viewer-action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 5px;
  border: 1px solid rgba(115, 115, 115, 0.28);
  border-radius: 999px;
  background: rgba(229, 229, 229, 0.78);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px);
}

.viewer-action-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.viewer-action-separator {
  width: 1px;
  height: 18px;
  margin: 0 1.5px;
  background: rgba(115, 115, 115, 0.26);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--viewer-control-border);
  border-radius: 999px;
  background: var(--viewer-control-bg);
  color: #171717;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(12px);
  transition:
    transform 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--viewer-control-hover-border);
  background: var(--viewer-control-hover-bg);
  transform: translateY(-1px);
}

.icon-btn:focus-visible {
  outline: 2px solid #525252;
  outline-offset: 2px;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
}

.viewer-tooltip-host {
  position: relative;
  display: inline-flex;
}

.viewer-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 50;
  width: max-content;
  max-width: 180px;
  padding: 5px 7px;
  border-radius: 6px;
  background: #171717;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.viewer-tooltip-host:hover .viewer-tooltip,
.viewer-tooltip-host:focus-within .viewer-tooltip {
  opacity: 1;
}

.toolbar-toggle-icon-expand {
  display: none;
}

.toolbar-toggle-btn {
  flex: 0 0 auto;
  transition:
    width 0.18s ease,
    height 0.18s ease,
    opacity 0.18s ease,
    transform 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.18s ease;
}

.viewer-action-bar[data-toolbar-collapsed='true'] {
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.viewer-action-bar[data-toolbar-collapsed='true'] .viewer-action-group-html,
.viewer-action-bar[data-toolbar-collapsed='true'] .viewer-action-separator {
  display: none;
}

.viewer-action-bar[data-toolbar-collapsed='true'] .toolbar-toggle-btn {
  width: 22px;
  height: 22px;
  opacity: 0.68;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.viewer-action-bar[data-toolbar-collapsed='true'] .toolbar-toggle-btn:hover {
  opacity: 1;
}

.viewer-action-bar[data-toolbar-collapsed='true'] .toolbar-toggle-icon-collapse {
  display: none;
}

.viewer-action-bar[data-toolbar-collapsed='true'] .toolbar-toggle-icon-expand {
  display: block;
}

.html-editor-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 23, 23, 0.38);
}

.html-editor-backdrop[hidden] {
  display: none;
}

.html-editor-dialog {
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  height: min(680px, 100%);
  min-height: 360px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
}

.html-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.html-editor-kicker {
  margin: 0 0 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.html-editor-header h1 {
  margin: 0;
  color: #0f172a;
  font-size: 20px;
  font-weight: 700;
}

.source-editor-shell {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #f8fafc;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    Liberation Mono,
    monospace;
  font-size: 13px;
  line-height: 1.5;
}

.source-line-numbers {
  overflow: hidden;
  padding: 18px 10px 18px 6px;
  border-right: 1px solid #e2e8f0;
  color: #7a8694;
  text-align: right;
  font-variant-numeric: tabular-nums;
  user-select: none;
  white-space: pre;
}

.source-highlight {
  overflow: hidden;
  padding: 18px;
  color: #1f2933;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
}

.source-highlight-line {
  min-height: 1.5em;
}

.source-input {
  position: absolute;
  inset: 0 0 0 56px;
  width: calc(100% - 56px);
  height: 100%;
  padding: 18px;
  border: 0;
  outline: 0;
  resize: none;
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #1f2933;
  font: inherit;
  line-height: inherit;
}

.html-token-plain {
  color: #1f2933;
}

.html-token-tag-bracket {
  color: #0f766e;
  font-weight: 700;
}

.html-token-tag-name {
  color: #0f5fc4;
  font-weight: 700;
}

.html-token-attribute-name {
  color: #7c3aed;
}

.html-token-attribute-value {
  color: #9d174d;
}

.html-token-operator {
  color: #64748b;
}

.html-token-comment {
  color: #2f6b3f;
  font-style: italic;
}

.html-token-doctype {
  color: #b45309;
  font-weight: 700;
}

.html-editor-error {
  min-height: 20px;
  margin: 0;
  padding: 8px 20px 0;
  font-size: 13px;
  line-height: 1.4;
  color: #b91c1c;
}

.html-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
}

.primary-action-btn,
.secondary-action-btn {
  min-width: 72px;
  padding: 9px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.primary-action-btn {
  border: 0;
  background: #171717;
  color: #ffffff;
}

.secondary-action-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #171717;
}

@media (max-width: 720px) {
  .html-editor-backdrop {
    padding: 12px;
  }

  .html-editor-dialog {
    min-height: 0;
  }
}
