html {
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
}

body {
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Login / register: gradient shell, brand + card centered */
body:not(:has(#dashboard-container)) {
    background: linear-gradient(155deg, #2d1545 0%, #4a2771 38%, #6b3d9e 72%, #8f6ad4 100%);
    background-attachment: fixed;
}

body:not(:has(#dashboard-container)) header {
    display: none;
}

body:not(:has(#dashboard-container)) footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 20px 24px 24px;
    text-align: center;
}

body:not(:has(#dashboard-container)) footer p {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
}

main[role='main']:not(.main--dashboard) {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px 24px;
    max-width: 100%;
    box-sizing: border-box;
}

@media (min-height: 540px) {
    main[role='main']:not(.main--dashboard) {
        padding: min(8vh, 56px) 20px 32px;
    }
}

/* Usable down to ~400px × 700px (assignment minimum mobile). */
header h1,
footer p {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

/* Dashboard: full-width shell (Ed-style); login/register keep padded main */
main.main--dashboard {
    padding: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

body:has(#dashboard-container) > header {
    display: none;
}

body:has(#dashboard-container) {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

body:has(#dashboard-container) main[role='main'] {
    flex: 1;
    min-height: 0;
}

/* 2.6.3 — in-page watch notifications (fixed to viewport) */
.notification-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    max-width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

.notification-container .notification-item {
    pointer-events: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    line-height: 1.35;
    cursor: default;
}

.notification-item--clickable {
    cursor: pointer;
}

.notification-item__text {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.notification-item__close {
    flex-shrink: 0;
    margin: -4px -4px -4px 0;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #333;
}

.notification-item__close:hover {
    background: #f0f0f0;
}

.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(440px, 100%);
    margin: 0 auto;
    gap: 28px;
}

.auth-page__brand-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.auth-page__brand {
    margin: 0;
    padding: 0;
    font-size: clamp(1.65rem, 6.5vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.08;
    text-align: center;
    color: #fff;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.auth-page__brand-name {
    font-weight: 800;
}

.auth-page__brand-tld {
    font-weight: 600;
    opacity: 0.88;
}

.auth-page__tagline {
    margin: 0;
    padding: 0 8px;
    max-width: 22em;
    font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    font-size: clamp(1.15rem, 3.8vw, 1.45rem);
    font-weight: 500;
    font-style: italic;
    letter-spacing: 0.14em;
    text-align: center;
    line-height: 1.45;
    color: transparent;
    background: linear-gradient(
        105deg,
        rgba(255, 248, 235, 0.92) 0%,
        rgba(255, 255, 255, 0.98) 35%,
        rgba(232, 214, 255, 0.95) 65%,
        rgba(255, 248, 235, 0.9) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
    animation: auth-tagline-shimmer 14s ease-in-out infinite;
}

@keyframes auth-tagline-shimmer {
    0%,
    100% {
        background-position: 0% center;
    }
    50% {
        background-position: 100% center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-page__tagline {
        animation: none;
        background-position: 50% center;
    }
}

.auth-page__panel {
    width: 100%;
    padding: 28px 26px 26px;
    background: #fff;
    border-radius: 16px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 12px 40px rgba(45, 21, 69, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.auth-page__title {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #202124;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.auth-page__form {
    width: 100%;
}

.auth-page .field {
    margin-bottom: 14px;
}

.auth-page label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #5f6368;
    margin-bottom: 6px;
}

.auth-page input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
}

.auth-page input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.auth-page__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
}

.auth-page__btn {
    width: 100%;
    min-height: 40px;
    padding: 10px 16px;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    box-sizing: border-box;
}

.auth-page__btn--primary {
    border: 1px solid #1a73e8;
    background: #1a73e8;
    color: #fff;
}

.auth-page__btn--primary:hover {
    background: #1765cc;
    border-color: #1765cc;
}

.auth-page__btn--secondary {
    border: 1px solid #dadce0;
    background: #fff;
    color: #202124;
}

.auth-page__btn--secondary:hover {
    background: #f8f9fa;
}

:root {
    --dashboard-header-bg: #4a2771;
    --dashboard-header-text: #fff;
    --dashboard-workspace-bg: #eceef1;
    --dashboard-sidebar-bg: #f8f9fa;
    --dashboard-panel-bg: #fff;
    --dashboard-border: #e8eaed;
}

.dashboard-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100%;
    width: 100%;
}

/* Purple app bar (full width) */
.dashboard-app-header {
    flex-shrink: 0;
    background: var(--dashboard-header-bg);
    color: var(--dashboard-header-text);
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

.dashboard-brand {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.dashboard-app-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-app-header .avatar-label,
.dashboard-app-header button {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: var(--dashboard-header-text);
    cursor: pointer;
    font: inherit;
}

.dashboard-app-header .avatar-label:hover,
.dashboard-app-header button:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* #logout-button is global white below; ID wins over .dashboard-app-header button → white-on-white text */
.dashboard-app-header #logout-button {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: var(--dashboard-header-text);
}

.dashboard-app-header #logout-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Grey workspace + two-column shell (~32% / ~68%) */
.dashboard-workspace {
    flex: 1;
    min-height: 0;
    background: var(--dashboard-workspace-bg);
    padding: 16px 20px 24px;
    box-sizing: border-box;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 32%) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    max-width: 1400px;
    margin: 0 auto;
    min-height: min(720px, calc(100vh - 140px));
}

.dashboard-left {
    border: 1px solid var(--dashboard-border);
    border-radius: 8px;
    background: var(--dashboard-sidebar-bg);
    padding: 10px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dashboard-right-wrap {
    border: 1px solid var(--dashboard-border);
    border-radius: 8px;
    background: var(--dashboard-panel-bg);
    min-height: 240px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dashboard-right-panel {
    padding: 12px;
}

#profile-container {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    min-height: 220px;
    overflow-y: auto;
    box-sizing: border-box;
    padding-top: 6px;
}

.profile-screen {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 100%;
}

.profile-loading {
    margin: 0;
    font-size: 14px;
    color: #5f6368;
}

.profile-screen__hdr {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-screen__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #202124;
}

/* Profile Save / Back — same footprint */
.profile-action-btn {
    min-width: 96px;
    min-height: 38px;
    padding: 8px 18px;
    box-sizing: border-box;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
}

.profile-action-btn--primary {
    border: 1px solid #1a73e8;
    background: #1a73e8;
    color: #fff;
}

.profile-action-btn--primary:hover {
    background: #1765cc;
    border-color: #1765cc;
}

.profile-action-btn--secondary {
    border: 1px solid #dadce0;
    background: #fff;
    color: #1a73e8;
}

.profile-action-btn--secondary:hover {
    background: #f8f9fa;
}

.profile-toolbar-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.profile-toolbar-actions--card-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e8eaed;
}

.profile-toolbar-actions--form-footer {
    margin-top: 4px;
}

/* One card: hero + optional form */
.profile-card {
    border: 1px solid #e8eaed;
    border-radius: 10px;
    background: #fff;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.profile-hero {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
}

.profile-hero__avatar-wrap {
    flex-shrink: 0;
}

.profile-hero__avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 1px solid #e8eaed;
    background: #f1f3f4;
}

.profile-hero__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: #5f6368;
}

.profile-hero__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.profile-hero__name {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.25;
    color: #202124;
}

.profile-hero__email {
    margin: 0;
    font-size: 13px;
    color: #5f6368;
    word-break: break-all;
}

.profile-hero__lead {
    margin: 0;
    font-size: 13px;
    color: #5f6368;
}

.profile-role-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e8f0fe;
    color: #1967d2;
}

.profile-update-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e8eaed;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-update-form__head {
    margin-bottom: 2px;
}

.profile-update-form__title {
    font-size: 13px;
    font-weight: 600;
    color: #3c4043;
}

.profile-update-form .field,
.profile-admin-box {
    margin-bottom: 0;
}

.profile-update-form label,
.profile-admin-box label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #5f6368;
    margin-bottom: 4px;
}

.profile-update-form input[type='text'],
.profile-update-form input[type='email'],
.profile-update-form input[type='password'] {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
}

.profile-update-form input[type='text']:focus,
.profile-update-form input[type='email']:focus,
.profile-update-form input[type='password']:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

.profile-update-form .field--file input[type='file'] {
    max-width: 100%;
    font-size: 13px;
}

#user-permission-submit {
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid #1a73e8;
    background: #1a73e8;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
}

#user-permission-submit:hover {
    background: #1765cc;
    border-color: #1765cc;
}

.profile-admin-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid #e8eaed;
    border-radius: 10px;
    background: #fafafa;
}

.profile-admin-box label {
    margin-bottom: 0;
}

#user-permission {
    padding: 6px 10px;
    font: inherit;
    font-size: 14px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    min-width: 120px;
}

.profile-threads-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-section__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#profile-thread-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-thread-container {
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.profile-thread-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
    color: #202124;
}

.profile-thread-content {
    font-size: 13px;
    margin-bottom: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #3c4043;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.profile-thread-likes,
.profile-thread-comments {
    font-size: 12px;
    color: #5f6368;
}

.profile-thread-empty {
    margin: 0;
    font-size: 13px;
    color: #5f6368;
}

.profile-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #1a73e8;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    text-align: left;
}

.thread-author-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

/* Thread OP header: larger avatar (Ed-style “subject” author) */
.thread-author-avatar--thread {
    width: 64px;
    height: 64px;
}

.thread-author-avatar__img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.thread-author-avatar--thread .thread-author-avatar__img {
    width: 64px;
    height: 64px;
}

.thread-author-avatar__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e8eaed;
    font-size: 16px;
    font-weight: 600;
    color: #444;
    line-height: 1;
}

