/* KringeMail — user surface (USERWEB). Light theme, one accent colour, no external assets. */
:root {
  --accent: #2f6df6;
  --accent-strong: #1d55d6;
  --accent-soft: #e8efff;
  --accent-ring: rgba(47, 109, 246, .35);
  --text: #1a1f2b;
  --text-soft: #4b5567;
  --muted: #6f7a8c;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e7ee;
  --border-strong: #cfd6e2;
  --hover: #f7f9fd;
  --danger: #c62b3d;
  --danger-soft: #fdecee;
  --info-soft: #eaf6ee;
  --info-text: #1f6b3a;
  --warn-soft: #fff6e5;
  --warn-text: #7a4b00;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 6px 20px -12px rgba(20, 30, 50, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
svg { display: inline-block; vertical-align: -.15em; flex-shrink: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; border-radius: var(--radius-sm); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100; padding: .5rem .8rem;
  background: var(--card); color: var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }

/* ---------- Header / footer ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.site-header__inner {
  max-width: 1080px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.brand__icon { color: var(--accent); }
.mailbox-chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .35rem .25rem .6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: var(--text-soft); font-size: .9rem;
  max-width: 100%; min-width: 0;
}
.mailbox-chip__address { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: .85rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.is-copied { color: var(--info-text); }
.lang-switch { display: inline-flex; gap: .15rem; margin-left: auto; }
.lang-switch a {
  padding: .25rem .55rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .88rem;
}
.lang-switch a:hover { background: var(--hover); color: var(--text); }
.lang-switch a[aria-current] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.logout-form { margin: 0; }

.site-main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
.site-main:focus { outline: none; }
.site-footer {
  border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; background: var(--card);
  padding: .75rem 1rem; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between;
}
.site-footer__note { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--accent); color: #fff;
  font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; white-space: nowrap; transition: background .12s, color .12s;
}
.btn:hover { background: var(--accent-strong); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; pointer-events: none; }
.btn-primary { background: var(--accent); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--hover); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: .4rem .7rem; font-size: .88rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

.field { margin-bottom: .9rem; }
.field label { display: block; margin-bottom: .3rem; font-weight: 600; font-size: .92rem; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"] {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--card); transition: border-color .12s, box-shadow .12s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }

.alert { padding: .65rem .9rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-size: .93rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info-text); }
.alert-images {
  background: var(--warn-soft); color: var(--warn-text); display: flex; gap: .75rem; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
}
.alert-images__text { display: inline-flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.alert-images .muted { color: inherit; opacity: .75; }
.notice { color: var(--muted); font-size: .88rem; margin: .75rem 0; }
.notice-lock, .notice-inline { display: flex; gap: .4rem; align-items: center; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .6rem .9rem; margin: 0 0 1rem; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 600;
}

.badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }

/* ---------- Login ---------- */
.login { display: flex; justify-content: center; padding: 2rem 0; }
.login-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.75rem 1.5rem; box-shadow: var(--shadow);
}
.login-card__logo { color: var(--accent); margin-bottom: .75rem; }
.login-card__title { font-size: 1.4rem; margin-bottom: .25rem; }
.login-card__subtitle { margin: 0 0 1.25rem; color: var(--muted); }
.login-card .btn-block { margin-top: .5rem; }

/* ---------- Inbox ---------- */
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .25rem; }
.inbox-head__title { display: flex; align-items: center; gap: .6rem; }
.inbox-head h1 { font-size: 1.5rem; }
.search { display: flex; gap: .5rem; flex: 1 1 320px; max-width: 480px; margin: 0; }
.search__box { position: relative; flex: 1; }
.search__icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search__box input { padding-left: 2.2rem; padding-right: 2.2rem; }
.search__clear {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--muted);
}
.search__clear:hover { background: var(--hover); color: var(--text); }

.filter-tabs { display: flex; align-items: center; gap: .25rem; margin: .5rem 0 .75rem; border-bottom: 1px solid var(--border); }
.filter-tabs a {
  padding: .5rem .8rem; margin-bottom: -1px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem;
  border-bottom: 2px solid transparent;
}
.filter-tabs a:hover { color: var(--text); }
.filter-tabs a[aria-current] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.filter-tabs__total { margin-left: auto; color: var(--muted); font-size: .85rem; }

.bulk-form { margin: 0; }
.bulk-bar {
  display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; padding: .45rem .6rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.bulk-bar__select-text { font-size: .88rem; color: var(--muted); }
.bulk-bar__count { font-size: .88rem; color: var(--accent-strong); font-weight: 600; }
.bulk-bar__count:empty { display: none; }
.bulk-bar__actions { display: flex; gap: .15rem; flex-wrap: wrap; }
.bulk-bar__range { margin-left: auto; color: var(--muted); font-size: .85rem; }
.bulk-bar.has-selection { background: var(--accent-soft); border-color: var(--accent-soft); }

/* custom checkbox */
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; position: relative; }
.check input { position: absolute; opacity: 0; width: 1.25rem; height: 1.25rem; margin: 0; cursor: pointer; }
.check__box {
  width: 1.15rem; height: 1.15rem; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--card);
  display: inline-block; position: relative; transition: background .1s, border-color .1s;
}
.check input:checked + .check__box, .check input:indeterminate + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check input:indeterminate + .check__box::after {
  content: ""; position: absolute; left: 3px; right: 3px; top: 7px; height: 2px; background: #fff;
}
.check input:focus-visible + .check__box { box-shadow: 0 0 0 3px var(--accent-ring); }
.check input:disabled + .check__box { opacity: .5; }

