/* =========================================================
   Forge of Heroes portal layout
   Loaded after site.css so that legacy body/header rules are reset.
   ========================================================= */

:root {
    --portal-bg: #f4f1ec;
    --portal-surface: #ffffff;
    --portal-surface-soft: #fbf8f3;
    --portal-text: #29231f;
    --portal-muted: #72685f;
    --portal-line: #ded6cc;
    --portal-accent: #7a4e2d;
    --portal-accent-dark: #4e2f1c;
    --portal-accent-soft: #efe2d5;
    --portal-shadow: 0 14px 40px rgba(54, 39, 27, 0.09);
    --portal-radius: 22px;
    --portal-header-height: 72px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--portal-header-height) + 18px);
}

body.hero-app {
    display: block;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 0%, rgba(255,255,255,0.95), transparent 30%),
        linear-gradient(145deg, #f6f2ec 0%, #eee5da 100%);
    color: var(--portal-text);
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans JP",
        sans-serif;
    line-height: 1.7;
}

.hero-app a {
    color: var(--portal-accent-dark);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: var(--portal-header-height);
    padding: 0;
    color: #fff;
    background: rgba(35, 27, 22, 0.96);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(14px);
}

.app-header__inner {
    width: min(1180px, calc(100% - 32px));
    min-height: var(--portal-header-height);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.app-brand {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    color: #fff !important;
    text-decoration: none;
    line-height: 1.15;
}

.app-brand__main {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.app-brand__sub {
    margin-top: 4px;
    color: rgba(255,255,255,0.66);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.app-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 13px;
    border-radius: 999px;
    color: rgba(255,255,255,0.8) !important;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.16s ease, color 0.16s ease;
}

.app-nav__link:hover,
.app-nav__link:focus-visible {
    color: #fff !important;
    background: rgba(255,255,255,0.1);
}

.app-nav__link.is-current {
    color: #2d1e15 !important;
    background: #f2e6d9;
}

.app-nav__link--login {
    margin-left: 4px;
    border: 1px solid rgba(255,255,255,0.28);
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 34px auto 60px;
}

.guide-panel {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    align-items: center;
    gap: 30px;
    margin-bottom: 24px;
}

.guide-character {
    position: relative;
    z-index: 2;
}

.guide-character__placeholder {
    aspect-ratio: 4 / 5;
    width: 100%;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--portal-muted);
    background:
        linear-gradient(145deg, rgba(255,255,255,0.96), rgba(238,227,214,0.95));
    border: 1px solid var(--portal-line);
    border-radius: 24px 24px 14px 14px;
    box-shadow: var(--portal-shadow);
}

.guide-character__placeholder span {
    font-weight: 800;
}

.guide-character__placeholder small {
    margin-top: 4px;
}

.guide-bubble {
    position: relative;
    min-height: 154px;
    padding: 25px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--portal-surface);
    border: 2px solid #3d332d;
    border-radius: 28px;
    box-shadow: var(--portal-shadow);
}

.guide-bubble::before,
.guide-bubble::after {
    content: "";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
}

.guide-bubble::before {
    left: -31px;
    border-top: 18px solid transparent;
    border-bottom: 18px solid transparent;
    border-right: 31px solid #3d332d;
}

.guide-bubble::after {
    left: -27px;
    border-top: 16px solid transparent;
    border-bottom: 16px solid transparent;
    border-right: 28px solid var(--portal-surface);
}

.guide-bubble__name {
    margin: 0 0 6px;
    color: var(--portal-accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.guide-bubble__message {
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.8;
}

.guide-bubble__message p {
    margin: 0;
}

.guide-bubble__message p + p {
    margin-top: 3px;
}

.content-panel {
    min-height: 320px;
    padding: clamp(22px, 4vw, 42px);
    background: rgba(255,255,255,0.94);
    border: 1px solid rgba(102, 79, 61, 0.18);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
}

.content-heading {
    margin-bottom: 28px;
}

.content-heading__eyebrow {
    margin: 0 0 7px;
    color: var(--portal-accent);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.15em;
}

.content-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.25rem);
    line-height: 1.22;
}