.thread-author-avatar--thread .thread-author-avatar__placeholder {
    width: 64px;
    height: 64px;
    font-size: 22px;
}

#thread-author {
    flex: 1;
    min-width: 0;
    width: 100%;
}

#thread-author .profile-link {
    display: inline;
}

/* Author display:flex wins over the [hidden] attribute — force hide when toggling panels */
#thread-container[hidden],
#profile-container[hidden] {
    display: none !important;
}

/* Milestone 3: keep like/watch/edit/delete above the fold; body scrolls */
#thread-container {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    min-height: 220px;
    overflow: hidden;
    box-sizing: border-box;
    /* Tighter than .dashboard-right-panel 12px — keep thread title near top of panel */
    padding-top: 16px;
}

/* Create thread: allow scroll; avoid max-height clip from default #thread-container */
#thread-container.thread-container--create {
    max-height: none;
    overflow-y: auto;
    padding-top: 8px;
}

/* Thread OP: title + header row (avatar + author | actions), then body */
.thread-post-top {
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: none;
}

.thread-post-top #thread-title {
    margin: 0 0 20px 0;
    font-size: clamp(1.5rem, 3vw, 1.95rem);
    font-weight: 600;
    line-height: 1.22;
    color: #202124;
    letter-spacing: -0.02em;
}

