/* ientra.css – LinkedIn-inspired */

/* ------------------------------------------------------------------
   Design tokens (light theme — default on :root)
   Dark mode: override on body.dark-mode (see block below)
   ------------------------------------------------------------------ */
:root {
    /* Brand */
    --color-primary: #0a66c2;
    --color-primary-hover: #004182;
    --color-primary-contrast: #ffffff;

    /* Surfaces */
    --color-bg: #f3f2ef;
    --color-surface: #ffffff;
    --color-surface-muted: #f9f9f9;
    --color-surface-subtle: #fafafa;
    --color-surface-hover: #f0f0f0;
    --color-surface-active: #e0e0e0;

    /* Text */
    --color-text: #333333;
    --color-text-muted: #666666;
    --color-text-strong: #000000;

    /* Borders */
    --color-border: #e0e0e0;

    /* Feedback */
    --color-success: #2e7d32;
    --color-error: #d32f2f;

    /* Overlays & scrims */
    --color-overlay: rgba(0, 0, 0, 0.5);
    --color-scrim: rgba(0, 0, 0, 0.6);
    --color-scrim-strong: rgba(0, 0, 0, 0.8);

    /* Toast (neutral) */
    --color-toast-bg: #333333;
    --color-toast-text: #ffffff;

    /* Layout & shape */
    --radius: 8px;
    --radius-sm: 4px;
    --radius-pill: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 5px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 2px 5px rgba(0, 0, 0, 0.3);
    --shadow-avatar: 0 1px 3px rgba(0, 0, 0, 0.3);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --line-height: 1.5;

    /* Layout widths */
    --layout-max-width: 1128px;
    --panel-width: 250px;
    --navbar-offset: 80px;
}

body.dark-mode {
    color-scheme: dark;
    --color-primary: #70b5f9;
    --color-primary-hover: #9ecbfa;
    --color-primary-contrast: #0d1117;

    --color-bg: #1b1f23;
    --color-surface: #1d2226;
    --color-surface-muted: #252a2f;
    --color-surface-subtle: #22262a;
    --color-surface-hover: #2f363d;
    --color-surface-active: #38434f;

    --color-text: #e8eaed;
    --color-text-muted: #9aa0a6;
    --color-text-strong: #ffffff;

    --color-border: #38434f;

    --color-success: #6fcf97;
    --color-error: #f28b82;

    --color-overlay: rgba(0, 0, 0, 0.65);
    --color-scrim: rgba(0, 0, 0, 0.75);
    --color-scrim-strong: rgba(0, 0, 0, 0.9);

    --color-toast-bg: #2d333b;
    --color-toast-text: #e8eaed;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.55);
    --shadow-avatar: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------------ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: var(--line-height);
}

/* ------------------------------------------------------------------
   Shared form controls
   ------------------------------------------------------------------ */
