:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-surface: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-bg: rgba(56, 189, 248, 0.1);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --border: #475569;
  --border-subtle: #334155;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.3);
  --radius: 8px;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.125rem;
}

.logo svg { color: var(--accent); }

.main-nav {
  display: flex;
  gap: 8px;
}

.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: all 0.15s;
}

.main-nav a:hover, .main-nav a.active {
  color: var(--text);
  background: var(--bg-surface);
}

.workspace {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.toolbar-group select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-primary, .btn-secondary {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-small { padding: 5px 12px; font-size: 0.8125rem; }

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 480px;
}

.pane {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.pane-header h2 {
  font-size: 0.9375rem;
  font-weight: 600;
}

.pane-header .hint {
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.editor-pane textarea {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  resize: none;
  outline: none;
  tab-size: 2;
}

.editor-footer, .preview-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-subtle);
}

#preview-container {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: #ffffff;
}

#preview-content {
  color: #1e293b;
  font-size: 0.875rem;
  line-height: 1.6;
}

#preview-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
}

#preview-content th, #preview-content td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

#preview-content th {
  background: #f8fafc;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  position: relative;
}

#preview-content th:hover {
  background: #f1f5f9;
}

#preview-content th::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.3;
}

#preview-content th[data-align="left"]::after {
  border-top: 5px solid #64748b;
  border-bottom: none;
}

#preview-content th[data-align="center"]::after {
  border-top: 5px solid #64748b;
  border-bottom: 5px solid #64748b;
  height: 2px;
  margin-top: -1px;
}

#preview-content th[data-align="right"]::after {
  border-bottom: 5px solid #64748b;
  border-top: none;
}

#preview-content tr:nth-child(even) {
  background: #f8fafc;
}

#alignment-indicators {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.alignment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  background: var(--bg);
  color: var(--text-muted);
}

.alignment-badge .align-icon {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-bar {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  padding: 16px;
}

.history-bar h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.8125rem;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: all 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.history-item .history-name {
  font-weight: 500;
}

.history-item .history-date {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.history-item .history-delete {
  margin-left: 4px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0 2px;
}

.history-item .history-delete:hover {
  color: var(--danger);
}

.history-empty {
  color: var(--text-dim);
  font-size: 0.8125rem;
  font-style: italic;
}

.support-content {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

.support-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 24px;
}

.support-inner h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.support-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border-subtle);
}

.support-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent);
}

.support-card p, .support-card li {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.support-card ul {
  padding-left: 18px;
}

.support-card li {
  margin-bottom: 10px;
}

.support-card code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent);
}

.demo-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.8125rem;
}

.demo-table th, .demo-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.demo-table th {
  background: var(--bg-elevated);
  font-weight: 600;
}

.scenario-walkthrough, .troubleshooting {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.scenario-walkthrough h3, .troubleshooting h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--accent);
}

.scenario-walkthrough ol {
  padding-left: 20px;
}

.scenario-walkthrough li {
  margin-bottom: 10px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.troubleshooting dl {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.troubleshooting dt {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
}

.troubleshooting dd {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-left: 0;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}

.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border-subtle);
  padding: 24px;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9375rem;
}

.footer-nav {
  display: flex;
  gap: 20px;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.footer-nav a:hover { color: var(--text); }

.footer-note {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.footer-note a {
  color: var(--accent);
  text-decoration: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 200;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

.toast-success { background: var(--success); color: var(--bg); }

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 900px) {
  .panes { grid-template-columns: 1fr; }
  .support-grid { grid-template-columns: 1fr; }
  .workspace-toolbar { gap: 8px; }
  .toolbar-group { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .header-inner { padding: 0 16px; }
  .workspace { padding: 12px 16px; }
  .main-nav a { padding: 6px 10px; font-size: 0.8125rem; }
  .footer-inner { flex-direction: column; text-align: center; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
