:root {
    --bg: #0D1C1B;
    --card: #172B29;
    --border: #35534B;
    --gold: #E2C47B;
    --text: #F6F4EA;
    --text-muted: #A9BDB1;
    --green: #61C98A;
    --red: #E9A98C;
    --radius: 15px;
    --content-width: 390px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    display: flex;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: var(--content-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    position: relative;
}

.app-top-bar {
    height: 6px;
    background: var(--gold);
    flex-shrink: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.app-header .brand .suit {
    color: var(--gold);
}

.app-header .status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
}

.app-content {
    flex: 1;
    padding: 20px 24px 110px;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    margin: 6px 0 4px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 20px;
}

.back-link {
    display: inline-block;
    color: var(--gold);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 4px 0 14px;
}

.section-heading h2 {
    font-size: 17px;
    margin: 0;
}

.section-heading .count {
    color: var(--text-muted);
    font-size: 13px;
}

.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.table-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.table-card-head h3 {
    font-size: 20px;
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-available {
    background: rgba(97, 201, 138, 0.16);
    color: var(--green);
}

.badge-full {
    background: rgba(233, 169, 140, 0.18);
    color: var(--red);
}

.badge-neutral {
    background: rgba(169, 189, 177, 0.16);
    color: var(--text-muted);
}

.badge-gold {
    background: rgba(226, 196, 123, 0.16);
    color: var(--gold);
}

.table-meta {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.seat-count {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.progress-track {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 999px;
}

.progress-fill.full {
    background: var(--red);
}

.table-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.seats-left {
    color: var(--green);
}

.seats-full-text {
    color: var(--red);
}

.detail-link {
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
}

.field-list .field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.field-list .field-row:last-child {
    border-bottom: none;
}

.field-row .label {
    color: var(--text-muted);
}

.field-row .value {
    font-weight: 700;
}

.field-row .value.gold {
    color: var(--gold);
}

/* "已報名" row doubles as a <details> toggle that reveals who's registered. */
.field-list details {
    border-bottom: none;
}

.field-list summary.field-row {
    cursor: pointer;
    list-style: none;
}

.field-list summary.field-row::-webkit-details-marker,
.field-list summary.field-row::marker {
    display: none;
    content: "";
}

.field-row .chevron {
    display: inline-block;
    margin-left: 6px;
    transition: transform 0.15s ease;
}

.field-list details[open] .chevron {
    transform: rotate(180deg);
}

.registrant-list {
    padding: 4px 0 14px;
}

.registrant-list .registrant-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.registrant-list .registrant-row .index {
    color: var(--text-muted);
    margin-right: 10px;
}

.registrant-empty {
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 0 14px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group .hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 6px;
}

input[type=text],
input[type=number],
input[type=date],
input[type=time],
select,
textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 15px;
    padding: 13px 14px;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 47px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-primary {
    background: var(--gold);
    color: #17130a;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger-text {
    background: none;
    border: none;
    color: var(--red);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
}

.helper-text {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 18px;
}

.flash {
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 18px;
}

.flash-success {
    background: rgba(97, 201, 138, 0.16);
    color: var(--green);
    border: 1px solid rgba(97, 201, 138, 0.35);
}

.flash-error {
    background: rgba(233, 169, 140, 0.16);
    color: var(--red);
    border: 1px solid rgba(233, 169, 140, 0.35);
}

.flash-info {
    background: rgba(169, 189, 177, 0.14);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* 會員管理: list rows + chat thread */
.member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
}

.member-row:last-child {
    border-bottom: none;
}

.member-row .name-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.member-row .meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.member-row .last-message {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.member-detail-head .line-id {
    color: var(--text-muted);
    font-size: 12px;
    word-break: break-all;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0;
}

.chat-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble .meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-bubble.inbound {
    align-self: flex-start;
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble.outbound {
    align-self: flex-end;
    background: rgba(226, 196, 123, 0.16);
    border: 1px solid rgba(226, 196, 123, 0.35);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.chat-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-form textarea {
    flex: 1;
    min-height: 44px;
}

.chat-form button {
    width: auto;
    padding: 0 18px;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 10px;
    font-size: 14px;
}

.reg-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.reg-card h3 {
    font-size: 20px;
    margin: 10px 0 6px;
}

.reg-card .reg-meta {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 2px;
}

.reg-card .divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

.reg-card .reg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.reg-row-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.summary-card {
    display: flex;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.summary-card .stat {
    flex: 1;
    text-align: center;
}

.summary-card .stat + .stat {
    border-left: 1px solid var(--border);
}

.summary-card .stat .label {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.summary-card .stat .value {
    font-size: 26px;
    font-weight: 700;
}

.summary-card .stat .value.gold {
    color: var(--gold);
}

.section-label {
    font-weight: 700;
    font-size: 15px;
    margin: 22px 0 12px;
}

.manage-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
}

.manage-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manage-card h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.manage-card .meta {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.manage-link {
    color: var(--gold);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}

.roster-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.roster-row:last-child {
    border-bottom: none;
}

.roster-row .name {
    font-weight: 700;
    font-size: 15px;
}

.roster-row .meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: var(--content-width);
    display: flex;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bottom-nav a .icon {
    font-size: 18px;
}

.bottom-nav a.active {
    color: var(--gold);
}

.top-user-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 24px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.top-user-bar form {
    margin: 0;
}

.top-user-bar a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
}

.top-user-bar button {
    background: none;
    border: none;
    color: var(--text-muted);
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}

.login-screen {
    padding: 60px 24px;
}

.login-screen .logo {
    text-align: center;
    font-size: 40px;
    margin-bottom: 12px;
}

.login-screen h1 {
    text-align: center;
    margin: 0 0 6px;
}

.login-screen p.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 32px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-muted);
}

.checkbox-row input {
    width: 18px;
    height: 18px;
}
