/* ============================================================
   AKH 午餐 — 設計系統「暖食堂」
   米紙暖底 × 柿橙主色 × 楷體標題
   Light / Dark 由 <html data-theme="light|dark"> 控制
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    /* 品牌色階(柿橙) */
    --brand-300: #fbbf6b;
    --brand-400: #f59e0b;
    --brand-500: #d97706;
    --brand-600: #b45309;
    --brand-700: #92400a;

    /* 語意色 — Light */
    --bg: #faf7f1;
    --bg-texture: radial-gradient(rgba(146, 64, 10, 0.05) 1px, transparent 1px);
    --surface: #fffdf9;
    --surface-2: #f5f0e6;
    --surface-3: #ece5d8;
    --ink: #292524;
    --ink-soft: #57534e;
    --ink-faint: #8f8880;
    --line: #e5ddd0;
    --line-strong: #d6ccbb;

    --primary: var(--brand-500);
    --primary-strong: var(--brand-600);
    --primary-soft: #fdf0dd;
    --on-primary: #fffdf9;
    --primary-gradient: linear-gradient(135deg, #e8850c 0%, #c2570b 100%);

    --success: #3f6c3a;
    --success-soft: #e8f0e3;
    --danger: #b3372b;
    --danger-soft: #fae7e2;
    --warning: #9a6a00;
    --warning-soft: #faf1d7;

    --focus-ring: 0 0 0 3px rgba(217, 119, 6, 0.28);
    --shadow-sm: 0 1px 2px rgba(70, 45, 15, 0.06), 0 1px 6px rgba(70, 45, 15, 0.05);
    --shadow-md: 0 2px 6px rgba(70, 45, 15, 0.06), 0 10px 28px rgba(70, 45, 15, 0.09);
    --shadow-lg: 0 4px 10px rgba(70, 45, 15, 0.07), 0 24px 48px rgba(70, 45, 15, 0.12);

    /* 字體 */
    --font-display: "LXGW WenKai TC", "Noto Sans TC", serif;
    --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;

    /* 幾何 */
    --radius-sm: 0.5rem;
    --radius-md: 0.85rem;
    --radius-lg: 1.25rem;
    --speed: 0.22s;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #171310;
    --bg-texture: radial-gradient(rgba(245, 158, 11, 0.045) 1px, transparent 1px);
    --surface: #211c17;
    --surface-2: #2a241e;
    --surface-3: #342d25;
    --ink: #ede5d8;
    --ink-soft: #b7ac9d;
    --ink-faint: #857b6d;
    --line: #383027;
    --line-strong: #4a4034;

    --primary: var(--brand-400);
    --primary-strong: #fbbf24;
    --primary-soft: #33261263;
    --on-primary: #1e1503;
    --primary-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);

    --success: #96c48c;
    --success-soft: #22301f;
    --danger: #eb9a8b;
    --danger-soft: #3a221d;
    --warning: #e5c26a;
    --warning-soft: #352b13;

    --focus-ring: 0 0 0 3px rgba(245, 158, 11, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 6px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 10px rgba(0, 0, 0, 0.4), 0 24px 48px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

html, body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background-color: var(--bg);
    background-image: var(--bg-texture);
    background-size: 22px 22px;
    transition: background-color var(--speed) ease, color var(--speed) ease;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 0.5rem;
    color: var(--ink);
}

h1:focus {
    outline: none;
}

p {
    margin: 0 0 0.75rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--speed) ease;
}

a:hover {
    color: var(--primary-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
}

code {
    color: var(--danger);
    background: var(--surface-2);
    padding: 0.1em 0.35em;
    border-radius: 0.3em;
    font-size: 0.9em;
}

::selection {
    background: rgba(217, 119, 6, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- 進場動畫 ---------- */
@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- 按鈕 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.35rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--speed) ease, box-shadow var(--speed) ease,
                background var(--speed) ease, border-color var(--speed) ease,
                color var(--speed) ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    text-decoration: none;
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary,
.auth-submit {
    color: var(--on-primary);
    background: var(--primary-gradient);
    border: none;
    padding: 0.7rem 1.5rem;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.28);
}

.btn-primary:hover:enabled,
a.auth-submit:hover,
.auth-submit:hover:enabled {
    color: var(--on-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.36);
    filter: brightness(1.05);
}

.btn-secondary {
    background: transparent;
}

.btn-danger {
    color: #fff;
    background: var(--danger);
    border: none;
}

.btn-danger:hover:enabled {
    color: #fff;
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.btn-block,
.auth-submit {
    width: 100%;
}

a.auth-submit {
    width: auto;
    display: inline-flex;
}

/* 圖示小按鈕(主題切換等) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    font-size: 1.1rem;
    color: var(--ink-soft);
    background: transparent;
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--speed) ease;
}

.btn-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: rotate(15deg) scale(1.06);
}

.btn-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ---------- 表單 ---------- */
.form-field {
    margin-bottom: 1.1rem;
}

.form-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius-md);
    transition: border-color var(--speed) ease, box-shadow var(--speed) ease,
                background var(--speed) ease;
    appearance: none;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.4rem;
}

.form-control::placeholder {
    color: var(--ink-faint);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-control:disabled {
    background: var(--surface-2);
    opacity: 0.7;
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--danger);
}

.validation-message {
    margin-top: 0.3rem;
    font-size: 0.83rem;
    color: var(--danger);
}

/* checkbox */
input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--primary);
    cursor: pointer;
}

/* 並排操作列(上一步 / 下一步) */
.form-actions {
    display: flex;
    gap: 0.85rem;
    margin-top: 1.25rem;
}

.form-actions .grow {
    flex: 1;
}

/* ---------- 提示 / Alert ---------- */
.alert {
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    animation: rise-in 0.25s ease both;
}

.alert-danger {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.alert-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 25%, transparent);
}

.alert-warning {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: color-mix(in srgb, var(--warning) 25%, transparent);
}

/* ---------- 卡片 ---------- */
.card,
.auth-card,
.home-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    transition: background var(--speed) ease, border-color var(--speed) ease;
}

.auth-card {
    max-width: 26rem;
    margin: 8vh auto 3rem;
    padding: 2.25rem 2rem;
    animation: rise-in 0.45s cubic-bezier(0.22, 0.8, 0.36, 1) both;
}

.auth-card-wide {
    max-width: 38rem;
}

.auth-card-full {
    max-width: 52rem;
    margin-top: 1rem;
}

.auth-title {
    font-size: 1.75rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.95rem;
    margin-bottom: 1.75rem;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.auth-hint {
    font-size: 0.85rem;
    color: var(--ink-faint);
}

.auth-result {
    text-align: center;
}

.auth-result-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    font-size: 1.6rem;
    border-radius: 999px;
    animation: rise-in 0.5s 0.1s ease both;
}

.auth-result-icon-success {
    color: var(--success);
    background: var(--success-soft);
}

.auth-result-icon-error {
    color: var(--danger);
    background: var(--danger-soft);
}

/* ---------- 首頁 ---------- */
.home {
    animation: rise-in 0.45s cubic-bezier(0.22, 0.8, 0.36, 1) both;
}

.home-greeting {
    font-size: clamp(1.7rem, 4.5vw, 2.4rem);
    margin-top: 1.5rem;
}

.home-subtitle {
    color: var(--ink-soft);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.home-card {
    animation: rise-in 0.45s 0.12s cubic-bezier(0.22, 0.8, 0.36, 1) both;
}

.home-card-title {
    font-size: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px dashed var(--line-strong);
}

.home-card-empty {
    color: var(--ink-soft);
}

/* ---------- 步驟指示器(wizard) ---------- */
.stepper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1.75rem;
}

.stepper-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    flex: none;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink-faint);
    background: var(--surface-2);
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    transition: all var(--speed) ease;
}

.stepper-dot.active {
    color: var(--on-primary);
    background: var(--primary-gradient);
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(217, 119, 6, 0.35);
}

.stepper-dot.done {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: var(--primary);
}

.stepper-line {
    flex: 1;
    height: 2px;
    background: var(--line);
    border-radius: 1px;
}

.stepper-line.done {
    background: var(--primary);
}

.step-heading {
    font-size: 1.35rem;
}

.step-caption {
    color: var(--ink-soft);
    margin-bottom: 1.5rem;
}

/* ---------- 摘要面板(確認頁、次要區塊) ---------- */
.panel {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
}

.panel h4 {
    font-size: 1.02rem;
    margin-bottom: 0.5rem;
}

.panel p {
    margin: 0.15rem 0;
    font-size: 0.93rem;
    color: var(--ink-soft);
}

.panel strong {
    color: var(--ink);
}

/* ---------- 訂餐頁 ---------- */
.order-header {
    margin-bottom: 1.25rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.order-restaurant {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.15rem;
}

.order-meal-date {
    display: inline-block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    margin-bottom: 0.35rem;
}

.order-deadline {
    color: var(--ink-soft);
    font-size: 0.92rem;
}

/* 額度橫幅 */
.quota-banner {
    padding: 1rem 1.25rem;
    margin: 0 auto 1.5rem;
    max-width: 560px;
    border-radius: var(--radius-md);
    border: 1px solid;
    animation: rise-in 0.4s ease both;
}

.quota-banner-ok {
    color: var(--success);
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.quota-banner-over {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.quota-banner .quota-title {
    font-weight: 700;
    font-size: 1.02rem;
}

.quota-banner .quota-detail {
    font-size: 0.9rem;
    opacity: 0.9;
}

.quota-banner .quota-over-note {
    margin: 0.4rem 0 0;
    font-weight: 700;
}

/* 兩欄:菜單 + 購物車 */
.order-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
    max-width: 560px;
    margin: 0 auto;
}

@media (min-width: 821px) {
}

.menu-section {
    margin-bottom: 1.5rem;
}

.menu-section-title {
    font-size: 1.1rem;
    color: var(--ink-soft);
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--line-strong);
    margin-bottom: 0.75rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--speed) ease, background var(--speed) ease,
                transform var(--speed) ease, box-shadow var(--speed) ease;
}

.menu-item:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.menu-item.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 3px 0 0 var(--primary);
}

.menu-item-name {
    flex: 1;
    min-width: 0;
}

.menu-item-price {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 購物車 */
.cart-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.25rem;
}

.cart-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.cart-list {
    max-height: 22rem;
    overflow-y: auto;
}

.cart-empty {
    color: var(--ink-faint);
    font-size: 0.92rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--line);
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.cart-item-price {
    display: block;
    font-size: 0.83rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.cart-remove {
    flex: none;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--danger);
    background: none;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--speed) ease, transform var(--speed) ease;
}

.cart-remove:hover {
    background: var(--danger-soft);
    transform: scale(1.1);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid var(--line-strong);
    font-weight: 700;
}

.cart-total-amount {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* ---------- 空狀態 / NotFound ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    animation: rise-in 0.45s ease both;
}

.empty-state-art {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 12vw, 6rem);
    line-height: 1.1;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
}

.empty-state p {
    color: var(--ink-soft);
    margin-bottom: 1.5rem;
}

/* 載入中文字 */
.loading-note {
    text-align: center;
    color: var(--ink-soft);
    padding: 2rem 0;
}

/* ---------- Blazor 框架 UI ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #333;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.blazor-error-boundary::after {
    content: "發生錯誤,請重新整理頁面。";
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 30vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--brand-500);
    stroke-linecap: round;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink-soft);
    inset: calc(30vh + 3.4rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading…");
}

/* ---- Order history ---- */
.order-card {
    max-width: 560px;
    margin: 0 auto 1rem;
}

.order-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.order-card-header h3 {
    margin: 0;
}

