/* tk Web UI */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --border: #dfe3e8;
    --text: #1d2330;
    --muted: #677085;
    --board-column: #e3e2e2;
    --primary: #2563eb;
    --primary-text: #ffffff;
    --primary-soft: #e6eeff;
    --danger: #d23b3b;
    --danger-soft: #fdecec;
    --warn: #b7791f;
    --warn-soft: #fff5e1;
    --ok: #1f8a4c;
    --ok-soft: #e5f6ec;
    --agent-soft: #f0ebff;
    --agent: #6b46c1;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
    --radius: 8px;
    --font: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, monospace;

    --st-backlog: #8a94a6;
    --st-todo: #2f80ed;
    --st-in_progress: #7c3aed;
    --st-waiting_user: #d97706;
    --st-blocked: #dc2626;
    --st-review: #0891b2;
    --st-awaiting_deploy: #059669;
    --st-done: #4b5563;
    --st-rejected: #9ca3af;
    --st-cancelled: #9ca3af;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1a1e26;
        --surface-2: #222733;
        --border: #2e3442;
        --text: #e4e7ee;
        --muted: #949cb0;
        --board-column: #222733;
        --primary: #5b8cff;
        --primary-text: #0b1020;
        --primary-soft: #1f2a46;
        --danger: #f07070;
        --danger-soft: #3a1f22;
        --warn: #f0b252;
        --warn-soft: #3a2f1a;
        --ok: #4cc386;
        --ok-soft: #173126;
        --agent-soft: #2a2342;
        --agent: #b49cf5;
        --shadow: 0 1px 2px rgb(0 0 0 / 40%);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
code, pre { font-family: var(--mono); font-size: .9em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.empty { color: var(--muted); padding: .5rem 0; }

/* ヘッダー */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: .5rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.env-label { background: var(--warn); color: #fff; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.brand-mark {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px; border-radius: 7px;
    background: var(--primary); color: #fff; font-size: .85rem; font-weight: 800;
}
.brand-large { font-size: 1.3rem; justify-content: center; margin-bottom: 1rem; }
.topnav { display: flex; gap: .25rem; }
.topnav a { padding: .35rem .7rem; border-radius: 6px; color: var(--muted); }
.topnav a.active, .topnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.project-switcher select { min-width: 220px; }
.topbar-user { order: 2; display: flex; align-items: center; gap: .6rem; }
.topbar-user form { margin: 0; }
.user-name { font-weight: 600; }

/* メニュー: PC 幅では topbar-menu の中身を上部バーに並べ、スマホ幅では左のサイドパネルにする（PYTICKET-8） */
.topbar-menu { display: contents; }
.topbar > .bell { order: 1; margin-left: auto; }
.menu-button, .menu-head, .menu-backdrop { display: none; }
.menu-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer; }
@media (max-width: 760px) {
    .topbar { gap: .6rem; padding: .5rem .8rem; }
    .menu-button { display: inline-grid; place-items: center; flex: none; }
    .menu-backdrop { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 59; }
    .topbar-menu {
        display: flex; flex-direction: column; gap: 1rem;
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
        width: min(300px, 85vw); padding: .8rem 1rem 1.2rem; overflow-y: auto;
        background: var(--surface); border-right: 1px solid var(--border); box-shadow: 0 0 30px rgb(0 0 0 / 25%);
        transform: translateX(-105%); visibility: hidden;
        transition: transform .2s ease, visibility 0s linear .2s;
    }
    .topbar-menu.open { transform: none; visibility: visible; transition: transform .2s ease; }
    .menu-head { display: flex; align-items: center; justify-content: space-between; }
    .topbar-menu .topnav { flex-direction: column; gap: .1rem; }
    .topbar-menu .topnav a { padding: .6rem .7rem; }
    .project-switcher select { width: 100%; min-width: 0; }
    .topbar-user { order: 0; flex-direction: column; align-items: flex-start; gap: .4rem; border-top: 1px solid var(--border); padding-top: .8rem; }
}

