* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, "PingFang TC", "Noto Sans TC", sans-serif;
}

.hidden {
    display: none !important;
}

/* ---------- 登入畫面 ---------- */
.login-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #273246; /* LINE 深藍灰 */
}

.login-card {
    text-align: center;
    color: #fff;
    padding: 24px;
    width: 100%;
    max-width: 320px;
}

.login-logo {
    font-size: 64px;
}

.login-card h1 {
    margin: 8px 0 24px;
    font-size: 28px;
    letter-spacing: 2px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
}

.login-card button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background: #06c755; /* LINE 綠 */
    cursor: pointer;
}

.mode-hint {
    margin-top: 12px;
    font-size: 12px;
    color: #9fb0c9;
}

.login-card .secondary-button {
    margin-top: 10px;
    background: none;
    border: 1px solid #4a5d7e;
    color: #9fb0c9;
}

.auth-links {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.auth-links a {
    color: #9fb0c9;
}

.auth-error {
    margin-top: 12px;
    font-size: 13px;
    color: #ff8a80;
    min-height: 1em;
}

.waiting-text {
    font-size: 14px;
    color: #9fb0c9;
    margin-bottom: 20px;
}

/* ---------- 聊天畫面 ---------- */
.chat-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #7494c0; /* LINE 聊天室藍底 */
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: #273246;
    color: #fff;
    flex-shrink: 0;
}

.chat-title {
    font-size: 17px;
    font-weight: bold;
}

.my-name {
    font-size: 13px;
    color: #9fb0c9;
}

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

.header-button {
    font-size: 18px;
    color: #9fb0c9;
}

/* ---------- 成員管理面板 ---------- */
.admin-panel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.admin-card {
    background: #fff;
    border-radius: 12px;
    width: min(92vw, 420px);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #273246;
    color: #fff;
    font-weight: bold;
}

.admin-header .icon-button {
    color: #fff;
    font-size: 16px;
}

.member-list {
    overflow-y: auto;
    padding: 8px 0;
}

.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

.member-name {
    font-size: 15px;
}

.member-email {
    font-size: 12px;
    color: #888;
}

.member-action {
    border: none;
    border-radius: 14px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.member-action.approve {
    background: #06c755;
}

.member-action.suspend {
    background: #e05a5a;
}

/* ---------- 照片滿版檢視 ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.lightbox img {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

.lightbox-button {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    z-index: 21;
}

.lightbox-close {
    right: 14px;
}

.lightbox-download {
    left: 14px;
}

/* ---------- 個人設定 ---------- */
.settings-body {
    padding: 18px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-avatar-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
}

.settings-avatar {
    width: 64px;
    height: 64px;
    font-size: 26px;
}

.settings-label {
    font-size: 13px;
    color: #666;
}

.settings-body input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* 小於 16px iOS Safari 點擊會自動放大畫面 */
}

.settings-save {
    margin-top: 6px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #06c755;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.settings-hint {
    font-size: 13px;
    color: #666;
    min-height: 1em;
}

/* ---------- 頭像裁切 ---------- */
.crop-card {
    width: min(92vw, 340px);
}

.crop-viewport {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 16px auto 0;
    overflow: hidden;
    background: #111;
    touch-action: none; /* 手機拖曳照片時不要捲動頁面 */
    cursor: grab;
}

.crop-viewport img {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
}

/* 中央方框: 用四邊超大陰影把框外壓暗 */
.crop-frame {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 255, 255, .9);
    pointer-events: none;
}

.crop-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px 18px;
}

.crop-controls input[type="range"] {
    flex: 1;
}

.crop-controls .settings-save {
    margin-top: 0;
    padding: 8px 18px;
    flex-shrink: 0;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

/* 日期分隔線 */
.date-divider {
    text-align: center;
    margin: 12px 0;
}

.date-divider span {
    background: rgba(0, 0, 0, .25);
    color: #fff;
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 12px;
}

/* 訊息列 */
.message-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    gap: 6px;
}

.message-row.mine {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4a5d7e;
    color: #fff;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-body {
    max-width: 70%;
}

.sender-name {
    font-size: 12px;
    color: #e8eef7;
    margin-bottom: 3px;
}

.bubble {
    display: inline-block;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.45;
    word-break: break-word;
    background: #fff;
    border-top-left-radius: 4px;
}

.mine .bubble {
    background: #8de65c; /* LINE 自己的綠泡泡 */
    border-top-left-radius: 16px;
    border-top-right-radius: 4px;
}

/* 訊息內網址連結 */
.bubble a {
    color: #1565d8;
    word-break: break-all;
}

.mine .bubble a {
    color: #0b6e2f;
}

/* 貼圖訊息: 不用泡泡, 大顆 emoji 或圖片 */
.bubble.sticker {
    background: none;
    padding: 0;
    font-size: 64px;
    line-height: 1;
}

.bubble.sticker img {
    width: 120px;
    display: block;
}

/* 照片訊息: 圓角縮圖, 點開滿版 */
.bubble.photo {
    background: none;
    padding: 0;
    overflow: hidden;
    border-radius: 14px;
}

.bubble.photo img {
    display: block;
    max-width: min(220px, 60vw);
    max-height: 280px;
    cursor: pointer;
}

.bubble.photo.uploading {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, .18);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bubble.upload-failed {
    background: #ffd9d9;
    color: #b00;
    padding: 9px 13px;
    font-size: 13px;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.timestamp {
    font-size: 11px;
    color: #dfe7f2;
    flex-shrink: 0;
    padding-bottom: 2px;
}

/* ---------- 貼圖面板: 上排包頁籤 + 下面貼圖格 ---------- */
.sticker-panel {
    background: #fff;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

.sticker-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px 0;
    border-bottom: 1px solid #eee;
}

.sticker-tabs button {
    font-size: 22px;
    padding: 6px 12px;
    border: none;
    background: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    opacity: .45;
}

.sticker-tabs button.active {
    background: #f0f0f0;
    opacity: 1;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.sticker-grid button {
    font-size: 40px;
    padding: 8px 0;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
}

.sticker-grid button img {
    width: 100%;
    max-width: 72px;
}

.sticker-grid button:active {
    background: #eee;
}

/* ---------- 輸入列 ---------- */
.input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: #fff;
    flex-shrink: 0;
}

.icon-button {
    font-size: 24px;
    border: none;
    background: none;
    cursor: pointer;
}

.input-bar input {
    flex: 1;
    min-width: 0;
    padding: 9px 14px;
    border: 1px solid #ddd;
    border-radius: 18px;
    font-size: 16px; /* 小於 16px iOS Safari 點擊會自動放大畫面 */
    outline: none;
}

.send-button {
    padding: 9px 16px;
    border: none;
    border-radius: 18px;
    background: #06c755;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.send-button:disabled {
    background: #b9e6cd;
}
