:root {

    --bg-color: #cfcfcf;
    --primary-bg-color: #3c3c3c;
    --secondary-bg-color: #bcb0a6;
    --tertiary-bg-color: #ffffff;

    --text-color: #373434;
    --primary-text-color: #cfcfcf;
    --secondary-text-color: #393535;
    --tertiary-text-color: #373434;

    --public-accent-color: #cf446a;

    --font: 'Noto Sans JP';
    --bg-pattern-url: url('https://www.transparenttextures.com/patterns/batthern.png');
}

body {
    color: var(--text-color);
    font-family: var(--font), sans-serif;

    background-color: var(--bg-color);
}

h1 {

    padding: 1em 0em;
    font-size: 1.5rem;
    font-weight: 400;
}

/* ボタン制御 */
.button,
button {
    background-color: var(--bg-color);
    border: var(--text-color) solid 0.15rem;
    border-radius: 0.2rem;
    color: var(--text-color);
    padding: 10px;
    font-weight: bold;
}

/* トグルボタン */
.toggle-btn {
    text-align: right;
    display: inline-block;
    position: relative;
    width: 2.5rem;
    height: 1rem;
    border-radius: 1rem;
    border: 0.15rem solid var(--text-color);
    box-sizing: content-box;
    cursor: pointer;
    transition: border-color .4s;
}

.toggle-btn:has(:checked) {
    background-color: rgb(142 232 159);
}

.toggle-btn::after {
    position: absolute;
    top: 50%;
    left: 0.2rem;
    transform: translateY(-50%);
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background-color: var(--text-color);
    content: '';
    transition: left .2s;
}

.toggle-btn:has(:checked)::after {
    left: 1.6rem;
}

.toggle-btn input {
    display: none;
}

/* 汎用トグルメニュー */
.toggle-menu
{
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 5px;
    align-items: center;
    width: fit-content;
    min-width: 400px;
    box-sizing: border-box;
    margin: 0 auto;
    border-radius: 0.8rem;
    border: var(--primary-bg-color) solid 0.15rem;
}

.toggle-menu > a
{
    box-sizing: border-box;
    flex: 1 1 200px;
    width: min(200px, 100%);
    min-width: 0;
    border-radius: 0.5rem;
    padding: 10px;
    font-weight: bold;
    text-align: center;
    color: var(--primary-bg-color);
}

.toggle-menu > div
{
    box-sizing: border-box;
    flex: 1 1 200px;
    width: min(200px, 100%);
    min-width: 0;
    border-radius: 0.5rem;
    padding: 10px;
    font-weight: bold;
    text-align: center;
    background-color: var(--primary-bg-color);
    color: var(--primary-text-color);
}

/* ルーム用ヘッダ */
.room-header
{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 20px;
}