/* フッター */
.footer { padding: .4rem 1.25rem .8rem; text-align: right; font-size: .75rem; color: var(--muted); }
.footer-version { border: none; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.footer-version:hover { color: var(--primary); text-decoration: underline; }

/* ページ */
.main { padding: 1.25rem; }
.page { max-width: 1100px; margin: 0 auto; }
.page-wide { max-width: none; }
.page-narrow { max-width: 640px; }
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header h1 { margin-right: auto; }

.project-header { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.project-title { display: flex; align-items: baseline; gap: .6rem; }
.project-prefix { font-family: var(--mono); font-weight: 700; color: var(--primary); }
.tabs { display: flex; gap: .2rem; margin-right: auto; }
.tabs a { padding: .4rem .8rem; border-radius: 6px; color: var(--muted); }
.tabs a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--surface-2); }
.project-actions { display: flex; gap: .5rem; align-items: center; }
.project-actions .filter-toggle { display: none; }
.filter-toggle.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
@media (max-width: 760px) {
    .project-header { gap: .8rem; }
    /* 「絞り込み」と「チケット作成」を 1 行に均等に並べ、絞り込み欄は開いたときだけ出す（PYTICKET-11） */
    .project-actions { width: 100%; display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; }
    .project-actions > * { justify-content: center; text-align: center; }
    .project-actions .filter-toggle { display: inline-flex; }
    .filter-panel:not(.open) { display: none; }
    .filter-panel .search { flex: 1 1 100%; min-width: 0; }
    .tabs { width: 100%; overflow-x: auto; margin-right: 0; }
    .tabs a { white-space: nowrap; }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.columns-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.count {
    display: inline-block; min-width: 1.6em; padding: 0 .4em; margin-left: .3em;
    border-radius: 999px; background: var(--surface-2); color: var(--muted);
    font-size: .8rem; text-align: center; font-weight: 600;
}

/* フォーム */
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem .55rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input, .field select { width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin: .6rem 0; }
.check { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.inline-form { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }
.input-short { width: 140px; }
.search { min-width: 260px; }
.toolbar, .filters { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
    padding: .42rem .9rem;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-outline { color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-small { padding: .2rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-button, .link-button {
    border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 .2rem;
}
.link-button { color: var(--primary); font-size: .85rem; }
.icon-button:hover, .link-button:hover { color: var(--primary); text-decoration: underline; }

.alert { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary); }
.alert-close { margin-left: auto; border: none; background: none; color: inherit; font-size: 1.1rem; cursor: pointer; }

/* バッジ */
.badge {
    display: inline-block; padding: 0 .5em; border-radius: 4px;
    font-size: .78rem; font-weight: 600; line-height: 1.7;
    background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.status { color: #fff; }
.status-backlog { background: var(--st-backlog); }
.status-todo { background: var(--st-todo); }
.status-in_progress { background: var(--st-in_progress); }
.status-waiting_user { background: var(--st-waiting_user); }
.status-blocked { background: var(--st-blocked); }
.status-review { background: var(--st-review); }
.status-awaiting_deploy { background: var(--st-awaiting_deploy); }
.status-done { background: var(--st-done); }
.status-rejected, .status-cancelled { background: var(--st-rejected); }
.type-feature { background: var(--primary-soft); color: var(--primary); }
.type-bug { background: var(--danger-soft); color: var(--danger); }
.type-subtask { background: var(--surface-2); color: var(--muted); }
.priority { font-size: .78rem; font-weight: 700; }
.priority-high { color: var(--danger); }
.priority-medium { color: var(--warn); }
.priority-low { color: var(--muted); }
.chip {
    display: inline-block; padding: 0 .45em; margin-right: .25em; border-radius: 999px;
    font-size: .78rem; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.agent-chip {
    display: inline-block; padding: 0 .45em; border-radius: 999px; font-size: .78rem;
    background: var(--agent-soft); color: var(--agent); white-space: nowrap;
}
.ticket-key { font-family: var(--mono); font-weight: 600; white-space: nowrap; }

/* 表 */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-size: .8rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* スマホ幅のチケット一覧: ヘッダーを隠し、各行を 上段（番号・種別・ステータス・優先度）/ 下段（タイトル）の 2 段にする（PYTICKET-10） */
@media (max-width: 760px) {
    .ticket-table, .ticket-table tbody { display: block; }
    .ticket-table thead { display: none; }
    .ticket-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
    .ticket-table tr:last-child { border-bottom: none; }
    .ticket-table td { display: block; padding: 0; border: none; }
    .ticket-table .col-key { font-size: .8rem; }
    .ticket-table .col-priority { margin-left: auto; }
    .ticket-table .col-title { order: 1; flex-basis: 100%; }
    .ticket-table .col-title .ticket-title-link { font-weight: 600; color: var(--text); }
    .ticket-table .col-title .summary-line, .ticket-table .col-title .chip, .ticket-table .col-assignee, .ticket-table .col-updated { display: none; }
}
.summary-line { max-width: 640px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ダッシュボード */
.question-list, .ticket-list-compact, .plain-list, .release-list, .decision-list { list-style: none; margin: 0; padding: 0; }
.question-list li, .ticket-list-compact li { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.question-list li:last-child, .ticket-list-compact li:last-child { border-bottom: none; }
.question-list a { display: flex; gap: .6rem; }
.question-text { color: var(--text); font-weight: 600; }
.plain-list li { padding: .2rem 0; }
.release-list li { padding: .35rem 0; }

/* かんばん */
.board { display: flex; gap: .75rem; overflow-x: auto; align-items: flex-start; padding-bottom: 1rem; }

/* かんばんのページでは列の背景を画面の下端まで伸ばし、高さを揃える（ヘッダー・ツールバーの高さに依存しないよう flex で埋める） */
body:has(.page-board) { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body:has(.page-board) > .main { flex: 1; display: flex; flex-direction: column; }
.page-board { flex: 1; display: flex; flex-direction: column; width: 100%; }
.page-board > .board { flex: 1; align-items: stretch; }
.board-column {
    flex: 1 0 160px;
    max-width: 320px;
    background: var(--board-column);
    border-radius: var(--radius);
    padding: .5rem;
    min-height: 200px;
    border: 2px solid transparent;
}
.board-column.drop-target { border-color: var(--primary); }
/* スマホ幅: 列を画面幅にして縦に並べ、高さはチケットの量に合わせる（PYTICKET-8） */
@media (max-width: 760px) {
    .page-board > .board { flex: none; flex-direction: column; align-items: stretch; overflow-x: visible; }
    .board-column { flex: none; width: 100%; max-width: none; min-height: 0; }
    .drag-hint { display: none; }
}
.board-column-header { display: flex; align-items: center; justify-content: space-between; padding: .2rem .3rem .5rem; }
.board-cards { display: flex; flex-direction: column; gap: .5rem; }
.board-more { display: block; padding: .3rem; text-align: center; font-size: .85rem; color: var(--text); }
.board-more:hover { color: var(--primary); }
.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .55rem .65rem;
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: grab;
}
.card:hover { border-color: var(--primary); text-decoration: none; }
.card-blocked { border-left: 3px solid var(--danger); }
.card-top { display: flex; align-items: center; gap: .4rem; margin-bottom: .2rem; }
.card-top .priority { margin-left: auto; }
.card-title { font-weight: 600; line-height: 1.4; }
.card-summary { font-size: .82rem; color: var(--muted); margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .2rem; }

/* チケット詳細 */
.ticket-header { margin-bottom: 1rem; }
.breadcrumb { color: var(--muted); font-size: .85rem; }
.ticket-topbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.ticket-nav { display: flex; gap: .4rem; margin-left: auto; }
.ticket-title { display: flex; align-items: center; gap: .5rem; margin: .2rem 0 .5rem; }
.title-input { font-size: 1.2rem; flex: 1; }
.inline-edit { display: flex; gap: .4rem; align-items: center; margin: .3rem 0 .6rem; }
.ticket-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 960px) { .ticket-layout { grid-template-columns: 1fr; } }
.ticket-side {
    position: sticky; top: 64px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem 1rem; max-height: calc(100vh - 80px); overflow-y: auto;
}
.fields { margin: 0; }
.fields dt { font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: .8rem; }
.fields dt:first-child { margin-top: 0; }
.fields dd { margin: .2rem 0 0; }
.fields dd input, .fields dd select { width: 100%; }

.status-panel {
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
    border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem;
}
.status-panel-head { display: flex; align-items: center; gap: .5rem; }
.status-panel-head h2 { margin: 0; }
.status-panel-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin-top: .8rem; padding-top: .7rem; border-top: 1px dashed var(--border); }
.stat-label { display: block; font-size: .78rem; font-weight: 700; color: var(--muted); }

.entry {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .7rem .9rem; margin-bottom: .7rem; scroll-margin-top: 80px;
}
.entry-agent { border-left: 3px solid var(--agent); }
.entry-question { border-left: 3px solid var(--warn); }
.entry-decision { border-left: 3px solid var(--ok); background: linear-gradient(var(--ok-soft), var(--ok-soft)) top / 100% 2.4rem no-repeat, var(--surface); }
.entry-answer { border-left: 3px solid var(--primary); }
.entry-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; font-size: .88rem; }
.entry-actor { font-weight: 600; }
.entry-tools { margin-left: auto; display: flex; gap: .3rem; }
.seq { font-family: var(--mono); color: var(--muted); }
.post-question { background: var(--warn-soft); color: var(--warn); }
.post-decision { background: var(--ok-soft); color: var(--ok); }
.post-answer { background: var(--primary-soft); color: var(--primary); }
.post-worklog, .post-progress { background: var(--agent-soft); color: var(--agent); }
.post-review { background: var(--surface-2); }
.entry-event {
    display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap;
    padding: .15rem .6rem; margin: 0 0 .5rem .6rem;
    border-left: 2px solid var(--border); color: var(--muted); font-size: .82rem; scroll-margin-top: 80px;
}
.unread-divider { display: flex; align-items: center; gap: .6rem; color: var(--danger); font-size: .8rem; font-weight: 700; margin: .8rem 0; scroll-margin-top: 120px; }
.unread-divider::before, .unread-divider::after { content: ""; flex: 1; border-top: 1px solid var(--danger); }
.thread-filter { display: flex; gap: .3rem; align-items: center; margin: 1.2rem 0 .7rem; flex-wrap: wrap; font-size: .85rem; }
.thread-filter button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: .1rem .7rem; cursor: pointer; font: inherit; }
.thread-filter button.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.thread-filter .check { margin-left: .5rem; }
.criteria { margin-top: .9rem; padding-top: .7rem; border-top: 1px dashed var(--border); }
.criteria ul { list-style: none; padding: 0; margin: 0; }
.criteria li { display: flex; align-items: center; gap: .4rem; padding: .15rem 0; }
.criteria li.checked label { color: var(--muted); text-decoration: line-through; }
.criteria label { display: flex; gap: .4rem; align-items: center; cursor: pointer; }
.question-options { margin: .3rem 0; padding-left: 1.6rem; }
.answer-summary { margin-top: .5rem; padding: .35rem .6rem; border-radius: 6px; background: var(--ok-soft); font-size: .88rem; }
.worklog-meta { margin-top: .4rem; font-size: .85rem; }
.test-passed { color: var(--ok); }
.test-failed { color: var(--danger); }
.attachments { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.attachment { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: .2rem .5rem; background: var(--surface-2); }
.attachment img { max-width: 240px; max-height: 160px; display: block; border-radius: 4px; }

.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; margin-top: 1rem; scroll-margin-top: 80px; }
.composer-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.options { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .5rem; }

/* Markdown */
.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: .4rem 0; }
.markdown pre { background: var(--surface-2); padding: .7rem .9rem; border-radius: 6px; overflow-x: auto; }
.markdown pre code.hljs { background: transparent; padding: 0; }
.markdown :not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.markdown blockquote { margin: .5rem 0; padding: .1rem .9rem; border-left: 3px solid var(--border); color: var(--muted); }
.markdown table { border-collapse: collapse; margin: .5rem 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: .3rem .6rem; }
.markdown img { max-width: 100%; border-radius: 4px; border: 1px solid var(--border); cursor: zoom-in; }
.markdown ul.contains-task-list { list-style: none; padding-left: 1rem; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: .9rem 0 .4rem; }
.markdown h1 { font-size: 1.25rem; }
.markdown h2 { font-size: 1.12rem; }
.markdown h3 { font-size: 1rem; }
.tk-mention { color: var(--agent); font-weight: 600; }

/* ドキュメント */
.docs-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: 0 0 .8rem; }
.docs-empty { padding: 1rem 0; }
.docs-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1rem; align-items: start; }
.docs-list { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; padding: .6rem; display: flex; flex-direction: column; gap: .1rem; }
.docs-folder { color: var(--muted); font-size: .78rem; font-weight: 600; padding: .5rem .5rem .1rem; overflow-wrap: anywhere; }
.docs-folder:empty { display: none; }
.docs-item { padding: .3rem .5rem; border-radius: 6px; color: var(--text); overflow-wrap: anywhere; font-size: .9rem; }
.docs-item.nested { padding-left: 1.1rem; }
.docs-item:hover { background: var(--surface-2); text-decoration: none; }
.docs-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.docs-preview { min-width: 0; }
.docs-preview-header { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: .5rem; margin-bottom: .8rem; }
.docs-preview-header h2 { margin: 0; font-size: 1rem; font-family: var(--mono); overflow-wrap: anywhere; }
.docs-body { line-height: 1.75; }
.docs-body h1 { font-size: 1.5rem; }
.docs-body h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: .2rem; margin-top: 1.6rem; }
.docs-body h3 { font-size: 1.08rem; margin-top: 1.2rem; }
.docs-body h1, .docs-body h2, .docs-body h3, .docs-body h4 { scroll-margin-top: 1rem; }
.docs-body table { display: block; max-width: 100%; overflow-x: auto; }
.docs-body td, .docs-body th { overflow-wrap: normal; }
@media (max-width: 800px) {
    .docs-layout { grid-template-columns: 1fr; }
    .docs-list { position: static; max-height: 40vh; }
}
.tk-ticket-link { font-family: var(--mono); font-weight: 600; }

/* 入力欄 */
.editor { border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.editor:focus-within { border-color: var(--primary); }
.editor-dragging { outline: 2px dashed var(--primary); }
.editor textarea { border: none; border-radius: 0 0 6px 6px; outline: none; min-height: 6rem; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding: .2rem .4rem; background: var(--surface-2); border-radius: 6px 6px 0 0; flex-wrap: wrap; }
.editor-tabs button, .editor-buttons button, .editor-attach {
    border: none; background: none; cursor: pointer; font: inherit; color: var(--muted); padding: .2rem .5rem; border-radius: 4px;
}
.editor-tabs button.active { background: var(--surface); color: var(--text); font-weight: 600; }
.editor-buttons { display: flex; gap: .1rem; }
.editor-buttons button:hover, .editor-attach:hover { background: var(--surface); color: var(--text); }
.editor-preview { padding: .6rem .7rem; min-height: 6rem; }
.editor-hint { font-size: .78rem; color: var(--muted); padding: .2rem .6rem .4rem; }
.upload-list { list-style: none; margin: 0; padding: .3rem .6rem; font-size: .85rem; border-top: 1px solid var(--border); }
.upload-error { color: var(--danger); }

/* ダイアログ */
.dialog-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 40%); display: grid; place-items: center; z-index: 50; }
.dialog { background: var(--surface); border-radius: 10px; padding: 1.2rem 1.3rem; width: min(520px, 92vw); box-shadow: 0 20px 50px rgb(0 0 0 / 30%); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }
.dialog-wide { width: min(820px, 94vw); }
.changelog-dialog { display: flex; flex-direction: column; max-height: 88vh; text-align: left; font-size: .95rem; color: var(--text); }
.changelog-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.changelog-head h2 { margin: 0; font-size: 1.1rem; }
.changelog-body { overflow-y: auto; padding: .6rem .2rem 0; min-height: 0; }

