:root {
    color-scheme: light;
    font-family: "Noto Sans CJK JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
    color: #19333f;
    background: #f2f5f6;
    --sidebar: #102a3b;
    --sidebar-active: #1b4051;
    --ink: #19333f;
    --muted: #536a75;
    --line: #e1e8ea;
    --white: #fff;
    --teal: #13756d;
    --teal-dark: #0b5e56;
    --pale: #e8f4f1;
    --canvas: #f2f5f6;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; line-height: 1.6; }
button, input, textarea, select { font: inherit; }
a { color: var(--teal-dark); }
h1, h2, p, ul, dl, dd { margin: 0; }
h1 { font-size: clamp(1.52rem, 3vw, 1.95rem); line-height: 1.35; overflow-wrap: anywhere; }
h2 { font-size: 1.06rem; line-height: 1.4; }
:focus-visible { outline: 3px solid #318f87; outline-offset: 3px; }

.workspace {
    --sidebar-width: 238px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    background: linear-gradient(to right, var(--sidebar) var(--sidebar-width), var(--canvas) var(--sidebar-width));
}
.sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: start;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    background: var(--sidebar);
    color: #eef8fb;
    padding: 30px 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    font-weight: 750;
    font-size: 1.08rem;
    text-decoration: none;
    line-height: 1.3;
}
.sidebar .brand { margin: 0 10px 30px; }
.brand small { display: block; font-size: 1rem; }
.brand-mark {
    flex: none;
    width: 35px;
    height: 35px;
    border: 2px solid currentColor;
    border-radius: 8px;
    position: relative;
    color: #75ccca;
}
.brand-mark::before, .brand-mark::after {
    content: "";
    position: absolute;
    inset: 8px 4px;
    border-block: 2px solid currentColor;
}
.brand-mark::after { inset: 4px 8px; border: 0; border-inline: 2px solid currentColor; }
.brand-dark { color: var(--sidebar); }
.brand-dark .brand-mark { color: var(--teal); }
.side-menu { display: grid; gap: 5px; }
.nav-item {
    position: relative;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    border-radius: 8px;
    color: #bcd1dc;
    font-size: .92rem;
    font-weight: 700;
    text-decoration: none;
}
.nav-item.is-active, .nav-item:hover { background: var(--sidebar-active); color: var(--white); }
.nav-item.is-active::before {
    content: "";
    position: absolute;
    inset: 9px auto 9px 0;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: #66c6bd;
}
.nav-icon { flex: none; display: inline-block; width: 16px; height: 16px; position: relative; }
.nav-grid::before {
    content: "";
    position: absolute;
    width: 7px;
    height: 7px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    box-shadow: 8px 0 0 -1px var(--icon-fill, var(--sidebar-active)), 8px 0 currentColor,
        0 8px 0 -1px var(--icon-fill, var(--sidebar-active)), 0 8px currentColor,
        8px 8px 0 -1px var(--icon-fill, var(--sidebar-active)), 8px 8px currentColor;
}
.nav-item:not(.is-active):not(:hover) .nav-grid { --icon-fill: var(--sidebar); }
.nav-folder::before, .nav-photo::before, .nav-paper::before {
    content: "";
    position: absolute;
    inset: 4px 0 1px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
}
.nav-folder::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 1px;
    width: 7px;
    height: 3px;
    border: 1.5px solid currentColor;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
}
.nav-paper::before { inset: 0 2px; }
.nav-paper::after {
    content: "";
    position: absolute;
    inset: 5px 5px 5px;
    border-block: 1px solid currentColor;
}
.nav-photo::before { inset: 1px 0; }
.nav-photo::after {
    content: "";
    position: absolute;
    left: 5px;
    bottom: 3px;
    width: 6px;
    height: 6px;
    border: 1.5px solid currentColor;
    border-right: 0;
    border-bottom: 0;
    transform: rotate(45deg);
}