.room-header-left,
.room-header-right
{
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.room-header-left
{
    flex: 1 1 0;
    max-width: 100%;
}

.room-header-right
{
    flex: 0 1 auto;
}

.room-header-breadcrumb
{
    flex: 1 1 auto;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.8em 1.5em;
    border-radius: 2em;
    background-color: var(--primary-bg-color);
    font-weight: bold;
    color: var(--primary-text-color);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.room-header-breadcrumb a,
.room-header-breadcrumb span
{
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-header-breadcrumb a,
.room-header-breadcrumb span:not(.room-header-separator)
{
    display: block;
    flex: 0 1 auto;
    max-width: 180px;
}

.room-header-breadcrumb a:hover,
.room-header-breadcrumb a:active,
.room-header-breadcrumb a:focus
{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-header-breadcrumb a
{
    text-decoration: underline;
}

.room-header-separator
{
    flex: 0 0 auto;
    opacity: 0.7;
}

.room-header-button
{
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.2em;
}
.room-header-button > a,
.room-header-button > button,
.room-sidebar-toggle
{

    font-family: FontAwesome;
    font-weight: bold;
    background-color: var(--primary-bg-color);
    color: var(--primary-text-color);
    border: none;
    border-radius: 50em;
    padding: 0.8rem 0.8rem;
}

.room-sidebar-toggle
{
    flex: 0 0 auto;
}

.room-header-character
{
    min-width: 0;
    max-width: 220px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background-color: var(--primary-bg-color);
    color: var(--primary-text-color);
    font-weight: bold;
}

.room-header-character-icon
{
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: block;
    overflow: hidden;
    border-radius: 50%;
    background-color: var(--tertiary-bg-color);
}

.room-header-character-icon img
{
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.room-header-character-name
{
    min-width: 0;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary-text-color);
}

/*
 * チャット
 */
.chat-cell
{
    width: 100%;
    display: flex;
    gap: 10px;
}
.chat-cell-text
{
    width: 100%;

}

.chat-cell-header
{
    display: flex;
    justify-content: space-between;
    padding: 2px 5px;
}
.chat-cell-name
{
    color: var(--text-color);
    font-weight: bold;
}
.chat-cell-header > .chat-cell-name
{
    min-height: 1.5em;
}
.chat-cell-message
{
    padding: 10px;
    background-color: var(--tertiary-bg-color);
    color: var(--tertiary-text-color);

    min-height: 30px;
    border: solid 1px var(--secondary-bg-color);
    border-radius: 0 8px 8px 8px;
    white-space: pre-wrap;
    filter:
            drop-shadow(1px 2px 2px #00000066);
}

.chat-cell-message ruby {
    ruby-position: over;
}

.chat-cell-message rt {
    font-size: 0.65em;
}

.custom-tag-large {
    font-size: 1.35em;
    font-weight: 700;
}

.custom-tag-small {
    font-size: 0.78em;
}

.chat-cell-time
{
    text-align: right;
    padding: 2px 5px;
}

/*
 * アイコン
 */
.icon-thumbnail
{
    width: 62px;
    height: 62px;
}

.icon-thumbnail-base
{
    width: 62px;
    height: 62px;
    background-color: var(--primary-bg-color);
    border-radius: 5px;
    transform: rotate(-8deg);
}
.icon-thumbnail-base > img{
    width: 60px;
    height: 60px;
    background-color: var(--tertiary-bg-color);
    background-image: var(--bg-pattern-url);

    border: solid 1px var(--primary-bg-color);
    border-radius: 5px;
    transform: rotate(11deg);
}

/*
ポートレート
 */
.character-view
{
    position: relative;
    width: 600px;
    aspect-ratio: 1;
    overflow-x: visible;
    container-type: inline-size;

}

.character-view .layer
{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

}


.character-view-body img{
    object-fit: contain;
    position: relative;
    left: -25cqw;
    width: 100%;
    height: 100%;
    margin: auto auto;
    filter:
            url(#sticker-outline)
            drop-shadow(1px 1px 1px #000);
}

.character-view-frame-outer
{
    padding: 10cqw;
    box-sizing: border-box;

}
.character-view-frame
{
    width: 100%;
    height: 100%;
    background-color: var(--tertiary-bg-color);
    background-image: var(--bg-pattern-url);

    border-radius: 3cqw;
    border: solid 0.3cqw var(--primary-bg-color);
    overflow: hidden;

}
.character-view-frame > img
{
    object-fit: cover;
    width: 100%;
    height: 100%;
    filter:
            drop-shadow(0 0 5px #000);
    will-change: transform;
}

.svg
{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.no
{
    font-size: 0.6rem;
    text-align: center;
    filter:
            drop-shadow(0px 0px 1px var(--primary-bg-color));
}
.name
{
    font-size: 1.8rem;
    letter-spacing: -0.1em;
    text-align: center;
    font-weight: bold;
    filter:
            drop-shadow(0px 0px 1px var(--primary-bg-color));
}
.introduction
{
    margin: 16px;
    font-size: 1.1rem;
    color: var(--secondary-text-color);
    text-align: center;
    overflow: hidden;
    filter:
            drop-shadow(0px 0px 2px var(--secondary-text-color));
}

.character-player-info
{
    display: grid;
    gap: 6px;
    margin: 20px;
    padding: 12px;
    border: 1px solid currentColor;
    border-radius: 1rem;
    color: var(--secondary-text-color);
    background: var(--bg-color);
    filter:
            drop-shadow(0px 1px 1px rgba(0,0,0,0.1));
}

.character-text,
.character-records {
    margin: 20px ;
}
/* アコーディオン */
details,
.theme-accordion {
    padding: 5px;
}
details:not(:last-child),
.theme-accordion:not(:last-child) {
    margin-bottom: 20px;
}


details > summary,
.theme-accordion > summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 0.8em 1.5em;
    margin-bottom: 0;
    list-style: none;
    cursor: pointer;
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 2em;
}

details[open] > summary,
.theme-accordion[open] > summary {
    margin-bottom: 10px;
}

details > summary::-webkit-details-marker,
.theme-accordion > summary::-webkit-details-marker {
    display: none;
}

details > summary::after,
.theme-accordion > summary::after
{
    font-family: FontAwesome;
    content: '\f067';
    margin-left: 10px;
}

details[open] > summary::after,
.theme-accordion[open] > summary::after {
    content: '\f068';
}

details p,
.theme-accordion p {
    margin: 0;
    padding: 20px;
}

.description-text {
    line-height: 1.9;
    white-space: pre-wrap;
}

.description-serif {
    margin: 0.8em 0;
    white-space:nowrap;
}

.description-image {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0.8em 0;
}

.description-accordion-body {
    white-space: pre-wrap;
}

.chat-post-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-post-tools > button {
    padding: 4px 8px;
    border: 0;
    background: transparent;
    color: var(--text-color);
    font-size: 1rem;
}

.chat-tag-button {
    min-width: 28px;
    min-height: 28px;
    font-family: FontAwesome;
    box-shadow: none;
}

.chat-tag-button.tag-large,
.chat-tag-button.tag-small {
    font-family: FontAwesome, sans-serif;
}

.icon-select-current-button,
.icon-select-radio,
.icon-select-option {
    box-sizing: border-box;
    width: 60px;
    height: 60px;
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--tertiary-bg-color);
    cursor: pointer;
}

.icon-select-current-button {
    padding: 0;
    border-color: var(--primary-bg-color);
}

.icon-select-current-button:disabled {
    cursor: default;
}

.icon-select-radio.is-selected,
.icon-select-option.is-selected {
    border-color: var(--primary-bg-color);
}

.icon-select-radio input {
    display: none;
}

.icon-select-current-button img,
.icon-select-radio img,
.icon-select-option img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.icon-select-modal {
    width: inherit;
    max-height: 600px;
    border: 0;
    padding: 18px;
    margin: auto;
    overflow: hidden;
}

.icon-select-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.icon-select-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.icon-select-modal-header button {
    min-width: 36px;
    min-height: 36px;
}

.icon-select-modal-list {
    max-height: min(420px, calc(100vh - 180px));
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.icon-select-option {
    padding: 0;
}

/* ダイアログ */
dialog
{
    max-width: 780px;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: solid 0;

}
dialog::backdrop
{
    background-color: #000000aa;
    backdrop-filter: blur(10px);
}

.sidebar
{
    border-right: dotted 1px var(--text-color);
}

.primary-action,
.primary-action:hover,
.primary-action:visited,
.primary-action:active {
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
    border: var(--primary-bg-color) solid 0.15rem;

}

.secondary-action,
.secondary-action:hover,
.secondary-action:visited,
.secondary-action:active {
    background-color: transparent;
    color: var(--text-color);
    border: 0.15rem solid currentColor;

}

.danger-action,
.danger-action:hover,
.danger-action:visited,
.danger-action:active{
    border-color: #a33;
    color: #a33;

}

/*
 * 編集・詳細ページ共通
 */
.room-setting-view,
.character-setting-view,
.record-form-view,
.record-detail-view {
    box-sizing: border-box;
    width: min(820px, calc(100% - 32px));
    margin: 24px auto 80px;
}

.room-setting-form,
.room-setting-section,
.character-setting-form,
.character-setting-section,
.record-form,
.record-form-section {
    min-width: 0;
    display: grid;
    gap: 18px;
}

.room-setting-section,
.character-setting-section,
.record-form-section {
    padding-bottom: 28px;
    border-bottom: 1px solid currentColor;
}

.room-setting-section h2,
.character-setting-section h2 {
    margin: 0;
    font-size: 1rem;
}

.room-setting-section label:not(.setting-check),
.character-setting-section label,
.record-form-section label {
    min-width: 0;
    display: grid;
    gap: 8px;
    font-weight: 700;
}

.room-setting-section input[type="text"],
.room-setting-section select,
.room-setting-section textarea,
.character-setting-section input[type="text"],
.character-setting-section textarea,
.record-form-section input[type="text"],
.record-form-section textarea,
.record-form-section select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid currentColor;
    background: var(--tertiary-bg-color);
    color: var(--tertiary-text-color);
    font: inherit;
}

.room-setting-section textarea,
.character-setting-section textarea,
.record-form-section textarea {
    resize: vertical;
    line-height: 1.7;
}

.image-url-control {
    min-width: 0;
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.image-preview {
    box-sizing: border-box;
    width: 60px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid currentColor;
    background: var(--tertiary-bg-color);
}

.icon-preview {
    width: 60px;
    height: 60px;
    aspect-ratio: 1;
}

.image-preview img,
.record-detail-icon img,
.record-list-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.room-setting-view .section-title-row,
.character-setting-view .section-title-row {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
}

.room-setting-view .section-title-row h2,
.character-setting-view .section-title-row h2 {
    margin: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.danger-form {
    margin-top: 96px;
    padding-top: 24px;
    border-top: 1px solid currentColor;
}

.danger-message {
    display: grid;
    gap: 8px;
    color: #a33;
}

.danger-message h2,
.danger-message p {
    margin: 0;
}

.drag-handle {
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* room-header の sticky を親要素の高さ不足で殺さない */
body:has(.room-header) .container {
    height: auto;
}

body:has(.room-header) .room-header {
    position: sticky;
    top: 0;
    z-index: 100;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 20px;

    background:
            radial-gradient(ellipse at top, var(--bg-color), transparent 70%);
}

@media screen and (max-width: 780px) {

    .toggle-menu
    {
        gap: 8px;
        max-width: 400px;
        min-width: calc(min(100% - 32px,400px));
    }

    .toggle-menu > a,
    .toggle-menu > div
    {
        width: auto;
        padding: 6px;
    }

    body:has(.room-header) .room-header {
        padding: 12px 5px;
    }
    .room-header,
    .room-header-left,
    .room-header-right,
    .room-header-button
    {
        gap: 1px;
    }
    .room-header-breadcrumb {
        width: 100%;
        max-width: 100%;
        font-size: 0.6rem;
        padding: 0.7em 1em;
    }

    .room-header-breadcrumb a,
    .room-header-breadcrumb span:not(.room-header-separator) {
        max-width: 96px;
    }

    .room-header-button > a,
    .room-header-button > button,
    .room-sidebar-toggle {
        font-size: 0.6rem;
        padding: 0.6rem;
    }

    .room-header-character {
        max-width: 140px;
        gap: 0;
        padding: 2px;
    }
    .room-header-character-icon {
        width: 22px;
        height: 22px;
    }
    .room-header-character-name {
        font-size: 0.6rem;
        min-width: 0;
        max-width: 0;
    }

    dialog
    {
        max-width: 100%;
    }

    .room-setting-view,
    .character-setting-view,
    .record-form-view,
    .record-detail-view {
        width: calc(100% - 24px);
    }

    .introduction
    {
        font-size: 0.9rem;
    }
    .name
    {
        font-size: 1.4rem;
    }

    .danger-form {
        margin-top: 72px;
    }

    .character-view
    {
        width: 100%;
        overflow-x: clip;
    }

    .sidebar
    {
        border-right: 0;
        border-bottom: dotted 1px var(--text-color);
    }
}