.auth-card input,
.profile-inputs input,
.settings-frame input,
.password-frame input,
.login-form input[type="password"],
.composer textarea,
.add-connection input {
    display: block;
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.auth-card input,
.profile-inputs input,
.settings-frame input,
.password-frame input {
    margin-bottom: 0.8rem;
}

.settings-frame input:last-child,
.password-frame input:last-child {
    margin-bottom: 0;
}

.auth-card input {
    margin-bottom: 1rem;
}

.composer textarea {
    min-height: 80px;
    resize: none;
    overflow-y: hidden;
    transition: border-color 0.3s;
}

.add-connection input {
    flex: 1;
    padding: 0.5rem;
}

/* ------------------------------------------------------------------
   Shared buttons
   ------------------------------------------------------------------ */
.auth-card button,
.primary-btn,
.my-node-url button,
.add-connection button {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.auth-card button:hover,
.primary-btn:hover,
.my-node-url button:hover,
.add-connection button:hover {
    background: var(--color-primary-hover);
}

.auth-card button {
    width: 100%;
    padding: 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.primary-btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-pill);
    font-weight: bold;
}

.my-node-url button {
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
}

.add-connection button {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------
   Auth
   ------------------------------------------------------------------ */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.auth-card {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
    color: var(--color-primary);
}

/* ------------------------------------------------------------------
   Navbar
   ------------------------------------------------------------------ */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-primary);
    cursor: pointer;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.navbar-profile-trigger {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.navbar-user-info {
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    min-width: 0;
}

.navbar-user-info:hover {
    background: var(--color-surface-hover);
}

.navbar-user-info .user-name,
.navbar-user-info .user-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
}

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.user-info:hover {
    background: var(--color-surface-hover);
}

.user-name {
    font-weight: bold;
}

.user-title {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.navbar-right button {
    background: none;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.navbar-right button:hover {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */
.container {
    display: flex;
    gap: 1rem;
    max-width: var(--layout-max-width);
    margin: 1rem auto;
    padding: 0 1rem;
    align-items: flex-start;
}

.left-panel,
.right-panel {
    flex: 0 0 var(--panel-width);
    position: sticky;
    top: var(--navbar-offset);
    align-self: flex-start;
}

.center-column {
    flex: 1;
    min-width: 0;
}

/* ------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------ */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.connections-card {
    cursor: pointer;
    transition: background 0.2s;
}

.connections-card:hover {
    background: var(--color-surface-hover);
}

.connections-card-text {
    display: block;
    font-size: 1rem;
    color: var(--color-text);
}

.connections-card-count {
    font-weight: bold;
    color: var(--color-primary);
}

.profile-card {
    text-align: center;
}

.mobile-nav-backdrop {
    display: none;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.profile-name {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.profile-title {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.banner-card {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-muted);
    border: 1px dashed var(--color-border);
}

.banner-placeholder {
    color: var(--color-text-muted);
}

.copyright {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    padding: 1rem 0;
}

/* ------------------------------------------------------------------
   Composer
   ------------------------------------------------------------------ */
.composer textarea.limit-reached {
    border-color: var(--color-error);
    border-width: 2px;
    outline: none;
}

.composer textarea.limit-reached:focus {
    border-color: var(--color-error);
    box-shadow: 0 0 0 1px var(--color-error);
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.image-upload-wrap {
    position: relative;
}

.image-upload-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-pill);
    transition: background 0.2s;
}

.image-upload-label:hover {
    background: var(--color-surface-hover);
}

.file-input {
    display: none;
}

.image-preview {
    margin-top: 1rem;
    position: relative;
    display: none;
}

.preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.preview-edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-scrim);
    color: var(--color-primary-contrast);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.preview-edit-btn:hover {
    background: var(--color-scrim-strong);
}

/* ------------------------------------------------------------------
   Posts
   ------------------------------------------------------------------ */
.post {
    cursor: pointer;
}

.post-header {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar.clickable {
    cursor: pointer;
}

.post-author-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.post-header-meta {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: auto;
}

.post-header-meta .post-date {
    white-space: nowrap;
    line-height: 1.5;
    padding-top: 0.15rem;
}

.post-author {
    font-weight: bold;
    cursor: pointer;
}

.post-author.clickable:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.post-author-title,
.post-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.post-content {
    margin-bottom: 0.5rem;
}

.post-content p,
.post-comment-body p {
    margin: 0 0 0.5rem;
}

.post-content p:last-child,
.post-comment-body p:last-child {
    margin-bottom: 0;
}

.post-content ul,
.post-content ol,
.post-comment-body ul,
.post-comment-body ol {
    margin: 0.25rem 0 0.5rem;
    padding-left: 1.5rem;
}

.post-content li,
.post-comment-body li {
    margin-bottom: 0.25rem;
}

.post-content strong,
.post-comment-body strong {
    font-weight: 700;
}

.post-content em,
.post-comment-body em {
    font-style: italic;
}

.post-content-link {
    color: var(--color-primary);
    text-decoration: underline;
}

.post-content-link:hover {
    color: var(--color-primary-hover);
}

.more-link {
    color: var(--color-primary);
    cursor: pointer;
    margin-left: 0.3rem;
}

.post-image {
    width: 100%;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
}

.post-actions {
    position: relative;
    flex-shrink: 0;
}

.post-actions-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0 0.5rem;
}

.post-actions-menu {
    position: absolute;
    right: 0;
    top: 30px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 50;
    min-width: 120px;
}

.post-actions-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    color: var(--color-text);
}

.post-actions-menu button:hover {
    background: var(--color-surface-hover);
}

.post-interactions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}

.reaction-btn {
    font-size: 0.9rem;
    cursor: default;
    background: var(--color-surface-hover);
    border-radius: var(--radius-pill);
    padding: 0.2rem 0.6rem;
    color: var(--color-text);
}

.reaction-btn.clickable {
    cursor: pointer;
    transition: background 0.2s;
}

.reaction-btn.clickable:hover {
    background: var(--color-surface-active);
}

.reaction-btn.reaction-active {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

.reaction-btn.reaction-active.clickable:hover {
    background: var(--color-primary-hover);
}

.post-stats {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.post-interactions-restricted {
    border-top: 1px solid var(--color-border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.interactions-restricted {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.reaction-btn.reaction-readonly {
    cursor: default;
}

.copy-feed-card {
    text-align: center;
}

.copy-feed-title {
    font-size: 0.95rem;
    color: var(--color-primary);
    margin-bottom: 0.6rem;
}

.copy-feed-url {
    display: block;
    background: var(--color-surface-hover);
    color: var(--color-text);
    padding: 0.45rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    word-break: break-all;
    text-align: left;
    margin-bottom: 0.75rem;
}

.copy-feed-btn {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.post-reactors {
    flex-basis: 100%;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
}

.post-comment-count {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.post-action-btn {
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.post-action-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.post-add-connection {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.35rem;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    vertical-align: middle;
}

.post-add-connection:hover {
    background: var(--color-surface-hover);
}

.post-add-connection-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.post-comments {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--color-border);
}

.post-comments-summary,
.post-comments-load-more {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: none;
    border: none;
    padding: 0.15rem 0;
    cursor: pointer;
}

.post-comments-summary:hover,
.post-comments-load-more:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.post-comments-load-more {
    margin-top: 0.35rem;
    font-weight: 500;
}

.post-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.post-comment {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0;
}

.post-comment-main {
    flex: 1;
    min-width: 0;
}

.post-comment-bubble {
    background: var(--color-surface-hover);
    border-radius: 0 0.75rem 0.75rem 0.75rem;
    padding: 0.45rem 0.75rem;
}

.post-comment-bubble .post-comment-author {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 0.15rem;
}

.post-comment-foot {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.2rem;
    padding-left: 0.15rem;
    flex-wrap: wrap;
}

.comment-interactions {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
}

.comment-reaction-btn {
    font-size: 0.72rem;
    cursor: default;
    background: var(--color-surface-hover);
    border-radius: var(--radius-pill);
    padding: 0.1rem 0.4rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.comment-reaction-btn.clickable {
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.comment-reaction-btn.clickable:hover {
    background: var(--color-surface-active);
    color: var(--color-text);
}

.comment-reaction-btn.reaction-active {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

.comment-reaction-btn.reaction-active.clickable:hover {
    background: var(--color-primary-hover);
}

.comment-reaction-readonly {
    cursor: default;
}

.post-comment-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.post-comment-thread {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.post-comment-replies {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-left: 2.5rem;
}

.post-comment-reply-btn {
    align-self: flex-start;
    margin-left: 2.5rem;
    border: none;
    background: none;
    color: var(--color-text-muted);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}

.post-comment-reply-btn:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.post-comment-reply-form {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-left: 2.5rem;
}

.post-comment-author {
    font-weight: 600;
}

.post-comment-date {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.post-comment-body {
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.post-comment-composer {
    margin-top: 0.75rem;
}

.post-comment-composer-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.post-comment-composer-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.post-comment-composer-input-wrap {
    flex: 1;
    min-width: 0;
}

.post-comment-composer-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.35rem;
}

.post-comment-input {
    width: 100%;
    min-height: 2.25rem;
    resize: none;
    overflow-y: hidden;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 1.25rem;
    font: inherit;
    font-size: 0.88rem;
    background: var(--color-surface);
    color: var(--color-text);
}

.post-comment-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.post-comment-submit {
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-primary);
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.post-comment-submit:hover {
    background: var(--color-surface-hover);
}

.post-comment-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

.empty-feed {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
}

.feed-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem 1rem;
}

.feed-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: feed-spin 0.8s linear infinite;
}

.feed-loading-text {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

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

.connection-feed-header {
    margin-bottom: 1rem;
}

.connection-feed-back {
    display: inline-block;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.connection-feed-name {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}

.connection-feed-title {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.post-author-title.clickable {
    cursor: pointer;
}

.post-author-title.clickable:hover {
    text-decoration: underline;
}

/* ------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------ */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--color-toast-bg);
    color: var(--color-toast-text);
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

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

.toast-error {
    background: var(--color-error);
    color: var(--color-primary-contrast);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ------------------------------------------------------------------
   Modals & settings
   ------------------------------------------------------------------ */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--color-overlay);
}

.modal-content {
    background-color: var(--color-surface);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    color: var(--color-text);
}

.settings-modal-content {
    max-width: 520px;
}

.settings-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 1rem 0 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-tab {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.settings-tab:hover {
    color: var(--color-text-strong);
}

.settings-tab-active {
    color: var(--color-text-strong);
    border-bottom-color: var(--color-primary);
}

.settings-tab-panel {
    display: none;
}

.settings-tab-panel-active {
    display: block;
}

.settings-appearance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
}

.settings-appearance .primary-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-appearance-label {
    font-size: 0.95rem;
    font-weight: 600;
}

.settings-appearance-hint {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.settings-toggle {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-surface-hover);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.settings-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.settings-toggle[aria-checked='true'] {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.settings-toggle[aria-checked='true']::after {
    transform: translateX(1.2rem);
    background: var(--color-primary-contrast);
}

.speed-test-results {
    margin-top: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
}

.speed-test-metrics {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
}

.speed-test-metric {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0;
    font-size: 0.95rem;
}

.speed-test-metric-label {
    color: var(--color-text-muted);
}

.speed-test-metric-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.speed-test-rating {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.speed-test-rating-value {
    text-transform: capitalize;
}

.speed-test-rating-advanced {
    color: var(--color-primary);
}

.speed-test-rating-medium {
    color: var(--color-text-strong);
}

.speed-test-rating-light {
    color: var(--color-text-muted);
}

.speed-test-key {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.update-status {
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
}

.update-status-message {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
}

.update-status-message:last-child {
    margin-bottom: 0;
}

.update-status-ok {
    color: var(--color-text-muted);
}

.update-status-error {
    color: var(--color-danger, #b00020);
}

.update-status .primary-btn {
    white-space: nowrap;
}

.connections-modal-content {
    max-width: 680px;
}

.connections-modal-content .connections-list {
    max-height: 360px;
}

.connections-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 1rem 0 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.connections-tab {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.connections-tab:hover {
    color: var(--color-text-strong);
}

.connections-tab-active {
    color: var(--color-text-strong);
    border-bottom-color: var(--color-primary);
}

.connections-tab-panel {
    display: none;
}

.connections-tab-panel-active {
    display: block;
}

.pingbacks-list {
    margin-bottom: 0;
}

.connection-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.connection-speed {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.connection-info-clickable {
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.connection-avatar-clickable {
    cursor: pointer;
}

.connection-restricted {
    opacity: 0.85;
}

.link-actions {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.btn-link-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-link-action:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-strong);
}

.link-action-active {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-surface-subtle);
}

.btn-allow-link {
    border-color: var(--color-border);
}

.btn-sign-in {
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
}

.login-modal-content {
    max-width: 420px;
}

.login-modal-content h2 {
    margin-bottom: 0.35rem;
}

.login-modal-lead {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.45;
    margin-bottom: 1.25rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.login-field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-strong);
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.login-remember input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.login-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.navbar-avatar-static {
    flex-shrink: 0;
}

.post-interactions-own {
    padding-top: 0.25rem;
}

.auth-modal-content {
    max-width: 420px;
}

.auth-modal-content input {
    width: 100%;
    margin-bottom: 1rem;
}

.close-modal {
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--color-text-strong);
}

.settings-body {
    margin-top: 1rem;
}

.settings-frame,
.password-frame {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--color-surface-subtle);
}

.settings-frame h4,
.password-frame h4 {
    margin-bottom: 0.8rem;
    color: var(--color-primary);
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.avatar-edit-container {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.settings-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-edit-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-avatar);
    transition: background 0.2s;
}

.avatar-edit-overlay:hover {
    background: var(--color-primary-hover);
}

.avatar-edit-overlay span {
    font-size: 1rem;
    line-height: 1;
}

.profile-inputs {
    flex: 1;
}

.my-node-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.my-node-url code {
    background: var(--color-surface-hover);
    color: var(--color-text);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-connection {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    min-width: 0;
}

.add-connection input {
    min-width: 0;
}

.connections-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
}

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border);
    min-width: 0;
}

.connection-clickable {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: var(--radius-sm);
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.connection-clickable:hover {
    background: var(--color-surface-hover);
}

.connection-down .connection-name,
.connection-down .connection-title {
    color: var(--color-text-muted);
}

.connection-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.connection-favourite-btn {
    background: none;
    border: none;
    padding: 0.15rem 0.25rem;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
}

.connection-favourite-btn:hover {
    color: var(--color-text-strong);
    transform: scale(1.08);
}

.connection-favourite-btn.connection-favourite-active {
    color: #f5c518;
}

.connection-favourite-btn.connection-favourite-active:hover {
    color: #e6b800;
}

.connection-status {
    font-size: 0.8rem;
    color: var(--color-error);
}

.connection-status-pending {
    color: var(--color-text-muted);
}

.connection-status-paused {
    color: var(--color-text-muted);
}

.connection-paused .connection-name {
    color: var(--color-text-muted);
}

.connection-follow-pending {
    opacity: 0.85;
}

.connection-follow-pending .btn-follow-back:disabled {
    opacity: 1;
    cursor: wait;
}

.btn-follow-back {
    font-weight: 600;
}

.connection-handshake-pending .connection-name {
    color: var(--color-text-muted);
}

.visit-error-card {
    text-align: center;
}

.visit-error-card p {
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
}

.visit-error-home {
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.connection-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.connection-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.connection-name {
    font-weight: bold;
    color: var(--color-text);
}

.connection-title {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.connection-url {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    word-break: break-all;
    line-height: 1.3;
}

.connections-empty {
    color: var(--color-text-muted);
    padding: 1rem 0;
    text-align: center;
}

.connection-item .btn-remove {
    background: none;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    flex-shrink: 0;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        gap: 0;
        margin: 0;
        padding: 0;
        max-width: none;
    }

    .navbar-profile-trigger {
        cursor: pointer;
    }

    .navbar-user-info {
        cursor: pointer;
    }

    .left-panel:not(.side-nav),
    .right-panel {
        position: static;
        flex: 1;
        width: 100%;
        padding: 0 1rem;
        margin-top: 1rem;
    }

    .left-panel:not(.side-nav) .card,
    .right-panel .card {
        border-radius: var(--radius);
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
    }

    .side-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: min(var(--panel-width), 85vw);
        max-width: 320px;
        height: 100dvh;
        min-height: 100%;
        margin: 0;
        padding: 1rem;
        padding-top: max(1rem, env(safe-area-inset-top, 0px));
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
        z-index: 200;
        background: var(--color-bg);
        border-right: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }

    .side-nav.mobile-nav-open {
        transform: translateX(0);
    }

    .side-nav .card {
        border-radius: var(--radius);
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
    }

    .mobile-nav-backdrop.visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 199;
    }

    body.mobile-nav-active {
        overflow: hidden;
    }

    .center-column {
        width: 100%;
    }

    .center-column .card {
        border-radius: 0;
        margin-bottom: 0;
        box-shadow: none;
    }

    .center-column .card + .card {
        margin-top: 0;
    }

    .center-column #feed .card {
        border-bottom: 1px solid var(--color-border);
    }

    .center-column #feed .card:last-child {
        border-bottom: none;
    }

    .center-column .composer {
        border-bottom: 1px solid var(--color-border);
    }
}