.danger-zone { border-color: var(--danger-soft); }
.deploy-form { border-left: 4px solid var(--st-awaiting_deploy); }

/* ログイン */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.8rem; box-shadow: var(--shadow); }

.error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: .7rem 1.2rem; background: var(--danger-soft); color: var(--danger); z-index: 100; }
.error-ui .reload { margin-left: .5rem; }

/* 通知 */
.bell { position: relative; font-size: 1.1rem; padding: .1rem .3rem; border-radius: 6px; }
.bell:hover { background: var(--surface-2); text-decoration: none; }
.bell-count {
    position: absolute; top: -4px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px;
    border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}
.user-name { color: var(--text); }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: .25rem; vertical-align: middle; }
.notification-list { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.notification-list li { border-bottom: 1px solid var(--border); }
.notification-list li:last-child { border-bottom: none; }
.notification-list li.unread { background: var(--primary-soft); }
.notification {
    display: flex; gap: .8rem; align-items: flex-start; width: 100%; padding: .7rem .9rem;
    border: none; background: none; text-align: left; font: inherit; color: var(--text); cursor: pointer;
}
.notification-body { flex: 1; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.notification-ticket { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-kind { flex: 0 0 auto; font-size: .75rem; font-weight: 700; padding: .05rem .5rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.kind-question { background: var(--warn-soft); color: var(--warn); }
.kind-review { background: var(--primary-soft); color: var(--primary); }
.kind-mention { background: var(--agent-soft); color: var(--agent); }
.kind-unblocked { background: var(--ok-soft); color: var(--ok); }

/* メンションの候補 */
.mention-popup {
    position: fixed; z-index: 60; min-width: 180px; max-height: 220px; overflow-y: auto;
    margin: 0; padding: .25rem 0; list-style: none; background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}
.mention-popup li { padding: .25rem .8rem; cursor: pointer; font-weight: 600; }
.mention-popup li.active, .mention-popup li:hover { background: var(--primary-soft); color: var(--primary); }

.plain-fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.plain-fieldset:disabled { opacity: .75; }
.token-plain { display: block; padding: .6rem .8rem; margin: .4rem 0; border-radius: 6px; background: var(--ok-soft); font-family: var(--mono); word-break: break-all; }
.criteria.plain-fieldset { margin-top: .9rem; padding-top: .7rem; }