.thread-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 10px;
}

.thread-post-header__left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.thread-post-header__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.thread-post-created {
    font-size: 12px;
    line-height: 1.35;
    color: #5f6368;
}

.thread-post-created:empty {
    display: none;
}

.thread-post-header .thread-post-toolbar {
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    justify-content: flex-end;
    align-items: center;
    align-self: center;
}

.thread-post-header .thread-toggle__hint {
    display: none;
}

.thread-post-header .thread-toggle--stack {
    align-items: center;
}

/* Body below meta: ~two lines of space when viewport is tight */
/* Indent with OP avatar (64px) + gap (14px) so body lines up with author column */
.thread-post-content {
    margin-top: clamp(1.25rem, 4vh, 2.75rem);
    margin-bottom: 8px;
    padding-bottom: 0;
    padding-left: calc(64px + 14px);
    box-sizing: border-box;
    border-bottom: none;
}

.thread-post-main {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.thread-post-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.thread-post-meta {
    font-size: 13px;
    color: #5f6368;
    margin-top: 4px;
    padding-top: 8px;
    border-top: none;
}

.thread-detail-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

#thread-title {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

#thread-body {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    font-size: 1.8rem;
    line-height: 1.65;
    color: #202124;
    letter-spacing: 0.01em;
    padding: 0 0 12px;
    margin: 0;
}

