/* TW-EN-Address: 簡潔、可讀、行動裝置友善的純 CSS。 */

:root {
  --bg: #fafaf9;
  --surface: #fff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --accent: #fde68a;
  --warn: #b45309;
  --error: #b91c1c;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --radius: 8px;
  --max-width: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --text: #e6edf3;
    --muted: #8b949e;
    --border: #30363d;
    --primary: #4f8cff;
    --primary-hover: #6ba1ff;
    --accent: #b3771a;
    --warn: #f59e0b;
    --error: #f87171;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
        "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hdr {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 16px 12px;
  text-align: center;
}
.hdr h1 {
  font-size: 36px; margin: 0 0 6px;
  font-weight: 700; letter-spacing: -.02em;
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
}
.hdr .tagline { color: var(--muted); margin: 0; font-size: 14px; }

.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

/* 輸入區 */
.input-area { margin-bottom: 16px; }
.input-wrap { position: relative; }
#addr-input {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 64px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
#addr-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,140,255,.2), var(--shadow);
}
.input-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* 自動補全清單 */
.suggestions {
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin: 4px 0 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
}
.suggestion-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.suggestion-item:hover, .suggestion-item.active {
  background: rgba(79,140,255,.1);
}
.suggestion-label { font-weight: 500; }
.suggestion-sublabel { color: var(--muted); font-size: 13px; }
.suggestion-type {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* 結果卡 */
.result { margin: 24px 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-row:last-of-type { border-bottom: none; }
.card-label { color: var(--muted); font-size: 13px; }
.card-value {
  font-family: ui-monospace, SFMono-Regular, "Menlo", monospace;
  font-size: 15px;
  word-break: break-all;
  color: var(--text);
  background: transparent;
  user-select: all;
}
.copy-btn {
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.copy-btn:hover { background: rgba(79,140,255,.1); }
.copy-btn.copied { background: var(--accent); }
.card-warnings {
  padding: 10px 16px;
  background: rgba(245,158,11,.08);
  color: var(--warn);
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.card-warnings.error { background: rgba(248,113,113,.08); color: var(--error); }

/* 歷史紀錄 */
.history { margin: 24px 0; }
.history-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted);
  margin-bottom: 8px;
}
.text-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 13px;
  padding: 0; text-decoration: underline;
}
.text-btn:hover { color: var(--text); }
.history-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.history-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.history-chip:hover { background: rgba(79,140,255,.08); }
.history-chip-label { font-family: ui-monospace, monospace; }
.history-chip-x {
  color: var(--muted);
  cursor: pointer;
  background: none; border: none; padding: 0;
  font-size: 14px;
}
.history-chip-x:hover { color: var(--error); }

/* Footer */
.ftr {
  max-width: var(--max-width);
  margin: 32px auto 24px;
  padding: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.ftr a { color: var(--muted); text-decoration: underline; }
.ftr a:hover { color: var(--text); }

/* mobile tighten */
@media (max-width: 480px) {
  .hdr h1 { font-size: 22px; }
  .card-row {
    grid-template-columns: 88px 1fr auto;
    gap: 8px;
    padding: 12px;
  }
  .card-value { font-size: 13px; }
}