.topbar {
    grid-column: 2;
    min-height: 72px;
    min-width: 0;
    padding: 12px clamp(20px, 3vw, 38px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
}
.breadcrumbs { display: flex; align-items: center; gap: 11px; min-width: 0; color: var(--muted); font-size: .85rem; }
.breadcrumbs > :first-child, .separator { flex: none; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--teal-dark); text-decoration: underline; }
.crumb-current, .crumb-project { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-current { color: var(--ink); font-weight: 700; }
.separator { color: #8b9ba3; }
.account-menu { position: relative; flex: none; }
.account-menu summary {
    display: flex;
    align-items: center;
    gap: 9px;
    border-radius: 6px;
    padding: 1px;
    cursor: pointer;
    list-style: none;
    font-size: .83rem;
    font-weight: 700;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--teal-dark);
    background: #e3f3ee;
}
.account-menu form {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 5;
    padding: 8px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 18px #19333f1f;
}

.skip { position: absolute; left: 8px; top: -90px; z-index: 6; padding: 8px 12px; background: var(--white); }
.skip:focus { top: 8px; }
.main {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    max-width: 1520px;
    margin-inline: auto;
    padding: 30px clamp(20px, 3vw, 38px) 45px;
}
.page-heading { display: flex; gap: 12px 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 24px; }
.page-heading > div { min-width: 0; }
.page-heading p { color: var(--muted); margin-top: 6px; font-size: .94rem; overflow-wrap: anywhere; }
.page-heading .project-type { color: var(--teal-dark); margin: 0 0 4px; font-size: .83rem; font-weight: 700; }
.surface { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 6px #19333f08; }
.section-head { min-height: 61px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.section-head p { margin-top: 2px; color: var(--muted); font-size: .82rem; }
.card-body { padding: 18px 22px; }
.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: .89rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.primary { background: var(--teal); color: var(--white); }
.primary:hover { background: var(--teal-dark); }
.secondary { color: var(--ink); background: var(--white); border-color: #cad8dc; }
.secondary:hover { background: #f1f8f6; border-color: #b1c9c5; }
.full { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.text-link { text-decoration: none; font-size: .9rem; }
.text-link:hover { text-decoration: underline; }

.notice { margin-bottom: 16px; padding: 12px 15px; border-radius: 9px; overflow-wrap: anywhere; }
.notice-error { background: #fff0eb; color: #782e19; border: 1px solid #e8b3a6; }
.notice-success { background: var(--pale); color: #15584c; border: 1px solid #b5d8cc; }
.rows { list-style: none; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.project-row, .project-columns, .document-row { display: grid; align-items: center; gap: 12px; padding-inline: 22px; }
.project-row, .project-columns { grid-template-columns: minmax(0, 1fr) minmax(100px, .32fr) 145px 12px; }
.project-row, .document-row { min-height: 72px; padding-block: 13px; color: var(--ink); text-decoration: none; }
.project-row:hover, .document-row:hover { background: #f3f9f7; }
.rows li:last-child > a { border-radius: 0 0 12px 12px; }
.project-columns { min-height: 41px; color: var(--muted); background: #f5f8f9; border-bottom: 1px solid var(--line); font-size: .79rem; font-weight: 700; }
.document-row { grid-template-columns: 40px minmax(0, 1fr) 12px; }
.record-main { min-width: 0; overflow-wrap: anywhere; }
.record-main strong { display: block; }
.record-main small, .row-date { color: var(--muted); font-size: .83rem; }
.arrow { color: var(--teal-dark); font-size: 1.42rem; line-height: 1; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 100px; font-size: .76rem; font-weight: 700; color: #4c626a; background: #edf2f3; white-space: nowrap; }
.badge.is-ready { color: var(--teal-dark); background: var(--pale); }
.file-kind, .empty-icon { display: grid; place-items: center; border-radius: 9px; color: var(--teal); background: var(--pale); }
.file-kind { width: 38px; height: 38px; }
.empty { display: grid; justify-items: center; gap: 4px; padding-inline: 16px; text-align: center; color: var(--muted); }
.project-empty { padding-block: clamp(40px, 8vw, 86px); }
.document-empty { padding-block: 50px; }
.empty strong { color: var(--ink); }
.empty p { font-size: .88rem; }
.empty-icon { width: 45px; height: 45px; margin-bottom: 8px; }
.empty-icon .nav-icon { transform: scale(1.13); }
.search { display: flex; align-items: center; gap: 9px; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.search-field { position: relative; flex: 1 1 160px; max-width: 380px; }
.search-field input { padding-left: 35px; margin: 0; }
.search-icon { position: absolute; top: 13px; left: 12px; width: 12px; height: 12px; border: 1.5px solid #5b7782; border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; left: 8px; top: 9px; width: 6px; height: 1.5px; background: #5b7782; transform: rotate(45deg); }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; padding: 12px; border-top: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

.form-card { max-width: 760px; padding: clamp(16px, 3vw, 26px); }
.stack { display: grid; gap: 14px; }
label { min-width: 0; font-size: .89rem; font-weight: 700; }
label > input, label > select, label > textarea { margin-top: 5px; }
input, select, textarea { min-width: 0; min-height: 42px; width: 100%; border: 1px solid #c1d0d5; border-radius: 7px; padding: 8px 10px; color: var(--ink); background: var(--white); }
textarea { display: block; resize: vertical; }
input[type="file"] { padding: 6px; font-size: .84rem; }
input::file-selector-button { color: #1b514c; background: #edf6f3; border: 1px solid #c5ded8; border-radius: 5px; padding: 4px 7px; margin-right: 6px; cursor: pointer; }
.required { padding: 1px 6px; margin-left: 4px; border-radius: 4px; font-size: .75rem; color: #793a2d; background: #fbeee9; }
.hint, .optional { color: var(--muted); font-size: .79rem; }
.hint { margin-top: -7px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.58fr) minmax(255px, 1fr); gap: 20px; align-items: start; }
.side-cards { display: grid; gap: 18px; min-width: 0; }
#documents, #add-document { scroll-margin-top: 15px; }
#add-document:target { outline: 2px solid #72b7af; outline-offset: 3px; }
.document-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 15px; }
.document-metrics > div { padding: 9px 10px; border-radius: 8px; border: 1px solid #e2ecee; background: #f3f8f8; }
.document-metrics dt { color: var(--muted); font-size: .77rem; line-height: 1.4; }
.document-metrics dd { color: #224d59; font-size: 1.23rem; font-weight: 750; line-height: 1.4; }
.document-metrics dd span { color: var(--muted); font-size: .77rem; font-weight: 500; }
.metadata { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px 14px; }
.metadata dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metadata dd { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .89rem; }
.versions, .replace { border-top: 1px solid var(--line); }
.versions summary, .replace summary { padding-block: 12px; cursor: pointer; color: var(--teal-dark); font-weight: 700; font-size: .85rem; }
.versions summary { padding-inline: 22px; }
.replace { margin-top: 14px; }
.preview-body { padding: 12px; background: #f7fafb; border-radius: 0 0 12px 12px; }
.pdf-frame { display: block; width: 100%; height: clamp(430px, 70vh, 900px); border: 1px solid var(--line); border-radius: 7px; background: #edf3f4; }
.image-link, .image-link img { display: block; max-width: 100%; margin: auto; }
.image-link img { height: auto; border-radius: 7px; }

.public-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(145deg, #dfece9, #f5f8f9 68%); }
.login-main { width: min(100%, 450px); padding: 20px; }
.login-card, .error-card { padding: clamp(19px, 5vw, 31px); }
.login-card h1 { margin: 20px 0 15px; font-size: 1.64rem; }
.error-card h1 { font-size: 1.1rem; margin-bottom: 14px; }

@media (max-width: 1080px) {
    .workspace { --sidebar-width: 194px; }
    .detail-grid { grid-template-columns: 1fr; }
    .side-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 820px) {
    .workspace { --sidebar-width: 166px; }
    .sidebar { padding-inline: 11px; }
    .sidebar .brand { margin-inline: 5px; gap: 8px; }
    .brand small { font-size: .89rem; }
    .side-cards { grid-template-columns: 1fr; }
    .project-columns { display: none; }
    .project-row { grid-template-columns: minmax(0, 1fr) auto 12px; gap: 3px 10px; }
    .project-row .row-date { grid-row: 2; grid-column: 1; }
    .project-row .arrow { grid-column: 3; grid-row: 1 / 3; }
}
@media (max-width: 600px) {
    .workspace { display: block; background: var(--canvas); }
    .sidebar { position: static; height: auto; padding: 12px 15px 7px; overflow: visible; }
    .sidebar .brand { margin: 0 0 9px; }
    .sidebar .brand-mark { width: 31px; height: 31px; }
    .side-menu { display: flex; flex-wrap: wrap; gap: 4px 6px; }
    .nav-item { min-height: 38px; gap: 8px; padding: 6px 10px; font-size: .81rem; }
    .nav-item.is-active::before { inset-block: 7px; width: 3px; }
    .topbar { min-height: 53px; padding: 7px 15px; }
    .breadcrumbs { gap: 6px; font-size: .77rem; }
    .account-name { max-width: 73px; font-size: .76rem; }
    .account-avatar { width: 29px; height: 29px; }
    .main { padding: 20px 14px 32px; }
    .page-heading { margin-bottom: 17px; }
    .section-head, .card-body, .search, .project-row, .document-row { padding-inline: 14px; }
    .section-head { padding-block: 13px; }
    .search { gap: 6px; }
    .search-field { flex-basis: 90px; }
    .button { padding-inline: 10px; }
    .detail-grid, .side-cards { gap: 14px; }
    .pdf-frame { height: 58vh; min-height: 330px; }
    input, textarea, select { font-size: 16px; }
}
@media (max-width: 360px) {
    .account-name { display: none; }
    .nav-item { padding-inline: 8px; }
    .card-body { padding-inline: 12px; }
    .document-metrics > div { padding-inline: 6px; }
}