.thread-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.thread-toggle {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #333;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.thread-toggle--stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    text-align: left;
}

.thread-toggle__main {
    font-weight: 600;
}

.thread-toggle__hint {
    font-size: 11px;
    font-weight: 400;
    line-height: 1.25;
    opacity: 0.92;
    max-width: 168px;
}

.thread-toggle--active {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #174ea6;
}

.thread-toggle--like {
    border-color: #137333;
    color: #137333;
}

.thread-toggle--watch {
    border-color: #9334e6;
    color: #6b2fba;
}

.thread-toggle--edit {
    text-transform: none;
}

/* Milestone 3: #edit-thread-container is the edit “screen” (new page in panel) */
#edit-thread-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#edit-thread-container .edit-thread-locked-notice {
    margin: 0 0 8px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: #5f4b6b;
    background: #f3e8ff;
    border: 1px solid #d4b8f0;
    border-radius: 6px;
}

#edit-thread-container .field {
    margin-bottom: 12px;
}

#edit-thread-container label {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

#edit-thread-container input[type='text'],
#edit-thread-container textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font: inherit;
    box-sizing: border-box;
}

#edit-thread-container .field--inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

#edit-thread-container .field--inline label {
    margin-bottom: 0;
}

#edit-thread-container .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

#edit-thread-container .actions button {
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid #333;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

#edit-thread-container #edit-thread-submit {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}

.thread-toggle--danger {
    border-color: #b3261e;
    color: #b3261e;
}

#logout-button {
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid #333;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-thread-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    box-sizing: border-box;
    max-height: 100px;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-thread-container.is-selected {
    border-color: #1a73e8;
}

.list-thread-title {
    font-weight: bold;
    margin-bottom: 0;
    line-height: 1.2;
    font-size: 13px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}

.list-thread-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-shrink: 0;
    min-height: 0;
}

.thread-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid currentColor;
    letter-spacing: 0.2px;
    white-space: nowrap;
    text-transform: uppercase;
    flex-shrink: 0;
}

.thread-badge--public {
    color: #0b57d0;
    background: #e8f0fe;
}

.thread-badge--public::before {
    content: '🌐';
    font-size: 13px;
    line-height: 1;
}

.thread-badge--private {
    color: #b3261e;
    background: #fce8e6;
}

.thread-badge--private::before {
    content: '🔒';
    font-size: 13px;
    line-height: 1;
}

.list-thread-author,
.list-thread-date,
.list-thread-likes {
    font-size: 11px;
    line-height: 1.2;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.thread-list-scroll-wrap {
    max-height: calc(100vh - 140px);
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Inside dashboard shell, let the left column height drive scrolling */
.dashboard-left .thread-list-scroll-wrap {
    flex: 1 1 auto;
    max-height: none;
}

.thread-list-loading {
    padding: 10px 4px 4px;
    font-size: 13px;
    color: #666;
    text-align: center;
}

.error-popup {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1000;
}

.error-popup__inner {
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    width: min(320px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

#error-message {
    margin: 0 0 12px 0;
}

#error-close {
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #333;
    background: #fff;
    font: inherit;
}

/* Milestone 4: comments — flat list, no inner cards */
.thread-comments-block {
    margin-top: 20px;
    padding-top: 16px;
    border-top: none;
}

.thread-comments-heading {
    font-size: 15px;
    margin: 0 0 12px 0;
    font-weight: 600;
    color: #3c4043;
}

#comment-list-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 14px;
    box-sizing: border-box;
}

.comment-thread-lines-svg {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.thread-comment-composer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.thread-comment-composer__box {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 14px;
    border: 1px solid #dadce0;
    border-radius: 24px;
    background: #fff;
    box-sizing: border-box;
    transition: border-radius 0.15s ease, gap 0.15s ease;
}

.thread-comment-composer--active .thread-comment-composer__box {
    gap: 10px;
    border-radius: 12px;
}

#thread-comment-text {
    font: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 2px 0;
    border: none;
    outline: none;
    resize: none;
    min-height: 40px;
    background: transparent;
    line-height: 1.4;
}

.thread-comment-composer--active #thread-comment-text {
    min-height: 88px;
}

#thread-comment-text::placeholder {
    color: #9aa0a6;
    opacity: 1;
}

#thread-comment-submit {
    align-self: flex-end;
    padding: 6px 14px;
    font: inherit;
    cursor: pointer;
}

#thread-comment-submit[hidden] {
    display: none !important;
}

.list-comment-container {
    position: relative;
    z-index: 1;
    border: none;
    border-radius: 0;
    padding: 14px 0;
    background: transparent;
    border-bottom: none;
}

.list-comment-inner {
    display: block;
}

/* Avatar column | text column (name row + body + likes) — Ed-style */
.list-comment-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
}

.list-comment-avatar-col {
    flex-shrink: 0;
}

/* Grid: col1 = name + body + likes (aligned); col2 = actions on row 1 only */
.list-comment-text-col {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
}

.list-comment-header {
    display: contents;
}

.list-comment-header__titles {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.list-comment-header__actions {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.list-comment-header__btn {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #dadce0;
    background: #fff;
    color: #1a73e8;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    line-height: 1.2;
}

.list-comment-header__btn.comment-delete-button {
    color: #c5221f;
    border-color: #f0cecd;
}

.list-comment-header__btn--like {
    border-color: #cce8d4;
    color: #137333;
}

.list-comment-header__like-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.list-comment-profile {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #e8eaed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.list-comment-profile--header {
    width: 48px;
    height: 48px;
    font-size: 17px;
}

.list-comment-profile--header .list-comment-profile__img {
    width: 100%;
    height: 100%;
}

.list-comment-profile__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.list-comment-meta-col {
    flex: 1;
    min-width: 0;
}

.list-comment-author {
    font-weight: 600;
    font-size: 13px;
}

button.list-comment-author.profile-link {
    display: block;
    width: 100%;
    text-align: left;
}

.list-comment-date {
    font-size: 11px;
    color: #5f6368;
    margin-top: 2px;
}

.list-comment-body {
    grid-column: 1;
    margin-top: 0;
    font-size: 16px;
    line-height: 1.55;
    color: #202124;
    white-space: pre-wrap;
    word-break: break-word;
}

.list-comment-likes {
    grid-column: 1;
    font-size: 11px;
    margin-top: 0;
    color: #5f6368;
}

.comment-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    padding: 16px;
    box-sizing: border-box;
}

.comment-modal[hidden] {
    display: none;
}

.comment-modal form {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    max-width: min(420px, calc(100vw - 32px));
    width: 100%;
    max-height: min(80vh, calc(100vh - 32px));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.comment-modal textarea {
    font: inherit;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 80px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    resize: vertical;
}

.comment-modal__actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
    padding-top: 4px;
}

.comment-modal button[type='submit'] {
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
    background: #1a73e8;
    border: 1px solid #1a73e8;
    color: #fff;
    border-radius: 4px;
}

.comment-modal button[type='button'] {
    padding: 6px 12px;
    cursor: pointer;
    font: inherit;
}

/* -------------------------------------------------------------------------- */
/* Create thread (in dashboard right panel)                                   */
/* -------------------------------------------------------------------------- */

.create-thread-card {
    border: 1px solid #e8eaed;
    border-radius: 10px;
    background: #fff;
    padding: 16px 18px;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
    box-sizing: border-box;
    max-width: 100%;
}

.create-thread-card__title {
    margin: 0 0 14px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #202124;
    letter-spacing: -0.02em;
}

#create-thread-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#create-thread-form .field {
    margin-bottom: 12px;
}

