/* ==================== 資料類型清單 ==================== */
/* 手機抽屜與電腦側欄：直接展開成清單；平板：下拉面板 */
.dropdown summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
                    min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
                    background: #fff; font-size: 15px; color: var(--fg); }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown summary::after { content: "▾"; color: var(--muted); margin-left: 8px; }
.dropdown[open] summary::after { content: "▴"; }
.dropdown-panel { margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.dropdown-actions { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.check-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 8px; max-height: 300px; overflow: auto; }
.check-list label { display: flex; gap: 8px; align-items: center; min-height: var(--tap); font-size: 15px; color: var(--fg); cursor: pointer; }
.check-list input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; }
@media (min-width: 600px) and (max-width: 1023.98px) {
  .dropdown { position: relative; }
  .dropdown-panel { position: absolute; z-index: 25; top: calc(100% + 4px); left: 0; width: 320px; max-width: 80vw; margin: 0;
                    box-shadow: 0 6px 20px rgba(0,0,0,.12); }
  .check-list { grid-template-columns: 1fr 1fr; }
}

/* ==================== 對話框與抽屜（原生 <dialog>） ==================== */
dialog.modal, dialog.drawer { border: 0; padding: 0; color: var(--fg); background: #fff; overscroll-behavior: contain; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
html.modal-open, html.modal-open body { overflow: hidden; }      /* 開啟時鎖住背景捲動 */

/* 手機：詳細與申請表單全螢幕 */
dialog.modal { width: 100%; max-width: 100%; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
               margin: 0; border-radius: 0; overflow: auto; }
/* 手機：抽屜從底部出現 */
dialog.drawer { width: 100%; max-width: 100%; max-height: 85vh; max-height: 85dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
dialog.drawer[open] { display: flex; flex-direction: column; }
.drawer-body { flex: 1 1 auto; overflow: auto; padding: 12px 20px; }
.drawer-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line);
               padding: 12px 20px calc(12px + var(--safe-bottom)); background: #fff; }

.modal-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; background: #fff;
             border-bottom: 1px solid var(--line); padding: calc(6px + var(--safe-top)) 6px 6px 20px; }
dialog.drawer .modal-bar { position: static; flex: none; padding-top: 6px; }
.bar-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; color: var(--fg); }
.modal-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
               border: 0; border-radius: 50%; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { background: var(--soft); }
.modal-box { padding: 16px 20px calc(24px + var(--safe-bottom)); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 16px; }
.modal-foot .btn:only-child { margin-left: auto; }
#dAddTop { flex: none; }
.d-title { font-size: var(--fs-h2); color: var(--title); margin: 0 0 12px; }

@media (min-width: 600px) {
  dialog.modal { width: min(720px, calc(100% - 48px)); height: auto; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
                 margin: auto; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  dialog.modal-wide { width: min(800px, calc(100% - 48px)); }
  .modal-bar { padding-top: 6px; }
  #dAddTop { display: none; }
  .modal-box { padding-bottom: 24px; }
  /* 平板以上：申請清單為右側抽屜 */
  dialog.drawer-side { width: 400px; max-width: 100%; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
                       margin: 0 0 0 auto; border-radius: 0; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
  dialog.drawer-side .modal-bar { padding-top: calc(6px + var(--safe-top)); }
}

/* ==================== 欄位清單（結果與詳細共用） ==================== */
.meta { display: grid; gap: 4px; margin: 0; font-size: 15px; }
.meta > div { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--soft); border-radius: var(--radius); padding: 12px;
        font-size: 15px; line-height: 1.8; }
@media (min-width: 600px) { .desc { max-height: 50vh; overflow: auto; } }

/* ==================== 申請清單 ==================== */
.cart-list { padding-left: 22px; margin: 0; }
.cart-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.cart-body { flex: 1; min-width: 0; }
.cart-body b { display: block; margin-bottom: 4px; }
.cart-list .meta { font-size: 13px; gap: 0; }
.cart-list .meta > div { grid-template-columns: 4.6em 1fr; }
.cart-list .cart-empty { list-style: none; margin-left: -22px; border-bottom: 0; }
.item-meta { color: var(--muted); font-size: 13px; }

/* ==================== 申請表單 ==================== */
.apply-items { margin: 0 0 16px; padding: 8px 8px 8px 28px; font-size: 14px; max-height: 160px; overflow: auto;
               background: var(--soft); border-radius: var(--radius); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 15px; color: var(--muted); position: relative; }
.f input, .f textarea { width: 100%; }
.f textarea { resize: vertical; min-height: 120px; }
.f.invalid input, .f.invalid textarea { border-color: var(--err); border-width: 2px; }
.req { color: var(--err); }
.counter { align-self: flex-end; font-size: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.notice-head { margin-top: 18px; color: var(--fg); }
.notice { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; height: 280px; overflow-y: auto;
          font-size: 15px; line-height: 1.8; background: #fcfcfc; }
.agree { display: flex; align-items: center; gap: 10px; min-height: var(--tap); margin: 12px 0; font-size: 16px; cursor: pointer; color: var(--fg); }
.agree input { width: 22px; height: 22px; min-height: 0; margin: 0; }
.agree.locked { color: var(--muted); cursor: not-allowed; }
.form-error { color: var(--err); background: var(--err-bg); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px;
              font-size: 15px; white-space: pre-line; }
.serial { font-size: 20px; color: var(--accent); }
@media (min-width: 1024px) {
  /* 電腦：姓名、信箱、電話排兩欄 */
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .f-wide { grid-column: 1 / -1; }
}

/* 申請須知內文（notice.html 與表單內共用） */
#notice-content h2, .notice h2 { text-align: center; margin: 0 0 10px; font-size: 16px; }
.n-list { padding-left: 24px; margin: 0; list-style: cjk-ideographic; }
.n-list > li { margin-bottom: 10px; }
.n-sub { padding-left: 28px; margin: 4px 0; list-style: none; counter-reset: sub; }
.n-sub > li { counter-increment: sub; position: relative; margin-bottom: 2px; }
.n-sub > li::before { content: "（" counter(sub, cjk-ideographic) "）"; position: absolute; left: -2.6em; width: 2.6em; text-align: right; }
.n-note { margin: 4px 0 0; padding: 6px 10px; background: var(--note-bg); border-left: 3px solid var(--note-bd); font-size: 14px; }
.n-end { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ==================== 提示、橫幅、骨架 ==================== */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60;
         width: max-content; max-width: calc(100% - 32px); background: #333; color: #fff; padding: 10px 18px;
         border-radius: var(--radius); font-size: 15px; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
@media (min-width: 600px) { .toast { bottom: 32px; } }

.banner { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin: 12px 0; padding: 10px 14px;
          background: var(--note-bg); border-left: 4px solid var(--note-bd); border-radius: var(--radius); font-size: 15px; }
.banner.error { background: var(--err-bg); border-left-color: var(--err); }
.banner p { margin: 0; flex: 1 1 220px; }

.skeleton .sk { display: block; height: 14px; margin: 8px 0; border-radius: 4px;
                background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-hi) 50%, var(--skeleton) 75%);
                background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
.skeleton .sk-title { height: 18px; width: 65%; }
.skeleton .sk-line { width: 40%; }
.skeleton .sk-btn { height: 44px; width: 88px; border-radius: var(--radius); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton .sk { animation: none; }
  html { scroll-behavior: auto; }
}
