* {
    box-sizing: border-box;
}

:root {
    --bg: #f5efe8;
    --header: #b77208;
    --header-dark: #985c00;
    --text: #352415;
    --muted: #7b6148;
    --card: #ffffff;
    --card-soft: #fff8ea;
    --line: #e5d6be;
    --line-strong: #d7bf98;
    --accent: #d58d17;
    --accent-soft: #f5ddb0;
    --table-head: #f8ebc7;
    --table-cell: #fffaf0;
    --shadow: 0 8px 24px rgba(86, 56, 16, 0.07);
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Microsoft JhengHei", Arial, sans-serif;
}

.site-header {
    background: linear-gradient(0deg, var(--header) 0%, #c37a09 100%);
    color: #fffaf1;
    border-top: 6px solid var(--header-dark);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.header-inner {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 14px 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-mark {
    position: relative;
    width: 68px;
    height: 54px;
}

.dot {
    position: absolute;
    border-radius: 999px;
}

.dot-a {
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    background: #fff0a6;
    border: 5px solid #d4a132;
}

.dot-b {
    left: 32px;
    top: 0;
    width: 30px;
    height: 30px;
    background: #161616;
    border: 5px solid #e0b55a;
}

.dot-c {
    left: 0;
    top: 24px;
    width: 30px;
    height: 30px;
    background: #d7a034;
    border: 5px solid #865106;
}

.brand-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.brand-subtitle {
    margin-top: 4px;
    font-size: 14px;
    opacity: 0.95;
}


.page-shell {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 22px 0 30px;
}

.card,
.card-lite {
    border: 1px solid var(--line);
    border-radius: 16px;
}

.card {
    background: var(--card);
    box-shadow: var(--shadow);
}

.card-lite {
    background: var(--card-soft);
}



.converter-panel {
    margin-top: 18px;
    padding: 22px;
}

.panel-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-heading-row h1 {
    margin: 0;
    font-size: 28px;
}

.panel-heading-row p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.fixed-rate-chip {
    flex: 0 0 auto;
    padding: 10px 14px;
    background: var(--card-soft);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    color: #835613;
}

.converter-grid {
    display: grid;
    grid-template-columns: 1fr 160px 1fr;
    gap: 18px;
    align-items: center;
}

.currency-card {
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 160px;
}

.flag {
    font-size: 34px;
    line-height: 1;
}

.currency-card label {
    font-size: 14px;
    font-weight: 700;
}

.currency-name {
    color: var(--muted);
    font-size: 14px;
}

.currency-card input,
.result-input,
.classic-select {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 28px;
    font-weight: 700;
}

.currency-card input:focus,
.classic-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(213, 141, 23, 0.16);
}

.result-input {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.converter-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.swap-button {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(0deg, #f0c66a 0%, #f7d98f 100%);
    color: #6d470f;
    font: inherit;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(163, 112, 25, 0.15);
}

.swap-button:hover {
    filter: brightness(1.02);
}

.swap-note {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.content-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
    margin-top: 20px;
}

.side-card,
.info-block,
.option-panel {
    padding: 18px;
}

.card-title {
    margin-bottom: 14px;
    font-size: 20px;
    font-weight: 800;
}

.mini-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.mini-table-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fffdf8;
}

.mini-card-title {
    padding: 12px 14px;
    background: var(--table-head);
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    font-weight: 800;
}

.mini-table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.mini-table-card th,
.mini-table-card td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0e6d6;
    text-align: right;
}

.mini-table-card th {
    background: #fff7e4;
    font-weight: 800;
}

.mini-table-card td {
    background: var(--table-cell);
}

.mini-table-card tr:last-child td {
    border-bottom: none;
}

.small-note,
.fixed-rate-board p,
.bottom-notice {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.center-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-caption {
    color: var(--muted);
    font-size: 15px;
}

.result-main-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 12px;
}

#result-value {
    font-size: clamp(42px, 6vw, 68px);
    font-weight: 900;
    color: #6e4507;
    letter-spacing: -1px;
}

#result-currency {
    font-size: 26px;
    font-weight: 800;
}

.result-formula {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--card-soft);
    border-radius: 12px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.big-rate {
    margin: 0 0 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card-soft);
    font-size: 24px;
}

.big-rate strong {
    font-size: 34px;
    color: #6d4406;
}

.option-group + .option-group {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #efe5d5;
}

.option-label {
    display: block;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 800;
}

.radio-line {
    display: block;
    margin: 10px 0;
    font-size: 14px;
}

.classic-select {
    font-size: 16px;
    font-weight: 600;
}

.alpha-list {
    margin: 0 0 0 18px;
    padding: 0;
    color: var(--muted);
    line-height: 1.9;
}

.bottom-notice {
    margin-top: 20px;
    padding: 16px 18px;
}