.order-status {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.order-status-active {
    background: color-mix(in srgb, #22c55e 18%, transparent);
    color: #16a34a;
}

.order-status-closed {
    background: color-mix(in srgb, #94a3b8 22%, transparent);
    color: #64748b;
}

.order-status-draft {
    background: color-mix(in srgb, #eab308 20%, transparent);
    color: #a16207;
}

.order-card-meta {
    font-size: 0.85rem;
    opacity: 0.75;
    margin: 0.25rem 0 0.75rem;
}

.order-card-items {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
}

.order-card-items li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px dashed color-mix(in srgb, currentColor 15%, transparent);
}

.order-card-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* ---- Menu editor (create lunch order) ---- */
.menu-editor-section {
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.menu-editor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.section-name-input {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.section-type-select {
    width: auto;
    flex-shrink: 0;
}

.menu-editor-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px dashed color-mix(in srgb, currentColor 12%, transparent);
}

.menu-editor-item-name {
    flex: 1;
}

.menu-editor-item-price {
    opacity: 0.8;
    white-space: nowrap;
}

.add-tile {
    display: block;
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.65rem;
    border: 2px dashed color-mix(in srgb, currentColor 30%, transparent);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    opacity: 0.65;
    cursor: pointer;
    font-size: 0.95rem;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.add-tile:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 5%, transparent);
}

.add-tile-lg {
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.icon-btn {
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.45;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.icon-btn:hover {
    opacity: 1;
    background: color-mix(in srgb, #ef4444 15%, transparent);
    color: #ef4444;
}

/* ---- Horizontal menu item cards ---- */
.menu-items-row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0 0.5rem;
    scrollbar-width: thin;
}

.menu-item-card {
    position: relative;
    flex: 0 0 auto;
    min-width: 96px;
    max-width: 160px;
    padding: 0.55rem 0.7rem;
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, currentColor 4%, transparent);
}

.menu-item-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    padding-right: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-item-card-price {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.15rem;
}

.menu-item-card-remove {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.35;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    border-radius: 5px;
}

.menu-item-card-remove:hover {
    opacity: 1;
    color: #ef4444;
}

.add-tile-card {
    flex: 0 0 auto;
    min-width: 64px;
    border: 2px dashed color-mix(in srgb, currentColor 30%, transparent);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.3rem;
    transition: opacity 0.15s, background 0.15s;
}

.add-tile-card:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 5%, transparent);
}

.menu-item-card-editing {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 140px;
    padding: 0.45rem 0.5rem;
    border: 2px dashed var(--primary);
    border-radius: 10px;
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.menu-item-card-editing input {
    width: 100%;
    padding: 0.3rem 0.45rem;
    font-size: 0.88rem;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
    color: inherit;
}

.menu-item-card-editing input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.menu-item-edit-actions {
    display: flex;
    gap: 0.35rem;
}

.menu-item-edit-actions button {
    border: none;
    border-radius: 6px;
    padding: 0.28rem 0.4rem;
    font-size: 0.82rem;
    cursor: pointer;
}

.menu-item-edit-confirm {
    flex: 1;
    background: var(--primary);
    color: var(--on-primary);
}

.menu-item-edit-confirm:hover {
    background: var(--primary-strong);
}

.menu-item-edit-cancel {
    background: transparent;
    color: inherit;
    opacity: 0.55;
}

.menu-item-edit-cancel:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
}

/* ---- Cart quantity ---- */
.cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.cart-qty-btn {
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cart-qty-btn:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
}

.cart-qty-num {
    min-width: 1.2rem;
    text-align: center;
    font-weight: 600;
}

/* ---- Participants status ---- */
.participants-panel {
    max-width: 560px;
    margin: 0 auto 1rem;
}

.participants-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

.participants-col h4 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    opacity: 0.75;
}

.participant {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    margin-bottom: 0.35rem;
    font-size: 0.92rem;
}

.participant-pending {
    background: color-mix(in srgb, #eab308 14%, transparent);
}

.participant-done {
    background: color-mix(in srgb, #22c55e 12%, transparent);
}

.participant-amount {
    font-size: 0.82rem;
    opacity: 0.7;
}

.participants-empty {
    font-size: 0.88rem;
    opacity: 0.6;
}

/* ---- Lunch order cards / home ---- */
.home-section-title {
    max-width: 560px;
    margin: 1.5rem auto 0.75rem;
    font-size: 1.05rem;
}

.lunch-card {
    max-width: 560px;
    margin: 0 auto 0.9rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    border-left-width: 4px;
}

.lunch-card-active {
    border-left-color: #22c55e;
}

.lunch-card-closed {
    border-left-color: #94a3b8;
    opacity: 0.75;
}

.lunch-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.lunch-card-header h3 {
    margin: 0;
}

.lunch-card-meal-date {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0.5rem 0 0;
}

.lunch-card-meta {
    font-size: 0.85rem;
    opacity: 0.7;
    margin: 0.3rem 0 0.75rem;
}

.lunch-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* 卡片按鈕：整顆換行、文字本身不斷行，並縮小內距讓多顆好並排 */
.lunch-card-actions .btn {
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

/* ---- Pager ---- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem auto;
}

.pager-info {
    opacity: 0.7;
    font-size: 0.9rem;
}

/* ---- User chip + debt badge ---- */
.app-user-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
}

.app-user-chip:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
}

.debt-badge {
    position: absolute;
    top: -0.35rem;
    left: -0.35rem;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---- Avatars ---- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar-md { width: 40px; height: 40px; font-size: 1rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }

.avatar-initials {
    color: #fff;
    font-weight: 700;
    user-select: none;
}

/* ---- Avatar groups (order status) ---- */
.avatar-group-title {
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
    opacity: 0.75;
}

.avatar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.avatar-wrap {
    position: relative;
    border-radius: 50%;
    padding: 2px;
}

.avatar-wrap-done { box-shadow: 0 0 0 2px #22c55e; }
.avatar-wrap-pending { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent); opacity: 0.6; }

.avatar-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    min-width: 180px;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    background: var(--surface, #fff);
    color: inherit;
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
    font-size: 0.85rem;
}

.avatar-wrap:hover .avatar-tooltip { display: block; }

.avatar-tooltip ul {
    list-style: none;
    padding: 0;
    margin: 0.35rem 0;
}

.avatar-tooltip li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.1rem 0;
    white-space: nowrap;
}

.avatar-tooltip-total {
    border-top: 1px dashed color-mix(in srgb, currentColor 20%, transparent);
    padding-top: 0.3rem;
    margin-top: 0.2rem;
    font-weight: 600;
}

/* ---- Member grid ---- */
.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.9rem;
    max-width: 780px;
    margin: 0 auto;
}

.member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.1rem 0.8rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
    text-align: center;
}

