:root {
    /* Material 3 Expressive Palette */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    --md-sys-color-background: #FFFBFE;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-surface-variant: #E7E0EB;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-sys-color-success: #10b981;
    --md-sys-color-error: #B3261E;
}

body {
    margin: 0;
    font-family: 'Roboto', 'Segoe UI', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

h1 { font-size: 1.5rem; color: var(--md-sys-color-primary); margin: 0; }

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--md-sys-color-surface-variant);
    padding: 0.4rem;
    border-radius: 100px;
    width: fit-content;
}

.tabs button {
    background: none;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 100px;
    font-weight: 600;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
}

.tabs button.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filter-chip {
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    padding: 0.4rem 0.8rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    transition: all 0.2s;
}

.filter-chip:hover {
    background: #e2daeb;
}

.filter-chip.active {
    background: var(--md-sys-color-primary);
    color: white;
    border-color: var(--md-sys-color-primary);
}

.filter-chips.small .filter-chip {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.filter-chips.small .filter-chip:hover {
    background: #e2e8f0;
}

m3-button {
    display: inline-block;
    --m3-button-margin: 0;
}

#target-form m3-button {
    height: 48px; /* Match standard input height */
    width: 100%;
}

@media (min-width: 600px) {
    #target-form m3-button {
        width: auto;
    }
}

section {
    background: var(--md-sys-color-surface);
    border-radius: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--md-sys-color-outline);
}

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

#target-form {
    display: grid;
    gap: 1rem;
    align-items: flex-end;
}

@media (min-width: 600px) {
    #target-form { grid-template-columns: 1fr 1.5fr auto; }
}

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
label { font-weight: 600; font-size: 0.9rem; color: var(--md-sys-color-on-surface-variant); }
input, select {
    padding: 0.75rem;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.targets-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.target-card {
    background: var(--md-sys-color-surface-variant);
    border-radius: 1.25rem;
    padding: 1.25rem;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.target-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.target-type {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.type-symbol {
    width: 36px;
    height: 36px;
    background: var(--md-sys-color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.1rem;
}

.target-authority {
    background: rgba(255,255,255,0.6);
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 2.5rem;
    position: relative;
}

.copy-btn {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--md-sys-color-primary-container);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.card-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.4rem;
}

.card-actions button {
    background: rgba(255,255,255,0.4);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.modal {
    background: white;
    border-radius: 2rem;
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}

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

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-pic {
    width: 44px; /* Fixed size, not HUGE */
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #eee;
}

.profile-name { font-weight: 700; font-size: 1.1rem; }
.profile-npub { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); font-family: monospace; }

/* Browse */
.form-group.row { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.form-group.row input { flex: 1; }

.browse-item {
    background: white;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 1.25rem;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
}

.browse-author-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.browse-pic {
    width: 28px; /* Fixed size, not HUGE */
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.browse-targets { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.mini-target {
    background: var(--md-sys-color-surface-variant);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
}

.hidden { display: none !important; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--md-sys-color-on-surface-variant); }

.target-network-badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 800;
    margin-left: 0.5rem;
}

.network-testnet { background: #fef9c3; color: #854d0e; }

/* Markdown Rendering Styles */
.markdown-body {
    line-height: 1.6;
    color: var(--md-sys-color-on-surface);
    padding: 0 0.5rem;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: 0.3rem;
}
.markdown-body p { margin-bottom: 1rem; }
.markdown-body code {
    background: var(--md-sys-color-surface-variant);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}
.markdown-body pre {
    background: var(--md-sys-color-surface-variant);
    padding: 1rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--md-sys-color-outline);
    padding: 0.5rem;
    text-align: left;
}
.markdown-body th { background: var(--md-sys-color-surface-variant); }

.modal-body .targets-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

footer { text-align: center; padding: 2rem; font-size: 0.8rem; color: var(--md-sys-color-on-surface-variant); }

#relay-list { list-style: none; padding: 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
#relay-list li { background: var(--md-sys-color-secondary-container); padding: 0.2rem 0.6rem; border-radius: 100px; font-size: 0.75rem; }