@media (max-width: 1080px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .mini-tables {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 860px) {
    .header-inner,
    .panel-heading-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .converter-grid,
    .mini-tables {
        grid-template-columns: 1fr;
    }

    .converter-center {
        order: 3;
    }

    .page-shell,
    .header-inner {
        width: min(100% - 24px, 1240px);
    }

    .brand-title {
        font-size: 24px;
    }

}

.secret-dot {
    display: block;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.secret-dot:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(255, 232, 184, 0.22);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 460px;
}

.login-card {
    padding: 28px;
}

.login-top-mark {
    position: relative;
    width: 68px;
    height: 54px;
    margin-bottom: 14px;
}

.login-card h1 {
    margin: 0;
    font-size: 30px;
}

.login-card p {
    margin: 8px 0 18px;
    color: var(--muted);
    line-height: 1.6;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 22px;
    font-weight: 700;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(213, 141, 23, 0.16);
}

.login-error {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #ffefef;
    color: #a82222;
    border: 1px solid #f2c0c0;
    font-size: 14px;
    font-weight: 700;
}

.login-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 16px;
}

.text-link {
    color: #8d5e12;
    text-decoration: none;
    font-weight: 700;
}

.text-link:hover,
.chat-back-link:hover {
    text-decoration: underline;
}

.login-hint {
    margin-top: 16px;
    color: var(--muted);
    font-size: 14px;
}

.chat-page {
    min-height: 100vh;
    padding: 18px;
}

.chat-shell {
    width: min(1240px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    min-height: calc(100vh - 36px);
}

.chat-sidebar,
.chat-main {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.chat-sidebar {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(0deg, #f0c66a 0%, #f7d98f 100%);
    font-size: 24px;
}

.chat-room-title {
    font-size: 22px;
    font-weight: 800;
}

.chat-room-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.chat-sidebar-card {
    padding: 14px;
    border-radius: 14px;
    background: var(--card-soft);
    border: 1px solid var(--line);
}

.chat-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
}

.chat-name-input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font: inherit;
}

.chat-name-input:focus,
#chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(213, 141, 23, 0.16);
}

.chat-tip {
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.chat-logout-form {
    margin-top: auto;
}

.chat-logout-button,
.chat-send-button {
    border: none;
    border-radius: 12px;
    background: linear-gradient(0deg, #f0c66a 0%, #f7d98f 100%);
    color: #6d470f;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.chat-logout-button {
    width: 100%;
    min-height: 44px;
}

.chat-back-link {
    color: #8d5e12;
    text-decoration: none;
    font-weight: 700;
}

.chat-main {
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
}

.chat-topbar {
    padding: 18px 20px;
    border-bottom: 1px solid #efe5d5;
    background: #fffdfa;
}

.chat-topbar-title {
    font-size: 22px;
    font-weight: 800;
}

.chat-topbar-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.chat-messages {
    padding: 20px;
    background: linear-gradient(180deg, #fffaf1 0%, #fffdf9 100%);
    overflow-y: auto;
}

.msg-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}

.msg-row.mine {
    align-items: flex-end;
}

.msg-row.other {
    align-items: flex-start;
}

.msg-row.system {
    align-items: center;
}

.msg-meta {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}

.msg-bubble {
    max-width: min(70%, 560px);
    padding: 12px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.55;
    white-space: normal;
    word-break: break-word;
    box-shadow: 0 4px 14px rgba(86, 56, 16, 0.06);
}

.msg-row.other .msg-bubble {
    background: #ffffff;
    border: 1px solid #eadfc8;
    color: var(--text);
    border-top-left-radius: 6px;
}

.msg-row.mine .msg-bubble {
    background: #e9f8cf;
    border: 1px solid #cae8a0;
    color: #2f3b1c;
    border-top-right-radius: 6px;
}

.system-msg {
    padding: 8px 12px;
    border-radius: 999px;
    background: #f5edd7;
    color: #856036;
    font-size: 13px;
}

.chat-input-panel {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
    padding: 16px 18px;
    border-top: 1px solid #efe5d5;
    background: #fffdfa;
}

#chat-input {
    width: 100%;
    min-height: 64px;
    max-height: 160px;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    font: inherit;
    font-size: 15px;
}

.chat-send-button {
    min-height: 64px;
    font-size: 16px;
}

@media (max-width: 960px) {
    .chat-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .chat-sidebar {
        order: 2;
    }

    .chat-main {
        min-height: 70vh;
    }
}

@media (max-width: 860px) {
    .login-actions,
    .chat-input-panel {
        grid-template-columns: 1fr;
        display: grid;
    }

    .msg-bubble {
        max-width: 88%;
    }
}

.simple-login-page,
.simple-chat-page {
    min-height: 100vh;
    padding: 24px;
}

.simple-login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.simple-login-wrap {
    width: 100%;
    max-width: 460px;
}

.simple-login-card {
    padding: 28px;
}

.simple-login-card h1 {
    margin: 0 0 18px;
    font-size: 36px;
    font-weight: 800;
}

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

.simple-login-form input {
    width: 100%;
    min-height: 58px;
    padding: 12px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 24px;
}

.simple-login-form input:focus,
.simple-chat-inputbar input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(213, 141, 23, 0.16);
}

