/* Kein Aufblitzen beim Antippen: Browser-Hervorhebung aus (siehe melucio-reset.css). */
* {
  -webkit-tap-highlight-color: transparent;
}

/* MelucioLabs MD Viewer — Dark Theme */
/* Breakpoints: MelucioLabs Shared Schema (packages/@meluciolabs/ui-components/src/theme/melucio-breakpoints.css) */
:root {
    --primary: #5CB85C;
    --primary-dark: #449D44;
    --accent: #7C6AF5;
    --bg: #1A1A2E;
    --bg-dark: #12121F;
    --surface: #252542;
    --text: #E8E8EC;
    --text-light: #C8C8D0;
    --text-muted: #A8A8B8;
    --border: #3D3D5C;
    --border-light: #2D2D45;
    --danger: #D9534F;
    --warning: #F0AD4E;
    --info: #5BC0DE;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

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

html, body {
    height: 100%;
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.header-brand .logo {
    color: var(--primary);
    font-weight: 700;
}

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

.filename {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn:hover {
    background: var(--border-light);
    border-color: var(--primary);
}

/* ---- Drop Zone ---- */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: 2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.drop-zone.drag-over {
    background: rgba(92, 184, 92, 0.08);
}

.drop-zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 4rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.2s;
}

.drag-over .drop-zone-inner {
    border-color: var(--primary);
}

.drop-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.drop-text {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-align: center;
}

.drop-hint {
    font-size: 0.8rem;
    color: var(--border);
}

.tailscale-link {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--border);
}

.tailscale-link a {
    color: var(--accent);
    text-decoration: none;
}

.tailscale-link a:hover {
    text-decoration: underline;
}

/* ---- Content ---- */
.content {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.content.visible {
    display: block;
}

/* ---- Markdown Styles ---- */
.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
    color: var(--text);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.content h1 { font-size: 2rem; border-bottom: 2px solid var(--primary); padding-bottom: 0.3em; }
.content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
.content h3 { font-size: 1.25rem; }
.content h4 { font-size: 1.1rem; color: var(--text-light); }
.content h5, .content h6 { font-size: 1rem; color: var(--text-muted); }

.content p {
    margin-bottom: 1em;
}

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

.content a:hover {
    text-decoration: underline;
}

.content strong { color: var(--text); }
.content em { color: var(--text-light); }

.content ul, .content ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.content li {
    margin-bottom: 0.3em;
}

.content li > ul, .content li > ol {
    margin-bottom: 0;
}

/* Inline code */
.content code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 0.15em 0.4em;
}

/* Code blocks */
.content pre {
    margin-bottom: 1em;
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.content pre code {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
}

/* Blockquotes */
.content blockquote {
    margin-bottom: 1em;
    padding: 0.5em 1em;
    border-left: 4px solid var(--accent);
    background: rgba(124, 106, 245, 0.06);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-light);
}

.content blockquote p:last-child {
    margin-bottom: 0;
}

/* Tables */
.content table {
    width: 100%;
    margin-bottom: 1em;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.content th {
    background: var(--surface);
    color: var(--primary);
    font-weight: 600;
    text-align: left;
    padding: 0.6em 0.8em;
    border: 1px solid var(--border);
}

.content th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.6em;
    position: relative;
}

.content th.sortable:hover {
    background: var(--border);
}

/* Neutral indicator: faint double arrow until a sort direction is chosen */
.content th.sortable::after {
    content: "⇅";
    position: absolute;
    right: 0.6em;
    opacity: 0.35;
    font-size: 0.85em;
}

.content th.sort-asc::after {
    content: "↑";
    opacity: 1;
}

.content th.sort-desc::after {
    content: "↓";
    opacity: 1;
}

.content td {
    padding: 0.5em 0.8em;
    border: 1px solid var(--border-light);
}

.content tr:nth-child(even) {
    background: rgba(37, 37, 66, 0.5);
}

/* Mermaid diagrams: span full content width (overrides Mermaid's inline
   max-width) so x-axis labels get room. Height scales via viewBox. */
.content .mermaid {
    width: 100%;
    margin-bottom: 1em;
    text-align: center;
}

.content .mermaid svg {
    max-width: 100% !important;
    width: 100%;
    height: auto;
}

/* Horizontal rules */
.content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

/* Images */
.content img {
    max-width: 100%;
    border-radius: var(--radius-md);
}

/* Task lists */
.content input[type="checkbox"] {
    margin-right: 0.5em;
    accent-color: var(--primary);
}

/* ---- Highlight.js Dark Override ---- */
.hljs {
    background: var(--bg-dark) !important;
    color: var(--text) !important;
}

.hljs-keyword, .hljs-selector-tag { color: #c792ea; }
.hljs-string, .hljs-addition { color: #c3e88d; }
.hljs-number, .hljs-literal { color: #f78c6c; }
.hljs-comment, .hljs-quote { color: #676e95; font-style: italic; }
.hljs-title, .hljs-section { color: #82aaff; }
.hljs-name, .hljs-tag { color: #f07178; }
.hljs-attr, .hljs-attribute { color: #ffcb6b; }
.hljs-built_in, .hljs-builtin-name { color: var(--info); }
.hljs-type, .hljs-class .hljs-title { color: #ffcb6b; }
.hljs-deletion { color: var(--danger); }
.hljs-meta { color: var(--text-muted); }
.hljs-punctuation { color: var(--text-muted); }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .content { padding: 1rem; }
    .drop-zone-inner { padding: 2rem 1.5rem; }
    .header { padding: 0.5rem 1rem; }
    .filename { max-width: 150px; }
}

/* ---- Legal Footer ---- */
.footer-legal {
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
}
.footer-legal a {
    color: var(--text-light);
    text-decoration: none;
    margin: 0 0.25rem;
}
.footer-legal a:hover { color: var(--primary); text-decoration: underline; }

/* ---- Legal Pages ---- */
.legal-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    line-height: 1.6;
}
.legal-page h1 { color: var(--primary); margin-bottom: 1.5rem; font-size: 1.8rem; }
.legal-page h2 { color: var(--text); margin-top: 1.5rem; margin-bottom: 0.5rem; font-size: 1.2rem; }
.legal-page h3 { color: var(--text-light); margin-top: 1rem; margin-bottom: 0.4rem; font-size: 1rem; }
.legal-page p, .legal-page li { color: var(--text-light); margin-bottom: 0.6rem; }
.legal-page ul { padding-left: 1.5rem; margin-bottom: 0.8rem; }
.legal-page strong { color: var(--text); }
.legal-page a { color: var(--accent); text-decoration: none; }
.legal-page a:hover { text-decoration: underline; }
.legal-meta {
    background: var(--bg-dark);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}
.legal-back {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary);
    text-decoration: none;
}
.legal-back:hover { text-decoration: underline; }
