/* 過去データ閲覧システム。手書きの CSS 1 枚（CSP のため style 属性・data: 画像は使わない） */

:root {
    --ink: #1f2933;
    --muted: #5b6573;
    --line: #e2e8f0;
    --bg: #f5f7fa;
    --surface: #fff;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --head: #1e293b;
    --radius: 8px;
}

/* ===== 土台 ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink);
    background: var(--bg);
    overflow-wrap: anywhere;
}
main { max-width: 72rem; margin: 0 auto; padding: 1rem 1.25rem 2.5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.4; }
h1 { font-size: 1.4rem; margin: .25rem 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
mark { background: #fde68a; color: inherit; padding: 0 .1em; }
.muted, .meta { color: var(--muted); font-size: .9rem; }
.key { color: var(--muted); font-weight: normal; font-size: .85em; margin-left: .5rem; }
.error-message { color: #b42318; }

/* 本文: TextFormatter は <br> を出さないので、改行は pre-wrap で見せる */
.body, .snippet { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ===== 部品 ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.button, .button-plain {
    display: inline-block;
    font: inherit;
    font-size: .9rem;
    line-height: 1.5;
    padding: .35rem .9rem;
    border-radius: 6px;
    border: 1px solid var(--accent);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.button { background: var(--accent); color: #fff; }
.button:hover { background: var(--accent-dark); text-decoration: none; }
.button-plain { background: var(--surface); color: var(--ink); border-color: #cbd5e1; }
.button-plain:hover { background: var(--bg); text-decoration: none; }
.field {
    font: inherit;
    font-size: .9rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: .3rem .5rem;
    max-width: 100%;
}
.pill {
    display: inline-block;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.6;
    padding: 0 .55rem;
    border-radius: 999px;
    white-space: nowrap;
}
.pill-open { background: #fdecec; color: #b42318; }
.pill-doing { background: #e6efff; color: #1d4ed8; }
.pill-done { background: #e3f6ee; color: #067647; }
.pill-closed, .pill-other { background: #eef1f4; color: #5b6573; }
.tag {
    display: inline-block;
    font-size: .75rem;
    line-height: 1.6;
    padding: 0 .4rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    background: var(--surface);
    white-space: nowrap;
}
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
    text-align: left;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    background: #f8fafc;
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f1f5ff; }

/* スマホだけ開閉する部分（チェックボックスと CSS。640px 以上では常に開く） */
.toggle-input, .toggle-label { display: none; }

/* ===== ヘッダー ===== */
.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    padding: .55rem 1.25rem;
    background: var(--head);
    color: #e2e8f0;
}
.site-header a { color: #e2e8f0; }
.site-header .brand { font-weight: 700; color: #fff; text-decoration: none; }
.header-search { display: flex; gap: .4rem; flex: 0 1 24rem; }
.header-search .field { flex: 1; min-width: 0; background: #334155; border-color: #475569; color: #fff; }
.header-search .field::placeholder { color: #cbd5e1; }
.header-search .button { background: #334155; border-color: #475569; }
.user-menu { display: flex; align-items: center; gap: .9rem; margin-left: auto; font-size: .9rem; }
.user-menu form { margin: 0; }
.user-menu .button-plain { background: transparent; color: #e2e8f0; border-color: #475569; font-size: .8rem; padding: .15rem .6rem; }
.user-menu .who { color: #cbd5e1; }

/* ===== 見出し・パンくず・タブ ===== */
.crumbs { font-size: .8rem; color: var(--muted); margin: .25rem 0; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 .35em; }
.page-title { margin: .1rem 0 .6rem; }
.tabs {
    display: flex;
    gap: .25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1rem;
    overflow-x: auto;
    white-space: nowrap;
}
.tabs a { padding: .4rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.tabs .count {
    font-size: .7rem;
    font-weight: normal;
    background: var(--line);
    color: #475569;
    border-radius: 999px;
    padding: 0 .45rem;
    margin-left: .35rem;
}

/* ===== ページ送り ===== */
.pager { display: flex; justify-content: center; align-items: center; gap: .5rem; margin: 1.25rem 0; font-size: .9rem; }
.pager a, .pager-off { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: .2rem .8rem; }
.pager-off { color: #94a3b8; }
.pager-now { color: var(--muted); padding: 0 .4rem; }

/* ===== ログイン・エラー ===== */
.center-card { max-width: 28rem; margin: 3rem auto; padding: 1.5rem 1.75rem; text-align: center; }
.center-card h1 { font-size: 1.2rem; }
.error-code { font-size: 2.5rem; font-weight: 700; color: var(--muted); margin: 0; }

/* ===== 課題の一覧 ===== */
.filters {
    display: grid;
    grid-template-columns: minmax(8rem, 2fr) repeat(3, minmax(5.5rem, 1fr)) auto;
    gap: .6rem .75rem;
    align-items: end;
    padding: .9rem 1rem;
    margin-bottom: .75rem;
}
.filters label { display: flex; flex-direction: column; gap: .15rem; font-size: .75rem; color: var(--muted); min-width: 0; }
.filters-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem 1.5rem; font-size: .85rem; }
.filters-more summary { cursor: pointer; color: var(--muted); }
.filters-more-body { display: flex; flex-wrap: wrap; gap: .6rem .75rem; margin-top: .5rem; }
.filters-more-body label { min-width: 10rem; }
.clear { white-space: nowrap; }
.count-line { color: var(--muted); font-size: .85rem; margin: .5rem .1rem; }
.table-wrap { overflow-x: auto; }
.issue-table .col-key { white-space: nowrap; }
.issue-table .col-key a { color: var(--muted); }
.issue-table .col-summary { min-width: 14rem; }
.issue-table .col-summary a { color: var(--ink); font-weight: 600; }
.issue-table .col-meta { white-space: nowrap; }
.issue-table .empty { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ===== 詳細（課題・Wiki・ドキュメント） ===== */
.title-key { color: var(--muted); font-weight: normal; font-size: .85em; margin-right: .5rem; }
.detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; color: var(--muted); font-size: .85rem; margin: -.25rem 0 1rem; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; grid-template-areas: "main side"; gap: 1rem; align-items: start; }
.detail-main { grid-area: main; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.detail-side { grid-area: side; min-width: 0; }
.section { padding: 1rem 1.15rem; }
.section + .section { border-top: 1px solid var(--line); }
.section-title { font-size: .85rem; color: var(--muted); margin: 0 0 .6rem; }
.props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem .9rem; margin: 0; padding: .9rem 1rem; font-size: .9rem; }
.props dt { color: var(--muted); font-size: .8rem; padding-top: .1rem; }
.props dd { margin: 0; }
.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem; font-size: .85rem; }
.attachment-list .image { display: flex; flex-direction: column; gap: .25rem; max-width: 10rem; }
.attachment-list .file { border: 1px solid var(--line); border-radius: 6px; padding: .2rem .6rem; align-self: flex-start; }
.attachment-list .file-missing { color: var(--muted); }
.thumb { display: block; max-width: 10rem; max-height: 8rem; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; }
.comments { padding: 1rem 0 0; }
.comments .section-title { padding: 0 1.15rem; }
.comment { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: .7rem; padding: .85rem 1.15rem; border-top: 1px solid var(--line); }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: #cbd5e1; color: #334155; font-size: .8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.comment-meta { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.comment-meta b { color: var(--ink); margin-right: .4rem; }
.change { font-size: .8rem; color: var(--muted); background: #f8fafc; border-left: 3px solid #cbd5e1; padding: .1rem .6rem; margin: .25rem 0; }
.comment-none { color: var(--muted); padding: 0 1.15rem 1rem; margin: 0; }

/* ===== Wiki・ドキュメント・共有ファイル ===== */
.tree-card { padding: .4rem 0; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 1.6rem; border-left: 1px solid var(--line); }
.tree-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1rem; padding: .3rem 1rem; }
.tree-row:hover { background: #f1f5ff; }
.tree-row .meta { font-size: .8rem; white-space: nowrap; }
.tree-folder { color: var(--muted); font-weight: 600; }
/* フォルダの印は枠線で描く（data: 画像は CSP で読めない） */
.tree-folder::before, .folder::before {
    content: "";
    display: inline-block;
    width: .95em;
    height: .72em;
    margin-right: .45em;
    border: 1.5px solid currentColor;
    border-top-width: 3px;
    border-radius: 2px;
    vertical-align: -.05em;
    opacity: .6;
}
.folder { font-weight: 600; }
.version-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.version-list li { display: flex; flex-wrap: wrap; gap: 0 1rem; padding: .25rem 0; }
.files-table .col-meta { white-space: nowrap; color: var(--muted); }
.files-table .col-action { white-space: nowrap; text-align: right; }
.files-table .empty { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ===== トップ ===== */
.project-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .9rem; }
.project-card { padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.project-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.project-name { font-weight: 700; font-size: 1.05rem; }
.key-line { color: var(--muted); font-size: .8rem; }
.counts { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .85rem; color: var(--muted); }

/* ===== 検索 ===== */
.search-form { display: flex; flex-wrap: wrap; gap: .5rem; padding: .9rem 1rem; margin-bottom: .75rem; }
.search-form .search-q { flex: 1 1 16rem; min-width: 0; }
.search-form select { flex: 0 1 auto; min-width: 0; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.result { padding: .75rem 1rem; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; font-size: .8rem; }
.result-date { margin-left: auto; font-size: .8rem; }
.result-title { display: block; font-weight: 600; margin: .2rem 0; }
.snippet { color: #3e4752; font-size: .9rem; }
.empty-card { color: var(--muted); text-align: center; padding: 1.5rem; }

/* ===== 管理 ===== */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: 1.5rem 0 .5rem; }
.section-head h2 { margin: 0; }
.props + .section { border-top: 1px solid var(--line); }
.flash { padding: .6rem 1rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.flash.error-message { border-color: #b42318; }
.admin-form { display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; padding: 1rem 1.15rem; max-width: 48rem; }
.admin-form .form-row { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); width: 100%; max-width: 28rem; }
.admin-form .error-message { margin: -.5rem 0 0; font-size: .85rem; }
.check { display: flex; align-items: center; gap: .45rem; }
.checks { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .9rem .75rem; margin: 0; width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .3rem 1rem; }
.checks legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.warnings { margin: 0; padding-left: 1.2rem; font-size: .85rem; }

/* ===== スマホ ===== */
@media (max-width: 639px) {
    main { padding: .75rem .9rem 2rem; }
    .site-header { padding: .5rem .9rem; }
    .header-search { order: 3; flex-basis: 100%; }
    .user-menu .who { display: none; }
    h1 { font-size: 1.2rem; }
    .toggle-label {
        display: flex;
        align-items: baseline;
        gap: .35em;
        cursor: pointer;
        color: var(--accent);
        padding: .5rem .75rem;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }
    .toggle-label::before { content: "▸"; }
    .toggle-input:checked + .toggle-label::before { content: "▾"; }
    .toggle-label .muted { margin-left: auto; }
    .toggle-input { display: block; position: absolute; opacity: 0; width: 1px; height: 1px; }
    .toggle-input:focus-visible + .toggle-label { outline: 2px solid var(--accent); outline-offset: 2px; }
    .toggle-input:not(:checked) ~ .toggle-body { display: none; }

    .filters { grid-template-columns: 1fr 1fr; margin-top: .5rem; }
    .filters .filter-q, .filters .button, .filters-foot { grid-column: 1 / -1; }
    .filters-more-body label { min-width: 0; flex: 1 1 9rem; }
    .issue-table thead, .files-table thead { display: none; }
    .issue-table, .issue-table tbody, .files-table, .files-table tbody { display: block; }
    .issue-table tr, .files-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .6rem; padding: .65rem .8rem; border-bottom: 1px solid var(--line); }
    .issue-table tr:last-child, .files-table tr:last-child { border-bottom: none; }
    .issue-table td, .files-table td { display: block; padding: 0; border: none; background: none; }
    .table.issue-table tbody tr:hover td, .table.files-table tbody tr:hover td { background: none; }
    .issue-table .col-key { order: 1; flex: 1; font-size: .8rem; }
    .issue-table .col-status { order: 2; }
    .issue-table .col-summary { order: 3; flex-basis: 100%; min-width: 0; }
    .issue-table .col-meta { order: 4; font-size: .8rem; color: var(--muted); white-space: normal; }
    .issue-table .col-meta::before { content: attr(data-label) " "; }
    .issue-table .col-meta:empty { display: none; }
    .issue-table .empty { flex-basis: 100%; }

    .files-table .col-name { flex-basis: 100%; }
    .files-table .col-meta { font-size: .8rem; }
    .files-table .col-action { margin-left: auto; font-size: .85rem; }
    .files-table .empty { flex-basis: 100%; }
    .tree .tree { margin-left: .9rem; }
    .tree-row { padding: .3rem .8rem; }

    .detail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "main"; }
    .props { margin-top: .5rem; }
    .section { padding: .85rem .9rem; }
    .comment { padding: .75rem .9rem; }
}
