:root {
  color-scheme: dark;
  --bg: #101017;
  --panel: #1a1a25;
  --edge: #373644;
  --ink: #f4f2fd;
  --muted: #b7b4c8;
  --violet: #c6b6ff;
  font: 16px/1.65 "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box }
[hidden] { display:none !important }
body { margin:0; min-height:100vh; background:radial-gradient(ellipse at 82% 14%,#211e30 0,transparent 38%),var(--bg) }
header { border-bottom:1px solid #302f3b; background:#14141c }
.bar,main { width:min(1050px,100%); margin:auto; padding-inline:clamp(16px,4vw,40px) }
.bar,.brand,.toolbar,.line,.actions,.search { display:flex; gap:12px; align-items:center }
.bar { min-height:70px; flex-wrap:wrap; padding-block:10px }
.brand { margin-right:auto; font:650 21px/1.2 "Segoe UI",system-ui,sans-serif; letter-spacing:-.045em }
.logo,.stamp,.empty-mark { display:grid; place-items:center; flex-shrink:0 }
.logo { width:35px; height:35px; background:var(--violet); color:#231a39; border-radius:11px; font-size:20px }
#mode { font-size:.82rem; color:#c2e1ce }
main { padding-block:32px 56px }
.hero { position:relative; isolation:isolate; overflow:hidden; border:1px solid #484053; border-radius:24px; padding:clamp(23px,4vw,42px); background:linear-gradient(110deg,#252234 12%,#30293c 69%,#47405d); min-height:182px; display:grid; align-content:center }
.hero h1 { margin:0; line-height:1.3; font-size:clamp(2rem,4.8vw,3.35rem); letter-spacing:-.04em }
.lead { margin:7px 0 0; color:#d6d1e1; max-width:65%; }
.mail-art { position:absolute; right:7%; top:50%; translate:0 -50%; rotate:-10deg; width:124px; height:84px; border:2px solid #e0d5f8; border-radius:9px; background:#a899c5; box-shadow:8px -8px 0 #736486,9px -9px 0 #b4a3cb,16px -16px 0 #524861,17px -17px 0 #9684ad; overflow:hidden; z-index:-1 }
.mail-art::after { content:""; position:absolute; width:91px; height:91px; left:14px; top:-54px; rotate:45deg; border:2px solid #e8def9; background:#cbbcdf; border-radius:6px }
button,input { font:inherit }
button { min-height:44px; border:1px solid var(--edge); border-radius:10px; background:#242430; color:var(--ink); padding:7px 14px; cursor:pointer }
button:hover { background:#323140; border-color:#686277 }
button:disabled { opacity:.55; cursor:wait }
.primary { font-weight:650; background:var(--violet); color:#221935; border-color:transparent }
.primary:hover { background:#d7cbff }
:focus-visible { outline:3px solid #d4c4ff; outline-offset:3px }
#notice:not(:empty) { color:#cdc5e2; font-size:.9rem; margin:16px 1px; padding-left:12px; border-left:3px solid #9f8bbb }
.toolbar { margin:26px 0 21px }
.search { flex:1; border:1px solid #4b485a; background:#1c1c27; border-radius:12px; padding:0 14px; margin:0 }
.search i { width:16px;height:16px;border:2px solid #bab3c9;border-radius:50%;position:relative;flex:none;margin-right:3px }
.search i::after { content:"";position:absolute;width:7px;height:2px;background:#bab3c9;right:-5px;bottom:-2px;rotate:45deg }
.search input { border:0; background:transparent; margin:0; padding:12px 2px; min-width:0 }
.search:focus-within { outline:2px solid var(--violet) }
.search input:focus-visible { outline:none }
.toolbar .primary { min-height:49px; padding-inline:21px; white-space:nowrap }
.line { justify-content:space-between; margin-bottom:12px }
h2 { font-size:1.18rem; margin:0; line-height:1.5 }
#count { display:inline-block; border-radius:8px; background:#302a40; color:#d8c8ff; padding:1px 8px; margin-left:4px }
#list { display:grid; gap:9px }
.card { display:grid; grid-template-columns:46px minmax(0,1fr) auto; gap:16px; align-items:center; background:var(--panel); border:1px solid var(--edge); border-radius:15px; padding:19px 20px }
.stamp { height:46px; border-radius:14px; background:#373046; color:#dec9fc; font:600 21px "Segoe UI",sans-serif }
.card:nth-child(3n+2) .stamp { color:#a4dddb; background:#233b40 }
.card:nth-child(3n) .stamp { color:#f0c496; background:#423325 }
.address { font-weight:650; font-size:1.03rem; overflow-wrap:anywhere }
.meta { font-size:.86rem; color:var(--muted); overflow-wrap:anywhere; margin-top:2px }
.meta b { font-weight:450; color:#e2dfee }
.actions { justify-content:flex-end; gap:8px }
.danger { color:#f0adb9 }
.empty { display:grid; justify-items:center; gap:9px; text-align:center; padding:30px 16px; border:1px dashed #4e495e; background:var(--panel); border-radius:15px }
.empty p { margin:0; max-width:100%; color:var(--muted) }
.empty-mark { border-radius:12px; width:42px; height:42px; background:#302a40; color:var(--violet); font-size:21px }
#login,#resetForm,dialog { background:var(--panel); color:var(--ink); border:1px solid var(--edge); border-radius:18px; padding:clamp(18px,4vw,29px); width:min(100%,440px) }
#login,#resetForm { margin:22px auto }
#login button,#resetForm button { width:100%; margin-top:9px }
dialog { max-width:calc(100% - 24px); max-height:90dvh; overflow:auto }
dialog::backdrop { background:#08080fc9 }
label { display:block; margin:14px 0; font-weight:550 }
input { width:100%; padding:10px 12px; margin-top:5px; border:1px solid #514c60; border-radius:9px; background:#14141d; color:var(--ink) }
input::placeholder { color:#b4aec2 }
small { font-size:.81rem; color:var(--muted); font-weight:450 }
#error { color:#ffabb8 }
@media(max-width:640px) {
  main { padding-top:16px }
  .bar { min-height:60px; gap:8px }
  .brand { font-size:19px; gap:8px }
  .bar button { padding-inline:8px; font-size:.85rem }
  .hero { min-height:142px; padding:20px }
  .mail-art { right:13px; scale:.48; transform-origin:right center }
  .hero h1,.lead { max-width:calc(100% - 72px) }
  .lead { font-size:.9rem }
  .toolbar { gap:8px; margin:18px 0 }
  .toolbar .primary { padding-inline:11px }
  .search { padding-inline:10px }
  .card { grid-template-columns:36px minmax(0,1fr); gap:8px 11px; padding:14px }
  .stamp { height:36px; border-radius:11px; font-size:17px }
  .card .actions { grid-column:2; justify-content:start }
  .actions button { padding:5px 12px }
}
#privateSection {margin-block:18px;padding:12px;border:1px solid var(--edge);border-radius:12px}
#privateSection summary {cursor:pointer;color:var(--violet);font-weight:600}
#privateSection small,#secretHelp {color:var(--muted);font-size:.85rem}
#privateSection textarea {box-sizing:border-box;width:100%;resize:vertical;display:block;padding:10px;border-radius:9px;margin-top:5px;border:1px solid #514c60;background:#14141d;color:var(--ink);font:inherit}
#privateSection button {font-size:.9rem}
