:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --ink: #14161a;
  --ink-soft: #5b6472;
  --line: #e4e7ee;
  --brand: #2f6bff;
  --brand-dark: #1f4fd8;
  --brand-soft: #eaf0ff;
  --ok: #12a150;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; color: var(--ink-soft); }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 28px 20px 60px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 0 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 160px; resize: vertical; }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; transition: .15s;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: #eef1f7; }
.btn.danger { color: var(--err); border-color: #f3c6c6; background: #fff5f5; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.alert { padding: 10px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 14px; display: none; }
.alert.show { display: block; }
.alert.ok { background: #ecfdf3; color: #08692f; border: 1px solid #b7ebc9; }
.alert.err { background: #fef2f2; color: #991b1b; border: 1px solid #f5c2c2; }
.alert.info { background: var(--brand-soft); color: #1e3a8a; border: 1px solid #c7d7ff; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f7; color: var(--ink-soft); }
.badge.ok { background: #ecfdf3; color: #08692f; }
.badge.warn { background: #fffbeb; color: #92400e; }
.badge.err { background: #fef2f2; color: #991b1b; }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #fafbfd; }
tr:last-child td { border-bottom: none; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; word-break: break-all; }

pre.copybox {
  background: #0f172a; color: #d7e3ff; padding: 12px 14px; border-radius: 10px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; margin: 0 0 12px; white-space: pre-wrap; word-break: break-all;
}

/* ---------------- 首頁 ---------------- */
.hero { text-align: center; padding: 44px 20px 26px; }
.hero .logo { font-size: 40px; }
.hero p.lead { max-width: 620px; margin: 0 auto 8px; font-size: 16px; }
.tabs { display: flex; gap: 6px; background: #eef1f7; padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------------- 信箱介面 ---------------- */
.mailapp { display: grid; grid-template-columns: 216px 340px 1fr; height: 100vh; }
.mailapp .pane { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
.mailapp .pane:last-child { border-right: none; background: #fff; }
.side { padding: 14px; display: flex; flex-direction: column; gap: 6px; background: #fbfcfe; }
.side .brandline { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.side .mailbox { font-size: 12.5px; color: var(--ink-soft); word-break: break-all; margin-bottom: 10px; }
.folder { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.folder:hover { background: #eef1f7; }
.folder.active { background: var(--brand-soft); color: var(--brand-dark); }
.folder .count { margin-left: auto; font-size: 12px; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; }
.folder .count.zero { display: none; }

.list-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
.msg { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg:hover { background: #f8fafc; }
.msg.active { background: var(--brand-soft); }
.msg .from { font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.msg .subj { font-size: 13.5px; margin-top: 2px; }
.msg .snip { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .when { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.msg.unread .from, .msg.unread .subj { font-weight: 700; }
.msg.unread { background: #fbfcff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; }

.reader { padding: 20px 24px; overflow-y: auto; }
.reader .subject { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.reader .meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; line-height: 1.7; }
.reader iframe.body { width: 100%; border: 1px solid var(--line); border-radius: 10px; min-height: 420px; background: #fff; }
.reader pre.body { white-space: pre-wrap; font: inherit; background: #fafbfd; padding: 14px; border-radius: 10px; border: 1px solid var(--line); }
.att { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; margin: 6px 6px 0 0; font-size: 13.5px; }

/* ---------------- 彈窗 ---------------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-back.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; padding: 20px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
.modal .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }
@media (max-width: 1000px) {
  .mailapp { grid-template-columns: 180px 1fr; }
  .mailapp .pane.reader-pane { display: none; }
  .mailapp.reading .pane.list-pane { display: none; }
  .mailapp.reading .pane.reader-pane { display: block; }
}
