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

:root {
    --color-bg:        #f5f6f8;
    --color-surface:   #ffffff;
    --color-border:    #e2e5ea;
    --color-primary:   #2563eb;
    --color-primary-h: #1d4ed8;
    --color-text:      #1e293b;
    --color-muted:     #64748b;
    --color-success:   #16a34a;
    --color-danger:    #dc2626;
    --color-warning:   #d97706;
    --radius:          6px;
    --shadow:          0 1px 3px rgba(0,0,0,.08);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ── Layout ── */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 12px;
    gap: 10px;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

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

.toolbar h1 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-h); }

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

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ── Table container ── */
.table-container {
    flex: 1;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-bg);
}

thead th {
    padding: 9px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td {
    padding: 9px 12px;
    vertical-align: middle;
}

/* ── File icon + type badge ── */
.file-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-icon {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
    letter-spacing: -.02em;
}

.file-icon.word  { background: #2563eb; }
.file-icon.cell  { background: #16a34a; }
.file-icon.slide { background: #ea580c; }
.file-icon.pdf   { background: #dc2626; }
.file-icon.image { background: #7c3aed; }
.file-icon.text  { background: #475569; }
.file-icon.other { background: #94a3b8; }

.file-title {
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 340px;
}

/* ── States: loading / empty / error ── */
.state-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--color-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
}

.state-container .icon {
    font-size: 36px;
    opacity: .5;
}

.state-container p {
    max-width: 320px;
    line-height: 1.5;
}

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Notification toast ── */
.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-danger); }

/* ── Action column ── */
.actions-cell {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    transition: background .15s;
    font-size: 14px;
}
.btn-icon:hover { background: var(--color-bg); }
.btn-icon:disabled { opacity: .4; cursor: not-allowed; }

/* ── Link-Panel (teilbarer Editor-Link) ── */
.link-panel-inner {
    background: #f0f7ff;
    border-top: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
}

.link-box {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-label {
    font-size: 12px;
    color: var(--color-muted);
}

.link-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.link-input {
    flex: 1;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: monospace;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: text;
}

.link-hint {
    font-size: 11px;
    color: #3b82f6;
}

/* ── Session-Liste ── */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.session-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.session-meta {
    font-size: 11px;
    color: var(--color-muted);
}

.session-empty {
    font-size: 12px;
    color: var(--color-muted);
    padding: 4px 0;
}

.new-session-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.ttl-select {
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 12px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }
