/* ============================================================
   IdeaBoard — flat, professional design system (no shadows)
   ============================================================ */
:root {
    --bg:         #f6f7f9;
    --surface:    #ffffff;
    --surface-2:  #f3f4f6;
    --surface-3:  #eceef1;

    --border:     #e4e6ea;
    --border-2:   #d6d9df;

    --text:       #16181d;
    --text-2:     #5b606b;
    --text-3:     #8a909c;

    --accent:       #5b5bd6;
    --accent-hover: #4d4dc9;
    --accent-press: #4140b4;
    --accent-weak:  #eeeefc;
    --accent-weak-2:#e2e2fb;
    --accent-text:  #4338ca;

    --green:        #198a4a;
    --green-weak:   #e7f6ed;
    --green-border: #bce6cb;

    --red:          #d22d4f;
    --red-hover:    #bd2545;
    --red-weak:     #fcebef;
    --red-border:   #f3c5d0;

    --amber-weak:   #fbf0d9;
    --amber-text:   #94660a;

    --radius-lg: 16px;
    --radius:    12px;
    --radius-sm: 9px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

/* The `hidden` attribute must always win over component `display` rules
   (author CSS otherwise overrides the browser default [hidden]{display:none}). */
[hidden] { display: none !important; }

body {
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.018em; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }

/* ---------- Material Symbols icons ---------- */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    font-size: 20px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
    flex: none;
}
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: .7rem clamp(1rem, 4vw, 2.5rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-mark .material-symbols-outlined { font-size: 24px; }
.brand-name { font-size: 1.05rem; letter-spacing: -.02em; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; }
.user-name { font-weight: 600; font-size: .9rem; }
.inline-form { display: inline; margin: 0; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--accent-weak); color: var(--accent-text);
    border: 1px solid var(--accent-weak-2);
    font-weight: 700; font-size: .78rem; flex: none;
}

/* ---------- Layout ---------- */
.page { max-width: 920px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 2.4rem); }
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}

/* ---------- Buttons ---------- */
.btn {
    font-family: inherit; font-weight: 600; font-size: .9rem;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: .55rem 1rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    transition: background .14s, border-color .14s, color .14s;
    white-space: nowrap; line-height: 1.2;
}
.btn .material-symbols-outlined { font-size: 18px; }
.btn-sm { padding: .42rem .8rem; font-size: .85rem; }
.btn-sm .material-symbols-outlined { font-size: 17px; }
.btn-xs { padding: .34rem .66rem; font-size: .82rem; }
.btn-xs .material-symbols-outlined { font-size: 16px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }
.btn-danger-ghost { background: var(--surface); color: var(--red); border-color: var(--red-border); }
.btn-danger-ghost:hover { background: var(--red-weak); }

