:root {
    --bg: #f5f7f4;
    --panel: #ffffff;
    --text: #1d2c2a;
    --muted: #5e6a68;
    --line: #d8dfdc;
    --primary: #0e7a6d;
    --primary-strong: #0a5e54;
    --secondary: #f2efe6;
    --danger: #ab2f2f;
    --shadow: 0 12px 30px rgba(14, 122, 109, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at 10% 10%, #ffffff 0%, #f5f7f4 45%, #eef3ef 100%);
    color: var(--text);
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a {
    color: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
    background: rgba(245, 247, 244, 0.92);
}

.brand {
    font-weight: 800;
    letter-spacing: 0.03em;
    text-decoration: none;
    font-size: 1.1rem;
}

.main-nav {
    display: flex;
    gap: 14px;
}

.main-nav a {
    text-decoration: none;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 999px;
}

.main-nav a.active {
    color: #fff;
    background: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: 0.9rem;
    color: var(--muted);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 6px 10px;
    cursor: pointer;
    min-height: 40px;
    color: #111;
}

.container {
    width: min(1040px, calc(100% - 32px));
    margin: 30px auto 48px;
    display: grid;
    gap: 18px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.auth-panel {
    width: min(460px, 100%);
    margin: 30px auto;
}

.channel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.muted {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    min-height: 44px;
}

textarea {
    resize: vertical;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    padding: 10px 14px;
    font-weight: 700;
    min-height: 44px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-strong);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
    border-color: var(--line);
}

.auth-link {
    margin: 8px 0 0;
    font-size: 0.95rem;
}

.field-error {
    color: var(--danger);
    font-size: 0.88rem;
}

.flash {
    border-radius: 10px;
    border: 1px solid;
    padding: 10px 12px;
    font-weight: 600;
}

.flash-success {
    background: #ecf9f6;
    border-color: #9cd7cc;
    color: #0b5b50;
}

.flash-error {
    background: #fff1f1;
    border-color: #efbcbc;
    color: #8f2b2b;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.summary-card {
    display: grid;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.cover-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #e5ece9;
}

.summary-card-body {
    padding: 0 12px 14px;
}

.summary-card-body h2 {
    margin: 4px 0;
    font-size: 1.05rem;
}

.owner-label,
.chapter-label {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 4px 0;
}

.summary-preview {
    margin: 8px 0 0;
}

.book-feed {
    display: grid;
    gap: 16px;
}

.book-card h2 {
    margin: 0;
}

.book-summary-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.summary-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.summary-block-head h3 {
    margin: 0;
}

.summary-block-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.summary-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.summary-row {
    display: block;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.summary-row:hover {
    border-color: #9dcfc7;
    box-shadow: 0 8px 18px rgba(14, 122, 109, 0.08);
}

.inline-summary-form {
    margin-top: 12px;
}

.summary-fields {
    border-top: 1px dashed var(--line);
    padding-top: 14px;
    display: grid;
    gap: 14px;
}

.book-headline {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 14px;
    align-items: start;
}

.cover-large {
    width: min(300px, 100%);
    border-radius: 12px;
    border: 1px solid var(--line);
}

.detail-header {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 18px;
    align-items: start;
}

.detail-block {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 14px;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}

.admin-user-row p {
    margin: 0;
}

.owned-sort {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.owned-sort a {
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    background: #fff;
    color: var(--muted);
}

.owned-sort a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.owned-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.owned-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.owned-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.owned-item-head > div {
    flex: 1;
    min-width: 0;
}

.owned-edit-btn {
    min-width: auto;
    min-height: 30px;
    padding: 3px 8px;
    font-size: 0.76rem;
    line-height: 1.1;
    border-radius: 8px;
    font-weight: 700;
    flex: 0 0 auto;
}

.owned-item-title {
    margin: 0 0 4px;
    font-weight: 700;
}

.owned-item .muted {
    margin: 0;
}

.empty-state h2 {
    margin-top: 0;
}

@media (max-width: 760px) {
    body {
        padding-bottom: 12px;
    }

    .site-header {
        position: static;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }

    .main-nav {
        order: 2;
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
        gap: 6px;
        padding: 0;
        border-top: 0;
        background: transparent;
        backdrop-filter: none;
    }

    .main-nav a {
        text-align: center;
        border: 1px solid var(--line);
        background: #fff;
        padding: 12px 4px;
        font-size: 0.6rem;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-right {
        order: 3;
        justify-content: space-between;
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .user-email {
        max-width: 100%;
        font-size: 0.78rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: break-all;
    }

    .brand {
        font-size: 1rem;
        line-height: 1.2;
    }

    .logout-btn {
        min-height: 34px;
        padding: 4px 8px;
        font-size: 0.78rem;
    }

    .channel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .channel-header .btn-primary {
        width: 100%;
    }

    .container {
        width: calc(100% - 20px);
        margin: 16px auto 18px;
        gap: 12px;
    }

    .panel {
        padding: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .book-feed {
        gap: 12px;
    }

    .summary-card {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .summary-card-body {
        padding: 10px 12px;
    }

    .actions-row .btn-primary,
    .actions-row .btn-secondary {
        width: 100%;
    }

    .summary-block-head {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-block-actions {
        width: 100%;
    }

    .summary-block-actions .btn-secondary {
        width: 100%;
    }

    .summary-block-head .btn-secondary {
        width: 100%;
    }

    .owned-sort {
        flex-direction: column;
        align-items: stretch;
    }

    .owned-sort a {
        text-align: center;
    }

    .admin-user-row {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-user-row .btn-primary {
        width: 100%;
    }

    .detail-header,
    .book-headline {
        grid-template-columns: 1fr;
    }
}
