*, *:before, *:after {
  box-sizing: border-box;
}

.readable-width {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.flex-row {
  display: flex;
  gap: 5px;
}
.flex-1:not([hidden]) {
  flex: 1;
}
.flex-2:not([hidden]) {
  flex: 2;
}
:is(.flex-1, .flex-2) > :is(button) {
  width: 100%;
}


label.file-upload {
  width: 100%;
  text-align: center;
  background-color: #007bff;
  color: white;
  cursor: pointer;
  display: block;
  border-radius: 6px;
  padding: 12px;
}
label.file-upload:hover {
  background-color: #0069d9;
}
label.file-upload:active {
  background-color: #0056b3;
}
input[type="file"] {
  display: none;
}

button {
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #cccccc;
  cursor: pointer;
  background-color: #e0e0e0;
}
button:hover {
  background-color: #d4d4d4;
}
button:active {
  background-color: #bcbcbc;
}

label:has(input:optional)::after {
  content: "(選填)";
  color: #999;
  font-size: 0.8em;
}

#declaration ol li {
  margin-bottom: 1em;
  line-height: 1.6;
  padding-left: 0.5em;
}
#declaration label:has(input[type="checkbox"]:required) {
  text-align: center;
  font-size: 16px;
}


/* 基礎設定：讓畫面在 WebView 裡不會亂跑 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  margin: 0;
  padding: 15px;
  background-color: #f9f9f9;
}

/* 區塊容器 */
.form-container {
  max-width: 800px;
  margin: 0 auto;
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

h2 {
  text-align: center;
}

h3 {
  border-left: 4px solid #0056b3;
  padding-left: 10px;
  margin: 25px 0 15px 0;
  color: #0056b3;
  font-size: 1.2rem;
}

/* 讓每一組 Label + Input 垂直堆疊（手機優先） */
div {
  margin-bottom: 15px;
}

label {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 0.95rem;
}

/* 輸入框樣式：滿版且易於觸控 */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px; /* 防止 iOS WebView 自動放大畫面 */
  background-color: #fff;
}

/* 唯讀欄位背景變灰色 */
input[readonly] {
  background-color: #eee;
  color: #666;
  cursor: not-allowed;
}

/* 同戶籍地按鈕 */
.sync-address-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: #0056b3;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* 表格優化：在手機上改為區塊顯示或橫向滾動 */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

th, td {
  border: 1px solid #ddd;
  padding: 10px 5px;
  text-align: left;
}

th {
  background-color: #f2f2f2;
  font-size: 0.9rem;
}

/* 電腦版微調 (螢幕寬度 > 600px) */
@media (min-width: 600px) {
  /* 讓部分欄位可以並排（如果有需要）或維持垂直但限制寬度 */
  .sync-address-btn {
    display: inline-block;
    margin-top: 0;
    margin-left: 10px;
    width: auto;
  }
}

/* 手機版表格處理：避免擠在一起 */
@media (max-width: 480px) {
  table, thead, tbody, th, td, tr {
    display: block; /* 將表格轉為區塊 */
  }

  thead tr {
    display: none; /* 隱藏表頭 */
  }

  tr {
    margin-bottom: 15px;
    border: 1px solid #eee;
    padding: 10px;
  }

  td {
    border: none;
    padding: 5px 0;
  }

  td::before {
    content: attr(data-label); /* 若有需要可加 data-label 顯示標題 */
    font-weight: bold;
    display: block;
  }
}