.msg-list {
  list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.msg-row {
  display: grid; grid-template-columns: auto auto minmax(120px, 200px) minmax(0, 1fr) auto; align-items: center; gap: .6rem;
  padding: .55rem .6rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s;
}
.msg-row:last-child { border-bottom: 0; }
.msg-row:hover { background: var(--hover); }
.msg-row.is-selected { background: var(--accent-soft); }
.msg-row__dot { width: 8px; height: 8px; border-radius: 999px; background: transparent; }
.msg-row.is-unread .msg-row__dot { background: var(--accent); }
.msg-row__from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.msg-row__main { min-width: 0; display: flex; gap: .4rem; text-decoration: none; color: var(--text); overflow: hidden; white-space: nowrap; }
.msg-row__main:hover { color: var(--text); }
.msg-row__subject { flex-shrink: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.msg-row__snippet { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.msg-row__snippet::before { content: "— "; }
.msg-row.is-unread .msg-row__from, .msg-row.is-unread .msg-row__subject { font-weight: 700; color: var(--text); }
.msg-row__meta { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.msg-row.is-unread .msg-row__meta time { color: var(--accent-strong); font-weight: 600; }
.icon-attach { display: inline-flex; color: var(--muted); }

.empty {
  text-align: center; padding: 3rem 1rem; background: var(--card); border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius); color: var(--muted);
}
.empty svg { color: var(--border-strong); margin-bottom: .5rem; }
.empty__title { color: var(--text); font-weight: 600; margin: .25rem 0; }
.empty__hint { color: var(--muted); margin: .25rem 0; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.pagination__info { color: var(--muted); font-size: .9rem; }

/* ---------- Message ---------- */
.message-nav { margin-bottom: .75rem; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; font-weight: 600; font-size: .92rem; }
.message-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.message-head__subject { font-size: 1.35rem; overflow-wrap: anywhere; flex: 1 1 300px; }
.message-actions { display: flex; gap: .2rem; flex-wrap: wrap; }

.message-meta {
  margin: 0 0 1rem; padding: .85rem 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  display: grid; gap: .3rem;
}
.message-meta__row { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .5rem; }
.message-meta dt { color: var(--muted); font-size: .9rem; }
.message-meta dd { margin: 0; overflow-wrap: anywhere; }
.sender-name { font-weight: 650; }
.addr { color: var(--text-soft); }

.attachments { margin: 0 0 1rem; }
.attachments__title { font-size: .9rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
.attachments__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem; max-width: 100%;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text); text-decoration: none; font-size: .9rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.chip__size { color: var(--muted); font-size: .8rem; }
.chip__tag { color: var(--muted); font-size: .75rem; border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; }

.message-body { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.message-body .empty__hint { padding: 2rem 1rem; text-align: center; }
.body-frame { display: block; width: 100%; min-height: 320px; height: 60vh; border: 0; background: #fff; }
.body-frame.is-sized { height: auto; }

.raw-headers { margin-bottom: 1rem; }
.raw-headers summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; padding: .3rem 0; }
.table-wrap { overflow-x: auto; margin-top: .5rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.headers-table { border-collapse: collapse; width: 100%; font-size: .85rem; font-family: var(--mono); }
.headers-table th, .headers-table td { text-align: left; vertical-align: top; padding: .4rem .7rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.headers-table thead th { font-family: var(--font); color: var(--muted); font-weight: 600; background: var(--bg); }
.headers-table tbody th { white-space: nowrap; color: var(--text-soft); font-weight: 600; }
.headers-table tr:last-child td, .headers-table tr:last-child th { border-bottom: 0; }

/* ---------- Errors ---------- */
.error-page { text-align: center; padding: 3rem 1rem; max-width: 560px; margin: 0 auto; }
.error-page__code { font-size: 3rem; font-weight: 800; color: var(--border-strong); margin: 0; letter-spacing: -.03em; }
.error-page h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.error-page__text { color: var(--muted); margin-bottom: 1.25rem; }
.details { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card); padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .8rem; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .site-header__inner { gap: .5rem; }
  .brand__name { display: none; }
  .mailbox-chip { order: 5; flex: 1 1 100%; }
  .lang-switch a { padding: .25rem .45rem; }
  .msg-row { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-rows: auto auto; row-gap: .1rem; }
  .msg-row__check { grid-row: 1 / span 2; }
  .msg-row__dot { grid-row: 1 / span 2; }
  .msg-row__from { grid-column: 3; }
  .msg-row__meta { grid-column: 4; }
  .msg-row__main { grid-column: 3 / span 2; white-space: normal; flex-direction: column; gap: 0; }
  .msg-row__subject { white-space: nowrap; }
  .msg-row__snippet { white-space: nowrap; }
  .msg-row__snippet::before { content: ""; }
  .bulk-bar__range { display: none; }
  .bulk-bar__select-text { display: none; }
  .message-meta__row { grid-template-columns: 1fr; gap: 0; }
  .message-head__subject { font-size: 1.2rem; }
  .body-frame { min-height: 260px; }
}
@media (max-width: 420px) {
  .search { flex: 1 1 100%; }
  .search .btn { display: none; }
  .filter-tabs__total { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