.simple-login-error {
    padding: 10px 12px;
    border-radius: 10px;
    background: #ffefef;
    color: #a82222;
    border: 1px solid #f2c0c0;
    font-size: 14px;
    font-weight: 700;
}

.simple-main-button {
    min-height: 56px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(0deg, #f0c66a 0%, #f7d98f 100%);
    color: #6d470f;
    font: inherit;
    font-size: 24px;
    font-weight: 800;
    cursor: pointer;
}

.simple-chat-shell {
    width: min(980px, 100%);
    min-height: calc(100vh - 48px);
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
}

.simple-chat-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid #efe5d5;
    background: #fffdfa;
}

.simple-chat-title {
    font-size: 28px;
    font-weight: 800;
}

.simple-chat-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.simple-chat-link,
.simple-chat-link-button {
    color: #8d5e12;
    background: none;
    border: none;
    padding: 0;
    text-decoration: none;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.simple-chat-messages {
    padding: 18px;
    overflow-y: auto;
    background: #fffaf1;
}

.simple-msg-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.simple-msg-row.mine {
    align-items: flex-end;
}

.simple-msg-row.other {
    align-items: flex-start;
}

.simple-msg-row.system {
    align-items: center;
}

.simple-msg-name {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
}

.simple-msg-bubble {
    max-width: 76%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
}

.simple-msg-row.other .simple-msg-bubble {
    background: #ffffff;
    border: 1px solid #e6dccb;
    border-top-left-radius: 6px;
}

.simple-msg-row.mine .simple-msg-bubble {
    background: #eaf8d0;
    border: 1px solid #cfe9aa;
    border-top-right-radius: 6px;
}

.simple-system-msg {
    padding: 8px 12px;
    border-radius: 999px;
    background: #f5edd7;
    color: #856036;
    font-size: 13px;
}

.simple-chat-inputbar {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
    padding: 16px 18px;
    border-top: 1px solid #efe5d5;
    background: #fffdfa;
}

.simple-chat-inputbar input {
    width: 100%;
    min-height: 54px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    font: inherit;
    font-size: 18px;
}

@media (max-width: 700px) {
    .simple-chat-topbar,
    .simple-chat-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .simple-chat-inputbar {
        grid-template-columns: 88px minmax(0, 1fr) 120px;
    }

    .simple-msg-bubble {
        max-width: 90%;
    }
}

.simple-extend-button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #e0bd78;
    border-radius: 10px;
    background: #fff4d7;
    color: #825512;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.simple-extend-button:hover {
    background: #ffe9ad;
}

.simple-extend-button.active {
    background: #eaf7d5;
    border-color: #bdd58e;
    color: #4b6924;
}

/* V5.11 chat stability / mobile keyboard / new-message indicator */
.simple-chat-page {
    height: var(--chat-viewport-height, 100dvh);
    min-height: 0;
    overflow: hidden;
}

.simple-chat-shell {
    position: relative;
    height: 100%;
    min-height: 0;
}

