:root {
    --ink: #101012;
    --paper: #f4f0ea;
    --line: rgba(16, 16, 18, 0.14);
    --red: #c53428;
    --teal: #2e7972;
    --white: #fffaf2;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
    line-height: 1.65;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 14px clamp(18px, 4vw, 44px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 900;
}

.topbar nav {
    display: flex;
    gap: 20px;
    align-items: center;
    font-weight: 800;
}

.topbar form {
    margin: 0;
}

.notification-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.nav-badge {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    background: var(--red);
    color: var(--white);
    font-size: 0.78rem;
    line-height: 1;
}

.hero,
.scratch-page {
    display: grid;
    gap: 24px;
    align-items: center;
    min-height: calc(100vh - 72px);
    padding: clamp(32px, 7vw, 96px);
}

.hero {
    max-width: 980px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.page-heading {
    padding: clamp(32px, 6vw, 72px) clamp(18px, 4vw, 44px) 24px;
}

.page-heading h1 {
    margin-bottom: 8px;
}

.text-link {
    color: var(--red);
    font-weight: 900;
}

.page-notice {
    width: min(1120px, calc(100% - 36px));
    margin: 18px auto 0;
}

.scratch-page {
    grid-template-columns: minmax(260px, 0.8fr) minmax(280px, 400px);
}

.eyebrow {
    margin: 0;
    color: var(--red);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.12em;
}

h1 {
    margin: 8px 0 14px;
    font-size: clamp(2.4rem, 8vw, 5.8rem);
    line-height: 0.96;
}

h2 {
    margin: 0 0 8px;
}

p {
    max-width: 66ch;
    color: rgba(16, 16, 18, 0.72);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--red);
    border-radius: 8px;
    background: var(--red);
    color: var(--white);
    cursor: pointer;
    font-weight: 900;
}

.button.ghost {
    background: transparent;
    color: var(--red);
}

.spec-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    padding: 0 clamp(18px, 4vw, 44px) 56px;
}

.spec-grid article {
    min-height: 170px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.72);
}

.pack-grid,
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding: 0 clamp(18px, 4vw, 44px) 72px;
}

.pack-card,
.collection-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.78);
}

.pack-card {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 18px;
    padding: 14px;
}

.pack-card img,
.pack-placeholder {
    width: 150px;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    object-fit: cover;
}

.pack-placeholder {
    display: grid;
    place-items: center;
    background: #c8ad87;
    color: rgba(16, 16, 18, 0.54);
    font-weight: 900;
}

.badge {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(16, 16, 18, 0.1);
    color: rgba(16, 16, 18, 0.62);
    font-weight: 900;
}

.pack-detail {
    display: grid;
    grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
    gap: clamp(24px, 6vw, 70px);
    align-items: center;
    padding: clamp(32px, 7vw, 92px) clamp(18px, 4vw, 44px);
}

.pack-art img,
.pack-art .pack-placeholder {
    width: min(360px, 80vw);
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2);
}

.meta-list {
    display: grid;
    gap: 8px;
    margin: 22px 0;
}

.meta-list div {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.meta-list dt {
    color: rgba(16, 16, 18, 0.62);
    font-weight: 800;
}

.meta-list dd {
    margin: 0;
    font-weight: 900;
}

.collection-card a {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 12px;
}

.collection-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    object-fit: cover;
}

.collection-card strong,
.collection-card small {
    display: block;
}

.collection-card small {
    color: rgba(16, 16, 18, 0.62);
    font-weight: 800;
}

.count-bubble {
    position: absolute;
    top: 20px;
    right: 20px;
    display: grid;
    min-width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 999px;
    background: var(--red);
    color: var(--white);
    font-weight: 900;
}

.scratch-frame {
    position: relative;
    width: min(400px, 82vw);
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border: 1px solid rgba(255, 250, 242, 0.22);
    border-radius: 8px;
    background: #000;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
    touch-action: none;
}

.scratch-frame canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.admin-body {
    background: #f7f3ed;
}