.icon-btn {
    border: 1px solid transparent; background: transparent; cursor: pointer;
    color: var(--text-3); width: 34px; height: 34px;
    border-radius: var(--radius-sm); display: inline-grid; place-items: center;
    transition: background .14s, color .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .material-symbols-outlined { font-size: 20px; }

/* ---------- Cards / project grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.project-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.project-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.1rem 1.2rem 1rem;
    color: inherit; display: flex; flex-direction: column; gap: .5rem;
    transition: border-color .14s, background .14s;
}
.project-card:hover { border-color: var(--accent); background: #fcfcff; text-decoration: none; }
.project-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.project-title { font-size: 1.06rem; font-weight: 650; }
.project-desc { margin: 0; font-size: .9rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.55em; }
.project-card-foot { display: flex; gap: 1.1rem; margin-top: .35rem; padding-top: .7rem; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text-2); }
.stat strong { color: var(--text); font-weight: 700; }
.stat-open strong { color: var(--accent-text); }
.stat-done strong { color: var(--green); }

.badge { font-size: .68rem; font-weight: 700; padding: .2rem .5rem; border-radius: 999px; letter-spacing: .02em; flex: none; text-transform: uppercase; }
.badge-owner { background: var(--accent-weak); color: var(--accent-text); }
.badge-shared { background: #e2f1fb; color: #0b6aa2; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 3.5rem 1rem; border: 1px dashed var(--border-2); border-radius: var(--radius); background: var(--surface); }
.empty-illustration { color: var(--text-3); display: inline-flex; }
.empty-illustration .material-symbols-outlined { font-size: 46px; }
.empty-state h2 { margin: .5rem 0 .35rem; }
.empty-state .btn { margin-top: 1.2rem; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2rem 1.8rem;
}
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-logo { color: var(--accent); display: inline-flex; }
.auth-logo .material-symbols-outlined { font-size: 40px; }
.auth-head h1 { font-size: 1.4rem; margin: .5rem 0 .25rem; }
.auth-foot { text-align: center; margin: 1.2rem 0 0; font-size: .9rem; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field-error { font-size: .78rem; color: var(--red); }
input[type=text], input[type=password], input[type=email], textarea {
    font-family: inherit; font-size: .95rem; color: var(--text);
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    padding: .65rem .75rem; background: var(--surface);
    transition: border-color .14s, box-shadow .14s; width: 100%; resize: vertical;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak); background: #fff;
}

.alert { padding: .7rem .85rem; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: 1rem; }
.alert-error { background: var(--red-weak); color: #9f1239; border: 1px solid var(--red-border); }

/* Password field with show/hide toggle */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 4.2rem; }
.pw-toggle {
    position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
    border: none; background: transparent; cursor: pointer;
    font-family: inherit; font-size: .8rem; font-weight: 600; color: var(--text-2);
    padding: .4rem .55rem; border-radius: var(--radius-xs); line-height: 1;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--accent-text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Auto-growing textareas */
textarea.auto-grow { resize: none; overflow-y: hidden; transition: height .08s ease; }

/* ---------- Project header ---------- */
.breadcrumb { margin-bottom: 1rem; }
.breadcrumb a { color: var(--text-2); font-weight: 600; font-size: .88rem; display: inline-flex; align-items: center; gap: .25rem; }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb .material-symbols-outlined { font-size: 18px; }
.project-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem;
}
.project-header-main { min-width: 0; }
.project-header h1 { margin-bottom: .25rem; word-break: break-word; }
.project-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.member-row { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-owner { background: var(--amber-weak); color: var(--amber-text); border-color: #f0dca8; }

/* ---------- Composer ---------- */
.composer { padding: .9rem 1rem; margin-bottom: 1.5rem; }
.composer-input { border: none; background: transparent; padding: .2rem 0; font-size: 1rem; min-height: 2.6em; }
.composer-input:focus { box-shadow: none; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; border-top: 1px solid var(--border); padding-top: .65rem; margin-top: .3rem; }
.composer-tools { display: flex; align-items: center; gap: .35rem; }

/* attach preview chip */
.attach-preview { display: flex; align-items: center; gap: .6rem; margin-top: .65rem; padding: .45rem .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); max-width: 100%; }
.attach-thumb { width: 42px; height: 42px; border-radius: var(--radius-xs); object-fit: cover; border: 1px solid var(--border-2); flex: none; }
.attach-info { min-width: 0; font-size: .82rem; line-height: 1.3; }
.attach-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-size { color: var(--text-3); }
.attach-busy { color: var(--text-2); font-size: .82rem; display: inline-flex; align-items: center; gap: .35rem; }
.attach-remove { margin-left: auto; }
.composer-foot-actions { display: flex; align-items: center; gap: .5rem; }

/* Collapsible "Add an idea" launcher */
.composer-launch { margin-bottom: 1.5rem; }
.composer-open-btn { justify-content: flex-start; color: var(--text-2); border-style: dashed; }
.composer-open-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }

/* ---------- Rich-text editor ---------- */
.rt-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding-bottom: .5rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.rt-btn { width: 30px; height: 30px; border: 1px solid transparent; background: transparent; border-radius: var(--radius-xs); cursor: pointer; color: var(--text-2); display: inline-grid; place-items: center; }
.rt-btn:hover { background: var(--surface-2); color: var(--text); }
.rt-btn.is-active { background: var(--accent-weak); color: var(--accent-text); }
.rt-btn .material-symbols-outlined { font-size: 19px; }
.rt-divider { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }
.rt-colors { display: inline-flex; align-items: center; gap: 4px; }
.rt-color { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; display: inline-block; transition: transform .1s; }
.rt-color:hover { transform: scale(1.15); }
.rt-color.rt-color-default { background: var(--surface); color: var(--text-2); font-weight: 800; font-size: .66rem; display: grid; place-items: center; }
.rt-input { min-height: 2.6em; outline: none; font-size: 1rem; line-height: 1.55; color: var(--text); word-break: break-word; white-space: pre-wrap; }
.rt-input:empty:before, .rt-input.is-empty:before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.reply-box .rt-input { min-height: 2.2em; font-size: .95rem; }
/* rich text inside a posted comment */
.comment-text b, .comment-text strong { font-weight: 700; }
.comment-text u { text-decoration: underline; }

/* ---------- Boards: Ideas (main) + Bugs (right drawer) ---------- */
.boards { position: relative; }
.board-panel { min-width: 0; }
.board-panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.board-panel-head .thread-title { display: flex; align-items: center; gap: .4rem; }
.board-panel-head .thread-title .material-symbols-outlined { font-size: 20px; color: var(--accent); }
.board-panel[data-kind="bug"] .thread-title .material-symbols-outlined { color: var(--red); }

/* Bug count badge on the header button */
.bug-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; }

/* Right-side Bugs drawer (opens on demand) */
.bug-backdrop { position: fixed; inset: 0; background: rgba(20,22,28,.42); z-index: 79; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }
.bug-backdrop.open { opacity: 1; visibility: visible; transition: opacity .25s ease; }
.bug-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 100%); background: var(--bg); border-left: 1px solid var(--border); z-index: 80; transform: translateX(100%); visibility: hidden; transition: transform .26s ease, visibility 0s .26s; overflow-y: auto; padding: .7rem 1.15rem 2.5rem; }
.bug-drawer.open { transform: translateX(0); visibility: visible; transition: transform .26s ease; }
.bug-drawer-bar { display: flex; justify-content: flex-end; position: sticky; top: 0; z-index: 1; }

/* ---------- Thread toolbar ---------- */
.thread-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.thread-title { font-size: 1.05rem; }