.simple-chat-messages {
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.simple-msg-name {
    opacity: 0.86;
}

.new-message-indicator {
    position: absolute;
    left: 50%;
    bottom: 92px;
    z-index: 20;
    transform: translateX(-50%);
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid #d9b66f;
    border-radius: 999px;
    background: #fff3d2;
    color: #7c5012;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 5px 18px rgba(93, 59, 13, 0.15);
}

.new-message-indicator[hidden] {
    display: none;
}

@media (max-width: 700px) {
    .simple-chat-page {
        padding: 0;
        height: var(--chat-viewport-height, 100dvh);
    }

    .simple-chat-shell {
        width: 100%;
        height: 100%;
        min-height: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .simple-chat-topbar {
        padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    }

    .simple-chat-actions {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }

    .simple-chat-inputbar {
        grid-template-columns: minmax(0, 1fr) 86px;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    .simple-chat-inputbar input {
        min-width: 0;
        min-height: 48px;
        font-size: 16px;
    }

    .simple-chat-inputbar .simple-main-button {
        min-height: 48px;
        font-size: 17px;
        border-radius: 12px;
    }

    .simple-chat-messages {
        padding: 12px;
    }

    .new-message-indicator {
        bottom: 76px;
    }
}

.simple-push-button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #d4c7ac;
    border-radius: 10px;
    background: #fffdfa;
    color: #765938;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.simple-push-button:hover {
    background: #fff5df;
}

.simple-push-button.active {
    background: #eaf7d5;
    border-color: #bdd58e;
    color: #4b6924;
}

.simple-push-button.error {
    background: #f7eded;
    border-color: #dfb8b8;
    color: #8a4444;
}

.simple-push-button:disabled {
    opacity: 0.65;
    cursor: wait;
}


.heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.home-push-button {
    min-height: 40px;
    padding: 9px 14px;
}

@media (max-width: 860px) {
    .heading-actions {
        width: 100%;
        justify-content: flex-start;
    }
}


.secret-dot-button {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.chat-login-modal[hidden] {
    display: none !important;
}

.chat-login-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 18px;
}

.chat-login-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(38, 31, 24, 0.34);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.chat-login-dialog {
    position: relative;
    z-index: 1;
    width: min(340px, calc(100vw - 36px));
    padding: 18px;
}

.home-chat-login-form,
.simple-login-form {
    display: grid;
    gap: 12px;
}

.home-chat-login-form input,
.simple-login-form input {
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    border: 1px solid #cdbf9f;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fffdfa;
    color: #3f3428;
    font: inherit;
    font-size: 18px;
    outline: none;
}

.home-chat-login-form input:focus,
.simple-login-form input:focus {
    border-color: #b77208;
    box-shadow: 0 0 0 3px rgba(183, 114, 8, 0.12);
}

.home-chat-login-actions,
.simple-login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.simple-secondary-button {
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid #d4c7ac;
    border-radius: 10px;
    background: #fffdfa;
    color: #765938;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.simple-secondary-button:hover {
    background: #fff5df;
}

body.chat-login-open {
    overflow: hidden;
}


/* V5.21 stickers */
.sticker-toggle-button {
    min-height: 54px;
    border-radius: 14px;
    white-space: nowrap;
}

.sticker-toggle-button.active {
    background: #fff0bf;
    border-color: #ddb56e;
    color: #7a5317;
}

.sticker-panel {
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid #efe5d5;
    background: #fff8ef;
}

.sticker-panel[hidden] {
    display: none;
}

.sticker-category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.sticker-category-button {
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #dac8a2;
    border-radius: 999px;
    background: #fff;
    color: #7c5a25;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.sticker-category-button.active {
    background: #ffe9ad;
    border-color: #d8aa4c;
    color: #6e470f;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
    max-height: 238px;
    overflow-y: auto;
    padding-right: 2px;
}

.sticker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 76px;
    padding: 6px;
    border: 1px solid #ead9b7;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
}

.sticker-item:hover {
    background: #fff7df;
    border-color: #dcb263;
}

.sticker-item img {
    display: block;
    width: 100%;
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
}

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

.simple-msg-sticker {
    padding: 2px 0;
    background: transparent;
    border: none;
}

.simple-msg-sticker-image {
    display: block;
    max-width: 160px;
    max-height: 160px;
    width: auto;
    height: auto;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06));
}

@media (max-width: 700px) {
    .simple-chat-inputbar {
        grid-template-columns: 72px minmax(0, 1fr) 86px;
    }

    .sticker-toggle-button {
        min-height: 48px;
        padding: 6px 8px;
    }

    .sticker-grid {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
        max-height: 210px;
    }

    .simple-msg-sticker-image {
        max-width: 132px;
        max-height: 132px;
    }
}


/* V5.22 read receipts */
.simple-msg-read-state {
    font-weight: 800;
}

.simple-msg-row.mine.is-read .simple-msg-read-state {
    color: #6e8f3d;
}


/* V5.23 privacy shield */
html.chat-privacy-exit .simple-chat-shell {
    visibility: hidden !important;
    opacity: 0 !important;
}


/* V5.29 normal-cover hold-to-view privacy mode */
.simple-chat-shell {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}


.chat-message-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #fffaf1;
}