.admin-shell,
.auth-panel {
    width: min(1120px, calc(100% - 36px));
    margin: 0 auto;
    padding: 44px 0 72px;
}

.auth-panel {
    width: min(520px, calc(100% - 36px));
}

.admin-heading {
    margin-bottom: 24px;
}

.admin-heading h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 4rem);
}

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

.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(46, 121, 114, 0.3);
    border-radius: 8px;
    background: rgba(46, 121, 114, 0.1);
    color: var(--teal);
    font-weight: 800;
}

.notice.error,
.form-error {
    border-color: rgba(197, 52, 40, 0.35);
    background: rgba(197, 52, 40, 0.08);
    color: var(--red);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.stat-grid article,
.table-card,
.form-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.78);
}

.stat-grid article {
    display: grid;
    gap: 4px;
    min-height: 120px;
    padding: 22px;
}

.stat-grid strong {
    font-size: 2.4rem;
    line-height: 1;
}

.stat-grid span {
    color: rgba(16, 16, 18, 0.62);
    font-weight: 800;
}

.table-card {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    font-size: 0.8rem;
    color: rgba(16, 16, 18, 0.62);
    text-transform: uppercase;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}

.actions form {
    margin: 0;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.media-cell {
    display: flex;
    gap: 12px;
    align-items: center;
    font-weight: 900;
}

.media-cell img {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    object-fit: cover;
}

.form-card {
    display: grid;
    gap: 16px;
    padding: 24px;
}

.search-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    margin-bottom: 18px;
}

.role-form {
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.4fr) minmax(220px, 1fr) auto;
    align-items: end;
    margin-bottom: 18px;
}

.form-card.wide {
    width: min(760px, 100%);
}

label {
    display: grid;
    gap: 7px;
    color: rgba(16, 16, 18, 0.72);
    font-weight: 900;
}

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

textarea {
    resize: vertical;
}

.preview {
    width: 130px;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: cover;
}

.preview.tall {
    width: 120px;
    aspect-ratio: 2 / 3;
}

.preview-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.preview-row figure {
    margin: 0;
}

.preview-row figcaption,
.locked-note {
    color: rgba(16, 16, 18, 0.62);
    font-weight: 800;
}

.chat-layout,
.notification-list {
    width: min(980px, calc(100% - 36px));
    margin: 0 auto 72px;
}

.chat-panel {
    display: grid;
    gap: 18px;
}

.message-list {
    display: grid;
    gap: 12px;
}

.message,
.notification-list article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.78);
    padding: 16px;
}

.message {
    width: min(680px, 100%);
}

.message.user {
    justify-self: end;
    border-color: rgba(46, 121, 114, 0.28);
    background: rgba(46, 121, 114, 0.08);
}

.message.character {
    justify-self: start;
}

.message div,
.notification-list article > div {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.message p {
    margin-bottom: 0;
    white-space: pre-wrap;
}

.message time,
.message small,
.notification-list time {
    color: rgba(16, 16, 18, 0.55);
    font-size: 0.86rem;
    font-weight: 800;
}

.chat-form {
    width: 100%;
}

.notification-list {
    display: grid;
    gap: 12px;
}

.notification-list article.unread {
    border-color: rgba(197, 52, 40, 0.34);
}

.moderation-panel,
.restriction-list article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 242, 0.72);
}

.moderation-panel {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.character-account-panel {
    width: min(760px, 100%);
    margin-top: 18px;
}

.restriction-list {
    display: grid;
    gap: 10px;
}

.restriction-list article {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.user-admin-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

@media (max-width: 820px) {
    .scratch-page,
    .spec-grid,
    .stat-grid,
    .pack-grid,
    .card-grid,
    .pack-detail,
    .user-admin-grid,
    .search-form,
    .role-form {
        grid-template-columns: 1fr;
    }

    .pack-card {
        grid-template-columns: 120px minmax(0, 1fr);
    }

    .pack-card img,
    .pack-placeholder {
        width: 120px;
    }

    .row-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}