#create-thread-form .field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #5f6368;
    margin-bottom: 4px;
}

#create-thread-form input[type='text'],
#create-thread-form textarea {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
}

#create-thread-form input[type='text']:focus,
#create-thread-form textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 1px #1a73e8;
}

#create-thread-form textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.5;
}

#create-thread-form .create-thread-private-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

#create-thread-form .create-thread-private-row label {
    display: inline;
    margin-bottom: 0;
    font-size: 14px;
    color: #3c4043;
    cursor: pointer;
    font-weight: 500;
}

#create-thread-form .create-thread-private-row input[type='checkbox'] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 4px;
}

#create-thread-form .create-thread-form__actions {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e8eaed;
}

/* Responsive: tablet (≤768) stack layout; narrow mobile (≤400) incl. 400×700 min */

@media (max-width: 768px) {
    main[role="main"] {
        padding: 12px 10px;
    }

    .auth-page {
        max-width: 100%;
        padding: 0 2px;
    }

    .thread-post-header {
        flex-direction: column;
        align-items: stretch;
    }

    .thread-post-header .thread-post-toolbar {
        width: 100%;
        justify-content: flex-start;
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .dashboard-left {
        max-width: 100%;
        order: 1;
    }

    .dashboard-right-wrap {
        order: 2;
        min-width: 0;
    }

    .dashboard-app-header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-app-header-actions {
        justify-content: flex-start;
        width: 100%;
        gap: 8px;
    }

    #logout-button {
        align-self: flex-end;
    }

    #thread-container,
    #profile-container {
        max-height: none;
        min-height: 180px;
    }

    .thread-toggle--stack .thread-toggle__hint {
        max-width: none;
    }

    .list-thread-title-row {
        flex-wrap: wrap;
    }

    .thread-badge {
        flex-shrink: 0;
    }

    .thread-actions {
        gap: 6px;
    }
}

@media (max-height: 720px) {
    #thread-container,
    #profile-container {
        max-height: min(65vh, calc(100vh - 96px));
    }

    .comment-modal form {
        max-height: min(75vh, calc(100vh - 24px));
    }
}

@media (max-width: 400px) {
    main[role="main"] {
        padding: 10px 8px;
    }

    header h1 {
        font-size: clamp(1rem, 5vw, 1.25rem);
    }

    .dashboard-layout {
        gap: 10px;
    }

    .dashboard-left,
    .dashboard-right-wrap {
        border-radius: 4px;
        padding: 8px;
    }

    .avatar-label,
    #create-thread-button,
    #logout-button {
        min-height: 40px;
        padding: 8px 12px;
    }

    #thread-container,
    #profile-container {
        padding: 10px;
    }

    .profile-screen {
        gap: 10px;
    }

    .thread-toggle {
        flex: 1 1 auto;
        min-width: min(140px, 100%);
    }

    .thread-toggle--stack {
        width: 100%;
    }

    .error-popup__inner {
        width: min(100%, calc(100vw - 24px));
        padding: 12px 14px;
    }
}

@media (max-width: 400px) and (max-height: 700px) {
    #thread-container,
    #profile-container {
        max-height: min(58vh, calc(100vh - 88px));
    }
}