.chat-message-stage .simple-chat-messages {
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* Private by default: chat pixels exist for fast reveal, but are not painted. */
body:not(.chat-peek-active) .chat-message-stage .simple-chat-messages {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

body.chat-peek-active .chat-message-stage .simple-chat-messages {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.chat-hold-cover {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #f5efe8;
    color: #735b43;
    text-align: center;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

body.chat-peek-active .chat-hold-cover {
    /* V5.36: keep the cover rendered so iPhone does not lose the captured
       first finger, but make it transparent and non-interactive so a second
       finger reaches the message list / extension button underneath. */
    opacity: 0;
    visibility: visible;
    pointer-events: none;
}

.chat-hold-cover-inner {
    max-width: 360px;
    padding: 20px 22px;
    border: 1px solid #dfd0b8;
    border-radius: 16px;
    background: #fffaf1;
}

.chat-hold-cover-title {
    font-size: 20px;
    font-weight: 900;
    color: #5f4933;
}

.chat-hold-cover-note {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
    color: #8b7258;
}

body:not(.chat-peek-active) .new-message-indicator {
    visibility: hidden !important;
}

@media (max-width: 700px) {
    .simple-chat-topbar {
        align-items: stretch;
    }

    .simple-chat-actions {
        justify-content: center;
    }

    .chat-hold-cover {
        padding: 16px;
    }
}


/* V5.24 covered state shows only a harmless compact exchange rate. */
.chat-rate-cover {
    min-width: min(300px, 86vw);
    padding: 22px 24px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.chat-rate-cover:active {
    transform: scale(0.985);
    box-shadow: 0 3px 14px rgba(95, 73, 51, 0.10);
}

.chat-rate-cover:focus-visible {
    outline: 2px solid #c58a31;
    outline-offset: 3px;
}

.chat-rate-cover-label {
    color: #92795f;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

.chat-rate-cover-value {
    margin-top: 7px;
    color: #5f4933;
    font-size: 22px;
    font-weight: 800;
    white-space: nowrap;
}

.chat-rate-cover-value strong {
    color: #9a6208;
    font-size: 28px;
}

@media (max-width: 700px) {
    .chat-rate-cover {
        min-width: min(270px, 86vw);
        padding: 18px 20px;
    }

    .chat-rate-cover-value {
        font-size: 19px;
    }

    .chat-rate-cover-value strong {
        font-size: 24px;
    }
}

/* V5.29 normal-looking calculator cover */
.chat-normal-cover {
    z-index: 40;
    display: block;
    padding: 0;
    overflow-y: auto;
    background: var(--bg);
    color: var(--text);
    text-align: left;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.chat-decoy-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px 18px;
    background: linear-gradient(0deg, var(--header) 0%, #c37a09 100%);
    border-top: 5px solid var(--header-dark);
    color: #fffaf1;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.chat-decoy-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    width: min(920px, 100%);
    margin: 0 auto;
}

.chat-decoy-brand-mark {
    flex: 0 0 68px;
    transform: scale(0.82);
    transform-origin: left center;
    margin-right: -10px;
}

.chat-decoy-title {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
}

.chat-decoy-subtitle {
    margin-top: 4px;
    font-size: 13px;
    opacity: 0.95;
}

.chat-decoy-content {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 28px;
}

.chat-decoy-converter-card,
.chat-decoy-rate-card,
.chat-decoy-note {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.chat-decoy-converter-card {
    padding: 20px;
}

.chat-decoy-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.chat-decoy-heading-title {
    font-size: 24px;
    font-weight: 800;
}

.chat-decoy-heading-note {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.chat-decoy-converter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.chat-decoy-currency-box {
    min-height: 132px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card-soft);
}

.chat-decoy-flag {
    font-size: 30px;
    line-height: 1;
}

.chat-decoy-currency-label {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.chat-decoy-fake-input,
.chat-decoy-result {
    margin-top: 8px;
    min-height: 48px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: #fff;
    color: var(--text);
    font-size: 24px;
    font-weight: 800;
}

.chat-decoy-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: 800;
    color: #b37717;
}

.chat-decoy-rate-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin-top: 16px;
    padding: 18px 20px;
    text-align: left;
    cursor: default;
    touch-action: auto;
}

.chat-decoy-rate-title {
    margin-bottom: 7px;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
}

.chat-decoy-rate-card .chat-rate-cover-value {
    margin-top: 0;
    color: var(--text);
    font-size: 22px;
}

.chat-decoy-rate-card .chat-rate-cover-value strong {
    color: #9a6208;
    font-size: 27px;
}

.chat-decoy-rate-secondary {
    margin-top: 8px;
    color: #5f4933;
    font-size: 16px;
    font-weight: 700;
}

.chat-decoy-rate-secondary strong {
    color: #9a6208;
}

.chat-decoy-rate-status {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.chat-decoy-note {
    margin-top: 16px;
    padding: 13px 15px;
    background: var(--card-soft);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    box-shadow: none;
}

@media (max-width: 700px) {
    .chat-decoy-header {
        padding: 10px 12px;
        border-top-width: 4px;
    }

    .chat-decoy-brand {
        gap: 8px;
    }

    .chat-decoy-brand-mark {
        flex-basis: 52px;
        transform: scale(0.64);
        margin-right: -16px;
    }

    .chat-decoy-title {
        font-size: 19px;
    }

    .chat-decoy-subtitle {
        font-size: 11px;
    }

    .chat-decoy-content {
        width: calc(100% - 20px);
        padding: 12px 0 max(18px, env(safe-area-inset-bottom));
    }

    .chat-decoy-converter-card {
        padding: 14px;
        border-radius: 14px;
    }

    .chat-decoy-heading {
        margin-bottom: 12px;
    }

    .chat-decoy-heading-title {
        font-size: 20px;
    }

    .chat-decoy-heading-note {
        font-size: 11px;
    }

    .chat-decoy-converter-grid {
        grid-template-columns: 1fr 34px 1fr;
        gap: 7px;
    }

    .chat-decoy-currency-box {
        min-height: 118px;
        padding: 11px;
    }

    .chat-decoy-flag {
        font-size: 25px;
    }

    .chat-decoy-currency-label {
        font-size: 11px;
    }

    .chat-decoy-fake-input,
    .chat-decoy-result {
        min-height: 43px;
        padding: 8px 9px;
        font-size: 19px;
    }

    .chat-decoy-arrow {
        font-size: 21px;
    }

    .chat-decoy-rate-card {
        margin-top: 12px;
        padding: 15px 16px;
        border-radius: 14px;
    }

    .chat-decoy-rate-title {
        font-size: 16px;
    }

    .chat-decoy-rate-card .chat-rate-cover-value {
        font-size: 18px;
    }

    .chat-decoy-rate-card .chat-rate-cover-value strong {
        font-size: 23px;
    }

    .chat-decoy-rate-secondary {
        font-size: 14px;
    }

    .chat-decoy-note {
        margin-top: 12px;
    }
}


/* V5.29 persistent calculator-looking composer.
   The real chat input remains usable while private message history stays covered. */
.simple-chat-inputbar.chat-decoy-composer {
    position: relative;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 54px 92px;
    gap: 8px;
    align-items: stretch;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: #fffdfa;
    box-shadow: 0 -5px 18px rgba(75, 52, 25, 0.06);
}

.chat-decoy-composer-field {
    min-width: 0;
    padding: 7px 10px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
}

.chat-decoy-composer-label {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
}

.chat-decoy-sticker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.chat-decoy-sticker-trigger.active {
    color: #9a6208;
}

.chat-decoy-sticker-trigger:focus-visible {
    outline: 2px solid #d7a53c;
    outline-offset: 2px;
    border-radius: 6px;
}

.simple-chat-inputbar.chat-decoy-composer input {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    box-shadow: none;
    outline: none;
    font: inherit;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
}

.simple-chat-inputbar.chat-decoy-composer input:focus {
    border: 0;
    box-shadow: none;
    outline: none;
}

.simple-chat-inputbar.chat-decoy-composer input::placeholder {
    color: #a49380;
    font-size: 16px;
    font-weight: 600;
}

.chat-decoy-swap-button,
.chat-decoy-convert-button {
    min-height: 52px;
    border-radius: 12px;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.chat-decoy-swap-button {
    border: 1px solid #d8c8aa;
    background: #fff8e9;
    color: #9a6208;
    font-size: 26px;
    line-height: 1;
}

.chat-decoy-swap-button.active {
    background: #fff0bf;
    border-color: #ddb56e;
}

.chat-decoy-convert-button {
    border: 1px solid #d8ab53;
    background: linear-gradient(0deg, #f0c66a 0%, #f7d98f 100%);
    color: #6d470f;
    font-size: 16px;
}

.chat-decoy-swap-button:disabled,
.chat-decoy-convert-button:disabled {
    opacity: .55;
    cursor: default;
}

/* Keep the sticker picker above the calculator cover when intentionally opened. */
.sticker-panel {
    position: relative;
    z-index: 45;
}

/* While holding the rate card, reveal only the conversation area.  The
   calculator-looking composer intentionally stays on top and remains unchanged. */
body.chat-peek-active .simple-chat-inputbar.chat-decoy-composer {
    z-index: 40;
}

@media (max-width: 700px) {
    .simple-chat-inputbar.chat-decoy-composer {
        grid-template-columns: minmax(0, 1fr) 48px 76px;
        gap: 7px;
        padding: 8px 9px max(8px, env(safe-area-inset-bottom));
    }

    .chat-decoy-composer-field {
        padding: 6px 9px 7px;
        border-radius: 11px;
    }

    .simple-chat-inputbar.chat-decoy-composer input {
        min-height: 26px;
        font-size: 18px;
    }

    .simple-chat-inputbar.chat-decoy-composer input::placeholder {
        font-size: 14px;
    }

    .chat-decoy-swap-button,
    .chat-decoy-convert-button {
        min-height: 48px;
        border-radius: 11px;
    }

    .chat-decoy-swap-button {
        font-size: 24px;
    }

    .chat-decoy-convert-button {
        font-size: 14px;
    }
}

.secret-rate-chip {
    border: 1px solid var(--line-strong);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.secret-rate-chip:focus-visible {
    outline: 2px solid #d0a44c;
    outline-offset: 2px;
}

.secret-rate-chip-armed {
    box-shadow: 0 0 0 2px rgba(183, 114, 8, 0.18);
    border-color: #c48a1d;
}

.secret-dot-armed {
    box-shadow: 0 0 0 3px rgba(255, 243, 196, 0.65);
}


/* V5.36: the ONLY hold-to-view target is the first literal "1" under
   「目前匯率」.  It looks exactly like text; the rest of the card has no
   active/press behavior. */
.chat-rate-one-hold {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -12px -14px;
    padding: 12px 14px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    line-height: inherit;
    vertical-align: baseline;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-rate-one-hold:active {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.chat-rate-one-hold:focus-visible {
    outline: 1px solid rgba(183, 114, 8, 0.35);
    outline-offset: 1px;
}

body.chat-peek-active .chat-rate-one-hold {
    pointer-events: none;
}

body.chat-peek-active .simple-chat-messages {
    touch-action: pan-y;
}


/* V5.37 iOS two-finger manual scroll */
body.chat-peek-active .simple-chat-messages {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* V5.39: prevent long-press text selection while peeking at chat.
   Keep the composer input selectable/editable. */
body.chat-peek-active .simple-chat-messages,
body.chat-peek-active .simple-chat-messages *,
body.chat-peek-active .simple-msg-row,
body.chat-peek-active .simple-msg-name,
body.chat-peek-active .simple-msg-bubble {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
}

body.chat-peek-active .simple-chat-messages {
    touch-action: pan-y !important;
}

.simple-chat-inputbar input {
    user-select: text;
    -webkit-user-select: text;
}


/* V5.40: easier hold target, LINE-like reply, and text+sticker composer. */
.simple-msg-content-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 86%;
}
.simple-msg-row.mine .simple-msg-content-wrap { justify-content: flex-end; }
.simple-msg-row.other .simple-msg-content-wrap { justify-content: flex-start; }
.simple-msg-content-wrap .simple-msg-bubble { max-width: 100%; }
.simple-msg-reply-button {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #dfd3c1;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    color: #80694e;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.simple-msg-reply-preview {
    max-width: 72%;
    margin-bottom: 4px;
    padding: 6px 9px;
    border-left: 3px solid #c8ad7a;
    border-radius: 7px;
    background: rgba(239,231,214,0.74);
    color: #6f604e;
    font-size: 11px;
    line-height: 1.35;
}
.simple-msg-reply-preview strong,
.simple-msg-reply-preview span { display: block; }
.simple-msg-reply-preview span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.simple-msg-combo {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.simple-msg-inline-sticker {
    width: 64px;
    height: 64px;
    object-fit: contain;
    flex: 0 0 auto;
}
.chat-composer-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-composer-input-row input { flex: 1 1 auto; }
.composer-sticker-preview {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
}
.composer-sticker-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.composer-sticker-preview button,
.reply-compose-preview button {
    border: 0;
    background: transparent;
    color: #7d6a54;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}
.composer-sticker-preview button {
    position: absolute;
    right: -5px;
    top: -7px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.reply-compose-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    padding: 5px 7px;
    border-left: 3px solid #c8ad7a;
    border-radius: 6px;
    background: #f6efe1;
    color: #75634d;
    font-size: 11px;
}
.reply-compose-preview[hidden], .composer-sticker-preview[hidden] { display: none !important; }
/* Never expose reply text while the privacy cover is closed. */
body:not(.chat-peek-active) .reply-compose-preview { display: none !important; }

/* V5.41: only the visible 「快速換算」 title is the hold-to-view trigger. */
.chat-quick-hold-target {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 44px;
    margin: -8px -10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-quick-hold-target:active {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.chat-quick-hold-target:focus-visible {
    outline: 1px solid rgba(183, 114, 8, 0.35);
    outline-offset: 2px;
}

body.chat-peek-active .chat-quick-hold-target {
    pointer-events: none;
}


/* V5.42 image sending */
.composer-image-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-left: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
    flex: 0 0 auto;
}

.composer-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.composer-image-preview button {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 999px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    line-height: 1;
    cursor: pointer;
}

.simple-msg-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.simple-msg-row.mine .simple-msg-stack {
    align-items: flex-end;
}

.simple-msg-upload {
    max-width: min(240px, 72vw);
}

.simple-msg-upload-image {
    display: block;
    max-width: 100%;
    max-height: 280px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    background: #fff;
}


/* V5.43: first "1" is the hold trigger again, with a much larger invisible hit area. */
.chat-first-one-wrap {
    position: relative;
    display: inline-block;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.chat-first-one-hit {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    width: 64px;
    height: 64px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: transparent;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-first-one-hit:active,
.chat-first-one-hit:focus {
    background: transparent;
    box-shadow: none;
    outline: none;
}

.chat-first-one-hit:focus-visible {
    outline: 1px solid rgba(183, 114, 8, 0.28);
    outline-offset: -8px;
}

body.chat-peek-active .chat-first-one-hit {
    pointer-events: none;
}

/* V5.45: disguise the image attachment controls so they still look like part
   of the calculator UI, and never show a broken-image label such as 「圖片」. */
.chat-decoy-attach-button {
    position: relative;
    overflow: hidden;
}

.chat-decoy-attach-button .chat-decoy-attach-glyph {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.chat-decoy-attach-button .chat-decoy-attach-glyph::before {
    content: "";
    position: absolute;
    inset: 2px;
    border: 2px solid #a77a24;
    border-radius: 4px;
    background: linear-gradient(180deg, #fffaf0 0%, #f8edd5 100%);
}

.chat-decoy-attach-button .chat-decoy-attach-glyph::after {
    content: "";
    position: absolute;
    left: 7px;
    right: 7px;
    bottom: 7px;
    height: 7px;
    background: linear-gradient(135deg, transparent 0 22%, #a77a24 23% 48%, transparent 49%),
                linear-gradient(45deg, transparent 0 34%, #d0a44c 35% 60%, transparent 61%);
    border-radius: 2px;
}

.chat-decoy-attach-indicator {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #89b649;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.95);
}

.chat-decoy-attach-button.active {
    background: #fff0bf;
    border-color: #ddb56e;
}

.chat-composer-input-row {
    min-width: 0;
}

.chat-composer-input-row input {
    min-width: 0;
}

.composer-image-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-left: 2px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(167, 122, 36, 0.22);
    background: linear-gradient(180deg, #fffdfa 0%, #f4ecdf 100%);
    flex: 0 0 auto;
}

.composer-image-preview::before {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 7px;
    background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(250,242,225,0.92) 100%);
}

.composer-image-preview::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 12px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -40%);
    border-radius: 2px;
    background: linear-gradient(135deg, transparent 0 24%, #b78c39 25% 52%, transparent 53%),
                linear-gradient(45deg, transparent 0 34%, #dec07b 35% 63%, transparent 64%);
    opacity: 0.65;
}

.composer-image-preview img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: transparent;
}

.composer-image-preview.is-fallback img {
    opacity: 0;
}

.composer-image-preview button {
    z-index: 2;
    top: 1px;
    right: 1px;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 999px;
    background: rgba(74, 58, 33, 0.78);
    color: #fff;
    line-height: 1;
    cursor: pointer;
}

.composer-image-preview[hidden] {
    display: none !important;
}


/* V5.45.1: image attachment stays visually disguised as the normal currency-swap control. */
.chat-decoy-attach-button .chat-decoy-attach-glyph {
    width: auto;
    height: auto;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}
.chat-decoy-attach-button .chat-decoy-attach-glyph::before,
.chat-decoy-attach-button .chat-decoy-attach-glyph::after {
    content: none !important;
    display: none !important;
}
.chat-decoy-attach-indicator {
    right: 5px;
    top: 5px;
    width: 7px;
    height: 7px;
    background: #8faa55;
}
.composer-image-preview {
    display: none !important;
}


/* V5.49 - iPhone software-keyboard viewport fix.
   WebKit can pan the layout viewport while the keyboard is animating. Keep
   the chat shell pinned to the actual VisualViewport and reserve the bottom
   strip for the calculator-looking composer. */
@media (max-width: 700px) {
    body.simple-chat-page.chat-keyboard-open {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: var(--chat-viewport-top, 0px) !important;
        width: 100% !important;
        height: var(--chat-viewport-height, 100dvh) !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.chat-keyboard-open .simple-chat-shell {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        margin: 0 !important;
    }

    body.chat-keyboard-open .simple-chat-inputbar.chat-decoy-composer {
        position: relative !important;
        z-index: 100 !important;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        background: #fffdfa !important;
    }

    /* The privacy cover may hide the conversation while typing, but it must
       never paint over the input row itself on iPhone. */
    body.chat-keyboard-open .chat-hold-cover {
        bottom: var(--chat-composer-height, 76px) !important;
    }

    body.chat-keyboard-open .chat-decoy-composer-field,
    body.chat-keyboard-open .chat-composer-input-row,
    body.chat-keyboard-open #chat-input {
        position: relative;
        z-index: 101;
    }

    body.chat-keyboard-open #chat-input {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        -webkit-text-fill-color: currentColor;
    }
}


/* V5.51: full-screen black image viewer for sent/received chat images. */
.simple-msg-upload-open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 14px;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

.simple-msg-upload-open:focus-visible {
    outline: 2px solid rgba(183, 114, 8, 0.34);
    outline-offset: 2px;
}

.chat-image-viewer[hidden] {
    display: none !important;
}

.chat-image-viewer {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.96);
}

.chat-image-viewer-backdrop {
    position: absolute;
    inset: 0;
}

.chat-image-viewer-body {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-image-viewer-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    background: transparent;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.chat-image-viewer-close {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 2;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(2px);
}

body.chat-image-viewer-open {
    overflow: hidden !important;
    touch-action: none;
}


/* V5.52 message recall */
.simple-msg-action-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}


.simple-msg-recalled {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 12px;
    border: 1px dashed rgba(115, 102, 83, 0.24);
    background: rgba(245, 241, 234, 0.76);
    color: #8a8175;
    font-size: 13px;
    font-style: italic;
}

.simple-msg-row.recalled .simple-msg-content-wrap {
    opacity: 0.88;
}

.simple-msg-reply-preview.recalled span {
    color: #8a8175;
    font-style: italic;
}


/* V5.53: recall is hidden behind a long press on your own message. */
.simple-msg-row.mine[data-recallable="1"] .simple-msg-bubble,
.simple-msg-row.mine[data-recallable="1"] .simple-msg-sticker,
.simple-msg-row.mine[data-recallable="1"] .simple-msg-upload {
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.simple-msg-row.mine.recall-holding .simple-msg-bubble,
.simple-msg-row.mine.recall-holding .simple-msg-sticker,
.simple-msg-row.mine.recall-holding .simple-msg-upload {
    transform: scale(0.985);
    opacity: 0.86;
}