/* Bug status selector (on bug root cards) */
.bug-status { font-family: inherit; font-size: .76rem; font-weight: 700; border: 1px solid var(--border-2); border-radius: var(--radius-xs); padding: .2rem .45rem; background: var(--surface); color: var(--text); cursor: pointer; }
.comment.status-new > .comment-body > .comment-card .bug-status { border-color: #9cc7fb; background: #eef5ff; }
.comment.status-in_progress > .comment-body > .comment-card .bug-status { border-color: #f3d27a; background: #fdf6e3; }
.comment.status-done > .comment-body > .comment-card .bug-status { border-color: var(--green-border); background: var(--green-weak); }
.filter-tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.filter-tab { border: none; background: transparent; font-family: inherit; font-weight: 600; font-size: .82rem; color: var(--text-2); padding: .35rem .85rem; border-radius: var(--radius-xs); cursor: pointer; }
.filter-tab:hover { color: var(--text); }
.filter-tab.is-active { background: var(--accent); color: #fff; }

/* ---------- Comment thread ---------- */
.thread { display: flex; flex-direction: column; gap: .65rem; }
.thread-loading, .thread-empty { text-align: center; color: var(--text-3); padding: 2.2rem; font-size: .92rem; }

.comment { display: flex; }
.comment-body { flex: 1 1 auto; min-width: 0; }
.comment-children { margin-left: 8px; padding-left: 14px; border-left: 2px solid var(--border); margin-top: .55rem; display: flex; flex-direction: column; gap: .55rem; }
.comment-children:empty { display: none; }

.comment-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; transition: border-color .14s; }
.comment-card:hover { border-color: var(--border-2); }
.comment.is-done > .comment-body > .comment-card { background: var(--green-weak); border-color: var(--green-border); }
.comment.is-done > .comment-body > .comment-card .comment-text { color: var(--text-2); }

.comment-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; flex-wrap: wrap; }
.comment-avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-weak); color: var(--accent-text); border: 1px solid var(--accent-weak-2); font-weight: 700; font-size: .7rem; flex: none; }
.comment-author { font-weight: 650; font-size: .88rem; }
.comment-date { margin-left: auto; color: var(--text-3); }
.done-pill { display: inline-flex; align-items: center; gap: .2rem; background: var(--green); color: #fff; font-size: .68rem; font-weight: 700; padding: .14rem .45rem; border-radius: 999px; }
.done-pill .material-symbols-outlined { font-size: 13px; }
.comment-text { margin: 0; font-size: .95rem; white-space: pre-wrap; word-break: break-word; }
.comment-text.clamped { display: -webkit-box; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.view-all-btn { margin-top: .3rem; background: none; border: none; padding: 0; font-family: inherit; font-size: .82rem; font-weight: 600; color: var(--accent-text); cursor: pointer; }
.view-all-btn:hover { text-decoration: underline; }

/* image in a comment */
.comment-image-link { display: inline-block; margin-top: .55rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; max-width: min(340px, 100%); }
.comment-image { display: block; width: 100%; max-height: 280px; object-fit: cover; cursor: zoom-in; }

.comment-actions { display: flex; gap: .15rem; margin-top: .55rem; flex-wrap: wrap; }
.action-btn { border: none; background: transparent; font-family: inherit; font-size: .8rem; font-weight: 600; color: var(--text-2); padding: .3rem .55rem; border-radius: var(--radius-xs); cursor: pointer; display: inline-flex; align-items: center; gap: .28rem; transition: background .12s, color .12s; }
.action-btn .material-symbols-outlined { font-size: 17px; }
.action-btn:hover { background: var(--surface-2); color: var(--text); }
.action-btn.action-danger:hover { background: var(--red-weak); color: var(--red); }
.comment.is-done .js-toggle { color: var(--green); }

.reply-box { margin-top: .55rem; }
.reply-actions { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; }
.reply-actions .spacer { flex: 1; }

/* ---------- Modal ---------- */
.modal { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; max-width: 440px; width: calc(100% - 2rem); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(20, 22, 28, .42); }
.modal-body { padding: 1.3rem 1.3rem 1.2rem; margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: .4rem; }

/* ---------- Lightbox ---------- */
.lightbox { border: none; background: transparent; padding: 0; max-width: 96vw; max-height: 96vh; overflow: visible; }
.lightbox::backdrop { background: rgba(12, 14, 18, .82); }
.lightbox img { display: block; max-width: 92vw; max-height: 90vh; border-radius: var(--radius); }
.lightbox-close { position: absolute; top: -14px; right: -14px; background: var(--surface); border: 1px solid var(--border-2); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: max-content; max-width: 92vw; }
.toast { display: flex; align-items: center; gap: .5rem; padding: .65rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500; background: var(--text); color: #fff; border: 1px solid rgba(255,255,255,.08); }
.toast .material-symbols-outlined { font-size: 18px; }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--accent); }

/* ---------- Animations ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.comment { animation: pop .16s ease both; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; display: inline-flex; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
    body { font-size: 14.5px; }
    h1 { font-size: 1.32rem; }
    .page { padding: 1rem; }
    .user-name { display: none; }
    .page-head .btn, .project-header-actions .btn { flex: 1 1 auto; }
    .comment-date { width: 100%; margin: .1rem 0 0; order: 5; }
    .comment-children { padding-left: 10px; }
    .filter-tabs { width: 100%; }
    .filter-tab { flex: 1; text-align: center; }
}