.member-card-disabled { opacity: 0.5; }

.member-card-name {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.member-role-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: color-mix(in srgb, #8b5cf6 18%, transparent);
    color: #8b5cf6;
}

.member-card-email {
    font-size: 0.78rem;
    opacity: 0.65;
    word-break: break-all;
}

.member-card-line {
    font-size: 0.78rem;
    opacity: 0.75;
}

/* ---- Profile ---- */
.profile-panel {
    max-width: 560px;
    margin: 0 auto 1rem;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-name { margin: 0; }
.profile-email { margin: 0.15rem 0 0; opacity: 0.65; font-size: 0.9rem; }

.profile-avatar-edit { position: relative; }

.profile-avatar-upload {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface, #fff);
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-sm { padding: 0.25rem 0.7rem; font-size: 0.85rem; }

/* ---- Order records ---- */
.record-card {
    max-width: 560px;
    margin: 0 auto 0.9rem;
}

.record-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.record-card-total {
    margin-left: auto;
    font-weight: 700;
}

.record-summary h4 { margin-top: 0; }

/* ---- Drink sugar/ice picker ---- */
.menu-section-hint {
    font-size: 0.78rem;
    opacity: 0.6;
    font-weight: 400;
}

.drink-picker {
    margin: 0.25rem 0 0.75rem;
    padding: 0.75rem;
    border: 1px dashed color-mix(in srgb, currentColor 30%, transparent);
    border-radius: 10px;
}

.drink-picker-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.drink-picker-label {
    font-size: 0.85rem;
    opacity: 0.7;
    min-width: 2.4rem;
}

.drink-chip {
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.drink-chip.active {
    background: color-mix(in srgb, #f97316 20%, transparent);
    border-color: #f97316;
    font-weight: 600;
}

.drink-picker-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.cart-item-custom {
    display: block;
    font-size: 0.78rem;
    opacity: 0.65;
}

/* ---- Frequent order templates ---- */
.frequent-orders {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.member-role-super {
    background: color-mix(in srgb, #f59e0b 20%, transparent);
    color: #d97706;
}

.menu-item-card-clickable {
    cursor: pointer;
}

.menu-item-card-clickable:hover {
    border-color: color-mix(in srgb, currentColor 40%, transparent);
    background: color-mix(in srgb, currentColor 8%, transparent);
}

/* ---- Deadline panel & skip badge ---- */
.deadline-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-top: 1px dashed color-mix(in srgb, currentColor 20%, transparent);
}

.avatar-wrap-skipped {
    box-shadow: 0 0 0 2px #94a3b8;
    opacity: 0.85;
}

.skip-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #94a3b8;
    color: #fff;
    font-size: 0.62rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ---- Board ---- */
.board-panel {
    max-width: 560px;
    margin: 0 auto 1rem;
}

.board-input {
    resize: vertical;
    width: 100%;
}

.board-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.board-message {
    max-width: 560px;
    margin: 0 auto 0.75rem;
}

.board-message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.board-message-time {
    font-size: 0.78rem;
    opacity: 0.55;
}

.board-message-header .icon-btn {
    margin-left: auto;
}

.board-message-content {
    margin: 0.5rem 0 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.home-board-preview {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.board-message-preview {
    opacity: 0.7;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-board-more {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    opacity: 0.6;
    text-align: right;
}

/* ---- Board reactions / replies / tags ---- */
.board-message-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.reaction-btn {
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.reaction-btn:hover {
    background: color-mix(in srgb, currentColor 7%, transparent);
}

.reaction-btn.active-like {
    background: color-mix(in srgb, #22c55e 18%, transparent);
    border-color: #22c55e;
}

.reaction-btn.active-dislike {
    background: color-mix(in srgb, #ef4444 15%, transparent);
    border-color: #ef4444;
}

.board-reply {
    margin-top: 0.6rem;
    margin-left: 1.6rem;
    padding-left: 0.9rem;
    border-left: 2px solid color-mix(in srgb, currentColor 15%, transparent);
}

.board-hashtag {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
}

.board-hashtag:hover { text-decoration: underline; }

.board-mention {
    color: #8b5cf6;
    font-weight: 600;
}

.board-filter {
    max-width: 560px;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0.85;
}

.board-my-post {
    padding: 0.6rem 0;
    border-bottom: 1px dashed color-mix(in srgb, currentColor 14%, transparent);
}

.member-card-admin-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}

.admin-links {
    display: flex;
    gap: 0.5rem;
}

/* ---- Composer tabs & auto-size textarea ---- */
.composer-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.composer-tab {
    border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0.7;
}

.composer-tab.active {
    background: color-mix(in srgb, #f97316 18%, transparent);
    border-color: #f97316;
    font-weight: 600;
    opacity: 1;
}

/* 隨內容自動調高，禁止手動拖拉 */
.board-input {
    resize: none;
    field-sizing: content;
    min-height: 3.2rem;
    max-height: 14rem;
    overflow-y: auto;
}

/* ---- Poll composer & display ---- */
.poll-option-input {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.45rem;
}

.poll-box {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.poll-option {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font-size: 0.92rem;
}

.poll-option:hover {
    border-color: #f97316;
}

.poll-option-mine {
    border-color: #f97316;
    font-weight: 600;
}

.poll-option-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: color-mix(in srgb, #f97316 16%, transparent);
    transition: width 0.25s;
    pointer-events: none;
}

.poll-option-label,
.poll-option-count {
    position: relative;
    z-index: 1;
}

.poll-option-count {
    font-size: 0.8rem;
    opacity: 0.7;
    white-space: nowrap;
}

.poll-total {
    opacity: 0.55;
    font-size: 0.78rem;
}

/* ---- Employee Zone link（Advantech 藍底白字、置右） ---- */
.app-nav {
    flex: 1;
    display: flex;
    align-items: center;
}

.app-link-ez {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1b4298;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.app-link-ez:hover {
    background: #143376;
    color: #fff;
}

/* ---- 首頁寬度一致（與 lunch-card 同 560px） ---- */
.home-card {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.home-board-stats {
    margin-left: auto;
    font-size: 0.78rem;
    opacity: 0.6;
    white-space: nowrap;
}

/* ---- Composer 即時提示 ---- */
.composer-hints {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
}

.hint-error {
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: 600;
}

.mention-unknown {
    color: #ef4444;
    text-decoration: line-through wavy;
}

/* ---- 首頁話題的最熱門回應 ---- */
.home-topic {
    padding: 0.35rem 0;
    border-bottom: 1px dashed color-mix(in srgb, currentColor 12%, transparent);
}

.home-topic:last-of-type {
    border-bottom: none;
}

.home-topic-reply {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0.35rem 0 0 1.6rem;
    font-size: 0.88rem;
    opacity: 0.85;
}

.home-topic-reply-arrow {
    opacity: 0.5;
}

.back-row {
    max-width: 560px;
    margin: 0 auto 0.75rem;
}

/* ---- Cart per-section subtotal ---- */
.cart-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    opacity: 0.65;
    margin-top: 0.6rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}

.cart-section-header:first-child {
    margin-top: 0;
}

.cart-section-subtotal {
    font-weight: 600;
}

/* ===== 訂單管理（Super-Admin 刪除） ===== */
.admin-orders-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.admin-orders-selectall {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.admin-orders-count {
    font-size: 0.88rem;
    color: var(--ink-soft);
    margin-right: auto;
}

.admin-order-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-order-check {
    flex: none;
    display: inline-flex;
    cursor: pointer;
}

.admin-order-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== 確認彈窗 ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.modal-card {
    position: fixed;
    z-index: 310;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 26rem);
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg, 1rem);
    box-shadow: var(--shadow-md);
}

.modal-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}
