:root {
  color-scheme: light;
  font: 16px/1.55 "Inter", "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
  color: #172f32; background: #f3f6f4;
  --muted: #4a6565; --edge: #ccd9d5; --teal: #105b52; --paper: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; }
.workspace, .compact { margin: 0 auto; padding: 3rem 1.4rem; width: min(100%, 61rem); }
.compact { width: min(100%, 32rem); padding-top: min(14vh, 8rem); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.65rem); letter-spacing: -.055em; line-height: 1.2; }
h1 small, h2 small { font-size: .55em; font-weight: 550; letter-spacing: 0; color: var(--muted); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
header, .top, .compact > h1 { margin-bottom: 1.5rem; }
.card, .directory { background: var(--paper); border: 1px solid var(--edge); border-radius: 14px; }
.card { padding: clamp(1rem, 2.8vw, 1.5rem); margin-bottom: 1.15rem; }
.stack, .create, .directory { display: grid; gap: 1rem; }
.create { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: end; margin-top: 1rem; }
label { display: grid; gap: .4rem; min-width: 0; font-weight: 600; font-size: .94rem; }
label small, .meta, .caption, .empty small { font-size: .83rem; font-weight: 500; color: var(--muted); }
.create label { display: block; }
.create label > input, .compound { margin-top: .4rem; }
input:not([type="checkbox"]) { width: 100%; min-width: 0; padding: .63rem .75rem; border: 1px solid #9fb4ae; border-radius: 7px; background: #fff; font: inherit; color: inherit; }
.compound { display: flex; align-items: center; border: 1px solid #9fb4ae; border-radius: 7px; background: #fff; padding-right: .6rem; overflow-wrap: anywhere; }
.compound input:not([type="checkbox"]) { border: 0; }
.compound span { font-size: .8rem; color: var(--muted); }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: .55rem .85rem; border: 1px solid var(--edge); border-radius: 7px; background: var(--paper); color: var(--teal); cursor: pointer; font-family: inherit; font-size: .88rem; font-weight: 650; line-height: 1.3; text-decoration: none; }
button:hover, .button:hover { background: #edf5f0; }
button:disabled { opacity: .6; cursor: wait; }
.primary { color: white; background: var(--teal); border-color: var(--teal); }
.primary:hover { background: #08443c; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid #197b71; outline-offset: 2px; }
.danger, .error { color: #9b3838; }
.top, .tools, .address, .actions, .box-head, .box-foot, .pair, .code-row, .pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.tools { margin: 1.5rem 0 .8rem; }
.actions { justify-content: flex-start; gap: .55rem; }
.switch { display: flex; align-items: center; gap: .4rem; cursor: pointer; padding: .45rem 0; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--teal); }
.caption, .address strong, .code { display: block; }
.address, .issued { background: #e5f2eb; border-color: #aed0c0; }
.address strong { font-size: clamp(1.15rem, 3vw, 1.65rem); margin-top: .25rem; }
.address, .message, .directory, .issued, .compound { overflow-wrap: anywhere; }
.directory { list-style: none; padding: 0; gap: 0; overflow: hidden; margin: .75rem 0; }
.mailbox { padding: 1.15rem; }
.mailbox + .mailbox { border-top: 1px solid var(--edge); }
.state { font-weight: 650; color: var(--muted); font-size: .8rem; }
.state.active { color: var(--teal); }
.note { white-space: pre-wrap; margin-top: .35rem; }
.box-foot, .message .meta, details, .issued p, .pair { margin-top: .65rem; }
.pair { gap: .5rem; padding-top: .65rem; border-top: 1px solid #c0d5c9; }
.issued-link { flex: 1 1 15rem; font-family: monospace; }
.code-row { background: #eff5f2; padding: .8rem 1rem; border-radius: 8px; margin-bottom: .85rem; }
.code { font: 700 1.75rem/1.25 "IBM Plex Mono", Consolas, monospace; letter-spacing: .11em; }
summary { width: fit-content; color: var(--teal); cursor: pointer; font-weight: 600; padding: .35rem 0; }
.mail-sign-in { margin: .35rem 0 .15rem; }
iframe { width: 100%; height: 16rem; margin-top: .5rem; border: 1px solid var(--edge); border-radius: 6px; background: white; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 1px dashed #aebfb9; border-radius: 12px; }
.toast:not(:empty) { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); background: #183e37; color: white; padding: .6rem 1rem; border-radius: 8px; text-align: center; max-width: calc(100% - 2rem); }
[hidden] { display: none !important; }
.workspace:has(.private-create) { width: min(100%, 76rem); }
.private-create { grid-template-columns: minmax(8rem, 16rem) minmax(10rem, 17rem) max-content; }
.private-create select { display: block; width: 100%; min-width: 0; margin-top: .4rem; padding: .63rem .65rem;
  border: 1px solid #9fb4ae; border-radius: 7px; background: #fff; color: inherit; font: inherit; }
.table-wrap { margin: .8rem 0; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden; background: var(--paper); }
.mail-table { table-layout: fixed; border-collapse: collapse; width: 100%; text-align: left; font-size: .92rem; }
.mail-table th, .mail-table td { padding: .95rem .75rem; vertical-align: top; }
.mail-table thead { background: #e9f0ec; color: #304c48; }
.mail-table tbody tr + tr { border-top: 1px solid var(--edge); }
.mail-table thead th:nth-child(1) { width: 26%; }
.mail-table thead th:nth-child(2) { width: 25%; }
.mail-table thead th:nth-child(3) { width: 13%; }
.mail-table thead th:nth-child(4) { width: 18%; }
.mail-table thead th:nth-child(5) { width: 18%; }
.mail-table th[scope=row] a { overflow-wrap: anywhere; }
.mail-table button, .mail-table .button { min-height: 2rem; padding: .3rem .6rem; font-size: .8rem; }
.cell-stack, .badges { display: grid; justify-items: start; gap: .36rem; min-width: 0; }
.cell-stack > * { max-width: 100%; min-width: 0; }
.clipped { display: block; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credential-link { display: flex; flex-wrap: wrap; gap: .3rem .4rem; align-items: center; width: 100%; }
.credential-link a { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.credential-link [data-copy] { flex: none; }
.password-field, .row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.password-field code { min-width: 0; overflow-wrap: anywhere; font-size: .83rem; }
.directory-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .75rem; margin: 1.35rem 0 1.55rem; }
.stat { padding: .8rem 1rem; background: white; border: 1px solid var(--edge); border-radius: 12px; }
.stat dt { font-size: .86rem; color: var(--muted); }
.stat dd { margin: .25rem 0 0; font-size: 1.75rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.pro-stat dd { color: #244e7c; } .max-stat dd { color: #654992; } .expiry-stat dd { color: #99500d; } .total-stat dd { color: var(--teal); }
.directory-heading, .modal-heading, .modal-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem; }
.sort-options { display: inline-flex; padding: .15rem; gap: .12rem; border: 1px solid var(--edge); border-radius: 9px; }
.sort-options a { padding: .25rem .65rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .85rem; }
.sort-options a[aria-current] { background: #e1eee7; color: var(--teal); font-weight: 700; }
.badge, .payment-tag, .link-off { display: inline-block; border-radius: 6px; padding: .12rem .5rem; font-weight: 650; font-size: .79rem; }
.badge.neutral, .payment-tag { background: #eef1f1; color: #455754; }
.badge.blue { background: #e3effc; color: #235489; }
.badge.violet { background: #eee7fa; color: #684390; }
.badge.gold { background: #fff0ca; color: #785103; }
.badge.green { background: #dff3e6; color: #216444; }
.badge.orange { background: #fff0da; color: #92450b; }
.badge.dark { background: #515c61; color: #fff; }
.badge.red, .link-off { background: #fce8e6; color: #963b33; }
.payment-tag { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expiry { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .4rem; font-variant-numeric: tabular-nums; }
.expiry span { font-size: .79rem; }
.due-soon { color: #984509; font-weight: 750; } .overdue { color: #a42f31; font-weight: 750; }
.renewal { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .83rem; font-weight: 550; cursor: pointer; }
.renewal input { margin: 0; width: 1rem; height: 1rem; accent-color: var(--teal); }
.mail-table button:disabled { cursor: default; }
#mailbox-editor { box-sizing: border-box; width: min(34rem,calc(100% - 1.5rem)); max-height: calc(100dvh - 2rem); overflow: auto;
  padding: 1.25rem; border: 1px solid var(--edge); border-radius: 14px; color: #172f32; box-shadow: 0 16px 65px #152c302c; }
#mailbox-editor::backdrop { background: #16383566; }
.modal-heading { flex-wrap: nowrap; align-items: start; margin-bottom: 1.1rem; }
.modal-heading .meta { overflow-wrap: anywhere; }
.modal-heading [data-close] { min-width: 2rem; min-height: 2rem; padding: .25rem; }
.edit-fields { padding: 0; margin: 0; border: 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem; }
.edit-fields .full { grid-column: 1/-1; }
.edit-fields select, .edit-fields textarea { width: 100%; min-width: 0; padding: .6rem .7rem; color: inherit; border: 1px solid #9fb4ae; border-radius: 7px; background: #fff; font: inherit; }
.edit-fields textarea { resize: vertical; }
.reset-confirm { padding: .65rem; margin-top: .5rem; border: 1px solid var(--edge); border-radius: 8px; font-size: .87rem; }
.reset-confirm .actions { margin-top: .5rem; }
.modal-feedback:not(:empty) { margin-top: .7rem; color: var(--teal); font-size: .9rem; }
.modal-feedback.error { color: #9b3838; }
.modal-footer { padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--edge); }
.modal-footer .actions { margin-left: auto; }
.new-row, .created-notice { background: #e7f3ec; }
.created-notice { padding: .6rem .8rem; margin-top: .6rem; }
@media (max-width: 800px) {
  .directory-stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
  .mail-table, .mail-table tbody, .mail-table tr { display: block; }
  .mail-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .mail-table tbody tr { padding: .6rem; }
  .mail-table td, .mail-table th[scope=row] { display: grid; grid-template-columns: 5.3rem minmax(0, 1fr); gap: .5rem; padding: .45rem .25rem; align-items: baseline; }
  .mail-table [data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; font-weight: 600; }
  .stat dd { font-size: 1.55rem; }
}
@media (max-width: 430px) {
  .edit-fields { grid-template-columns: minmax(0,1fr); }
  .modal-footer .actions { gap: .3rem; }
}
@media (max-width: 680px) {
  .workspace, .compact { padding: 1.6rem .9rem; }
  .create { grid-template-columns: 1fr; }
  .tools, .box-foot { align-items: flex-start; }
  .tools { flex-direction: column; }
  .pair { align-items: flex-start; flex-direction: column; }
  .issued-link { flex: auto; max-width: 100%; }
}