.content-heading > p:last-child {
    max-width: 760px;
    margin: 13px 0 0;
    color: var(--portal-muted);
}

.quick-search,
.character-search {
    padding: 20px;
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-line);
    border-radius: 18px;
}

.quick-search label,
.character-search label,
.per-page-form label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 800;
}

.quick-search__row,
.character-search__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.quick-search input,
.character-search input,
.per-page-form select {
    width: 100%;
    min-height: 46px;
    padding: 9px 14px;
    color: var(--portal-text);
    background: #fff;
    border: 1px solid #cfc4b9;
    border-radius: 12px;
    font: inherit;
}

.quick-search button,
.character-search button,
.per-page-form button {
    min-height: 46px;
    padding: 8px 20px;
    color: #fff;
    background: var(--portal-accent-dark);
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.portal-menu {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.portal-menu__card {
    min-height: 112px;
    padding: 18px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    color: var(--portal-text) !important;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 18px;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.portal-menu__card:hover,
.portal-menu__card:focus-visible {
    transform: translateY(-2px);
    border-color: #b99473;
    box-shadow: 0 14px 30px rgba(54, 39, 27, 0.1);
}

.portal-menu__icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-content: center;
    background: var(--portal-accent-soft);
    border-radius: 13px;
    font-size: 1.3rem;
}

.portal-menu__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.portal-menu__text strong {
    font-size: 1.04rem;
}

.portal-menu__text small {
    margin-top: 4px;
    color: var(--portal-muted);
    line-height: 1.5;
}

.portal-menu__arrow {
    color: #9c806c;
    font-size: 1.8rem;
}

.home-note {
    margin-top: 24px;
    padding: 17px 18px;
    color: var(--portal-muted);
    background: #f6f3ef;
    border-left: 4px solid #b58d6e;
    border-radius: 0 14px 14px 0;
}

.home-note p {
    margin: 5px 0 0;
}

/* Messages */
.app-messages {
    width: min(1180px, calc(100% - 32px));
    margin: 18px auto 0;
}

.app-message {
    margin: 0 0 8px;
    padding: 12px 15px;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 12px;
}

/* Story catalog */
.catalog-tools {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
    padding: 20px;
    background: #f8f5f1;
    border: 1px solid var(--portal-line);
    border-radius: 18px;
}

.catalog-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.catalog-filters a {
    padding: 7px 13px;
    color: var(--portal-text);
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.87rem;
    font-weight: 700;
}

.catalog-filters a.is-current {
    color: #fff;
    background: var(--portal-accent-dark);
    border-color: var(--portal-accent-dark);
}

.per-page-form {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.per-page-form label {
    margin: 0;
}

.per-page-form select {
    width: auto;
    min-height: 40px;
    border-radius: 999px;
}

.login-box {
    margin: 18px 0 0;
    padding: 14px 16px;
    background: #fffaf4;
    border: 1px solid #e5d4bd;
    border-radius: 14px;
}

.result-count {
    margin: 24px 0 9px;
    color: var(--portal-muted);
    text-align: center;
    font-size: 0.88rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.pagination a,
.pagination__current {
    min-width: 42px;
    padding: 7px 11px;
    text-align: center;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.88rem;
}

.pagination__current {
    color: #fff;
    background: var(--portal-accent-dark);
    border-color: var(--portal-accent-dark);
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.story-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 18px;
    box-shadow: 0 10px 26px rgba(54,39,27,0.06);
}

.story-card__thumb {
    aspect-ratio: 4 / 3;
    display: grid;
    place-content: center;
    overflow: hidden;
    background: linear-gradient(145deg, #f1ede8, #faf8f5);
}

.story-card__thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.story-card__placeholder {
    color: #92877d;
    font-size: 1rem;
    font-weight: 800;
}

.story-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.story-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.story-badge {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}

.story-badge--free {
    color: #176a2f;
    background: #e9f8ef;
}

.story-badge--locked {
    color: #80560b;
    background: #fff1d0;
}

.story-badge--tier {
    color: #5736a3;
    background: #eee8ff;
}

.story-card__title {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.5;
}

.story-card__title a {
    color: inherit;
    text-decoration: none;
}

.story-card__meta {
    color: var(--portal-muted);
    font-size: 0.8rem;
}

.story-card__excerpt {
    margin: 0;
    color: #4f4640;
    font-size: 0.9rem;
    flex: 1;
}

.character-tags {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

.character-tag {
    padding: 3px 9px;
    color: #254a91 !important;
    background: #eef3ff;
    border: 1px solid #d8e3ff;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.74rem;
    font-weight: 800;
}

.locked-note {
    padding: 10px;
    color: #6f4b00;
    background: #fff8e6;
    border: 1px solid #f0d48a;
    border-radius: 12px;
    font-size: 0.86rem;
}

.story-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 3px;
}

.app-button {
    min-height: 42px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    background: var(--portal-accent-dark);
    border: 1px solid var(--portal-accent-dark);
    border-radius: 999px;
    text-decoration: none;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
}

.app-button--secondary {
    color: var(--portal-text) !important;
    background: #fff;
    border-color: var(--portal-line);
}

.app-button--patreon {
    color: #fff !important;
    background: #ff424d;
    border-color: #ff424d;
}

.empty-panel {
    padding: 28px;
    color: var(--portal-muted);
    background: #f8f5f1;
    border: 1px dashed #c9bbae;
    border-radius: 16px;
}

/* My page */
.mypage {
    display: grid;
    gap: 18px;
}

.mypage .content-heading {
    margin-bottom: 4px;
}

.mypage-panel {
    padding: 22px;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 18px;
}

.mypage-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.mypage-panel h2 {
    margin: 0 0 12px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.favorite-character-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.favorite-character-list span {
    padding: 6px 11px;
    background: var(--portal-accent-soft);
    border-radius: 999px;
    font-weight: 700;
}

.favorite-image-grid,
.mypage-story-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.favorite-image-card,
.mypage-story-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--portal-line);
    border-radius: 15px;
}

.favorite-image-card__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: contain;
    background: #f4f1ed;
}

.favorite-image-card__body,
.mypage-story-card {
    padding: 14px;
}

.favorite-image-card__character {
    color: var(--portal-muted);
    font-size: 0.78rem;
}

.favorite-image-card__title {
    display: inline-block;
    margin-top: 4px;
    font-weight: 800;
    text-decoration: none;
}

.mypage-story-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mypage-story-card h3 {
    margin: 0;
}

.request-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.request-list li {
    padding: 11px 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--portal-line);
}

.app-footer {
    padding: 0 16px 36px;
    color: var(--portal-muted);
    text-align: center;
    font-size: 0.8rem;
}

/* Tablet */
@media (max-width: 920px) {
    .app-header__inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        padding: 12px 0;
    }

    .app-nav {
        width: 100%;
        padding-bottom: 2px;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .guide-panel {
        grid-template-columns: 130px minmax(0, 1fr);
        gap: 24px;
    }

    .story-grid,
    .favorite-image-grid,
    .mypage-story-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Mobile */
@media (max-width: 640px) {
    :root {
        --portal-header-height: 112px;
    }

    .app-header__inner,
    .app-shell,
    .app-messages {
        width: min(100% - 20px, 1180px);
    }

    .app-nav__link {
        min-height: 38px;
        padding: 0 11px;
        font-size: 0.84rem;
    }

    .app-shell {
        margin-top: 18px;
    }

    .guide-panel {
        grid-template-columns: 78px minmax(0, 1fr);
        gap: 15px;
        align-items: stretch;
    }

    .guide-character__placeholder {
        min-height: 112px;
        border-radius: 16px 16px 10px 10px;
        font-size: 0.8rem;
    }

    .guide-bubble {
        min-height: 112px;
        padding: 17px 18px;
        border-radius: 19px;
    }

    .guide-bubble::before {
        left: -21px;
        border-top-width: 13px;
        border-bottom-width: 13px;
        border-right-width: 21px;
    }

    .guide-bubble::after {
        left: -18px;
        border-top-width: 11px;
        border-bottom-width: 11px;
        border-right-width: 19px;
    }

    .guide-bubble__message {
        font-size: 0.91rem;
        line-height: 1.65;
    }

    .content-panel {
        padding: 20px 16px;
        border-radius: 18px;
    }

    .content-heading h1 {
        font-size: 2rem;
    }

    .portal-menu,
    .story-grid,
    .favorite-image-grid,
    .mypage-story-grid {
        grid-template-columns: 1fr;
    }

    .quick-search__row,
    .character-search__row {
        grid-template-columns: 1fr;
    }

    .quick-search button,
    .character-search button {
        width: 100%;
    }

    .portal-menu__card {
        min-height: 96px;
    }

    .mypage-profile,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .request-list li {
        flex-direction: column;
        gap: 2px;
    }
}


/* =========================================================
   Guide image
   ========================================================= */
.guide-character__image {
    width: 100%;
    max-height: 260px;
    display: block;
    object-fit: contain;
    object-position: center bottom;
}

/* =========================================================
   Character search labels on /hero/
   ========================================================= */
.character-browser {
    margin-bottom: 26px;
    padding: 22px;
    background: var(--portal-surface-soft);
    border: 1px solid var(--portal-line);
    border-radius: 18px;
}

.character-browser__heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.character-browser__heading h2 {
    margin: 0;
    font-size: 1.2rem;
}

.character-browser__heading p {
    margin: 4px 0 0;
    color: var(--portal-muted);
    font-size: 0.88rem;
}

.character-browser__all {
    flex: 0 0 auto;
    font-size: 0.88rem;
    font-weight: 800;
}

.character-label-list {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.character-search-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 7px 8px 7px 13px;
    color: var(--portal-text) !important;
    background: #fff;
    border: 1px solid #d7cabd;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(54, 39, 27, 0.04);
    transition:
        transform 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease;
}

.character-search-label:hover,
.character-search-label:focus-visible {
    transform: translateY(-1px);
    border-color: #a77c5b;
    box-shadow: 0 7px 16px rgba(54, 39, 27, 0.09);
}

.character-search-label__name {
    font-size: 0.91rem;
    font-weight: 800;
}

.character-search-label__count {
    padding: 2px 8px;
    color: var(--portal-accent-dark);
    background: var(--portal-accent-soft);
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    white-space: nowrap;
}

.character-label-more {
    margin-top: 15px;
}

.character-label-more summary {
    width: fit-content;
    cursor: pointer;
    color: var(--portal-accent-dark);
    font-size: 0.88rem;
    font-weight: 800;
}

.character-label-more summary span {
    color: var(--portal-muted);
    font-weight: 500;
}

.character-label-list--more {
    margin-top: 14px;
}

@media (max-width: 640px) {
    .guide-character__image {
        max-height: 150px;
    }

    .character-browser {
        padding: 17px 14px;
    }

    .character-browser__heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .character-search-label {
        min-height: 38px;
        padding-left: 11px;
    }
}

/* story_catalog.html: キャラクターラベル検索 */
.catalog-character-filter {
    padding: 18px;
    background: #ffffff;
    border: 1px solid var(--portal-line);
    border-radius: 16px;
}

.catalog-character-filter__heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.catalog-character-filter__heading h2 {
    margin: 0;
    font-size: 1rem;
}

.catalog-character-filter__heading p {
    margin: 4px 0 0;
    color: var(--portal-muted);
    font-size: 0.84rem;
}

.catalog-character-filter__clear {
    flex: 0 0 auto;
    font-size: 0.84rem;
    font-weight: 800;
}

.character-search-label.is-current {
    color: #ffffff !important;
    background: var(--portal-accent-dark);
    border-color: var(--portal-accent-dark);
}

.character-search-label.is-current .character-search-label__count {
    color: var(--portal-accent-dark);
    background: #ffffff;
}

@media (max-width: 640px) {
    .catalog-character-filter {
        padding: 15px 12px;
    }

    .catalog-character-filter__heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
}
