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

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: #020617;
  color: #e2e8f0;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.2), transparent),
    rgba(2, 6, 23, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.site-header h1 {
  margin: 0 0 0.35rem;
  font-size: 2.3rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tagline {
  margin: 0;
  color: #94a3b8;
}

.site-nav {
  margin-top: 1.5rem;
  display: inline-flex;
  gap: 1rem;
  background: rgba(2, 6, 23, 0.7);
  padding: 0.35rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 25px rgba(3, 7, 18, 0.35);
}

.nav-link {
  text-decoration: none;
  color: #cbd5f5;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  color: #f8fafc;
  background: rgba(56, 189, 248, 0.15);
}

.nav-link-active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(217, 70, 239, 0.15));
  color: #f8fafc;
}

.editor-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 320px) minmax(420px, 3fr);
  gap: 2rem;
  padding: 2rem clamp(1rem, 5vw, 3rem) 3rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.editor-panel {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 45px rgba(3, 7, 18, 0.4);
  backdrop-filter: blur(10px);
}

.editor-panel h2 {
  margin-top: 0;
}

.intro-panel ul {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  color: #cbd5f5;
}

.editor-status {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
}


.editor-status[data-variant="success"] {
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.editor-status[data-variant="error"] {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.auth-bar {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.auth-bar label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.auth-bar input {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.7);
  color: #f8fafc;
  padding: 0.5rem 0.75rem;
}

.auth-bar button {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: rgba(59, 130, 246, 0.25);
  color: #bfdbfe;
  cursor: pointer;
}

.auth-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.panel-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.panel-actions button {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.panel-actions button.primary {
  border: none;
  color: #0f172a;
}

.panel-actions button:hover {
  background: rgba(37, 99, 235, 0.3);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid.inline {
  align-items: end;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.form-grid input,
.form-grid textarea {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.7);
  color: #f8fafc;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
}

.form-grid textarea {
  resize: vertical;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.with-clipboard .clipboard-row {
  display: flex;
  gap: 0.75rem;
}

.with-clipboard textarea {
  flex: 1;
}

.clipboard-row button.small {
  align-self: flex-start;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.clipboard-row button.small:hover {
  background: rgba(56, 189, 248, 0.2);
}

button.primary {
  align-self: start;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f172a;
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  cursor: pointer;
  box-shadow: 0 15px 30px rgba(56, 189, 248, 0.35);
}

button.primary:hover {
  opacity: 0.95;
}

.passage-panel textarea[name="body"] {
  min-height: 260px;
  font-size: 1rem;
  line-height: 1.5;
}

.interactive-annotation {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.4);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  grid-template-areas: "header header" "canvas panel";
  gap: 1.5rem;
}

.canvas-header {
  grid-area: header;
}

.canvas-header h3 {
  margin: 0 0 0.35rem;
}

.canvas-body {
  grid-area: canvas;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 14px;
  padding: 1rem;
  min-height: 320px;
  background: rgba(15, 23, 42, 0.6);
  overflow-y: auto;
  font-size: 1.05rem;
  line-height: 1.8;
  width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.canvas-placeholder {
  margin: 0;
  color: #94a3b8;
  font-style: italic;
}

.canvas-body span.annotation-token {
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.canvas-body span.annotation-token:hover,
.canvas-body span.annotation-token[data-annotated="true"] {
  background: rgba(56, 189, 248, 0.18);
  color: #f8fafc;
}

.canvas-body span.annotation-token[data-selected="true"] {
  background: rgba(251, 191, 36, 0.2);
  color: #fef3c7;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45);
}

.canvas-panel {
  grid-area: panel;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.7);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.canvas-panel .label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.panel-token-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.canvas-panel .value {
  margin: 0.2rem 0 0.6rem;
  font-weight: 600;
  color: #f8fafc;
}

.clear-selection {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.clear-selection:hover {
  background: rgba(56, 189, 248, 0.2);
}

.panel-suggestions {
  margin-bottom: 0.75rem;
}

.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 140px;
  overflow-y: auto;
}

.suggestion-item {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  background: rgba(2, 6, 23, 0.5);
}

.suggestion-item:hover {
  border-color: rgba(56, 189, 248, 0.5);
}

.suggestion-item strong {
  display: block;
  color: #f1f5f9;
}

.suggestion-item span {
  display: block;
  font-size: 0.85rem;
  color: #cbd5f5;
}

.preview-panel {
  grid-column: 1 / -1;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.preview-header button {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  cursor: pointer;
}

.code-block {
  margin: 0;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  max-height: 320px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.85rem;
  color: #f8fafc;
}

@media (max-width: 600px) {
  .panel-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid,
  .form-grid.inline {
    grid-template-columns: 1fr;
  }

  .auth-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .with-clipboard .clipboard-row {
    flex-direction: column;
  }

  .auth-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .interactive-annotation {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "canvas" "panel";
  }
}
