@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0c;
  --surface:   #121215;
  --surface-2: #17171b;
  --surface-3: #1e1e24;
  --border:    #26262c;
  --border-2:  #34343d;
  --text:      #f4f4f6;
  --text-2:    #a2a2ad;
  --text-3:    #6e6e7a;
  --accent:    #6366f1;
  --accent-2:  #818cf8;
  --accent-bg: rgba(99,102,241,.12);
  --green:     #22c55e;
  --green-bg:  rgba(34,197,94,.12);
  --red:       #ef4444;
  --red-bg:    rgba(239,68,68,.12);
  --amber:     #f59e0b;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --sh-sm: 0 1px 2px rgba(0,0,0,.5);
  --sh:    0 6px 24px rgba(0,0,0,.45);
  --sh-lg: 0 18px 60px rgba(0,0,0,.6);
  --t: 170ms cubic-bezier(.4,0,.2,1);
  --maxw: 1160px;
}

html { scroll-behavior: smooth; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 480px at 12% -8%, rgba(99,102,241,.13), transparent 70%),
    radial-gradient(760px 420px at 88% 4%, rgba(129,140,248,.09), transparent 70%);
  background-attachment: fixed;
}

code, pre { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 13px; }
.hint { font-size: 12px; color: var(--text-3); }

/* ---------------- NAV ---------------- */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,10,12,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 22px;
  height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; }
.brand-text { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -.4px; }
.brand-text b { color: var(--accent-2); font-weight: 800; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.navlink {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm);
  transition: all var(--t); background: none; border: 0; cursor: pointer; font-family: inherit;
}
.navlink:hover { color: var(--text); background: var(--surface-2); }

.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  padding: 5px 10px; border-radius: 999px; text-transform: uppercase;
}
.badge.public { background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border-2); }
.badge.owner  { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,.3); }

/* ---------------- BUTTONS ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 18px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: all var(--t); white-space: nowrap;
}
.btn-sm { padding: 8px 13px; font-size: 12.5px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 16px var(--accent-bg); }
.btn-primary:hover { background: var(--accent-2); box-shadow: 0 6px 24px rgba(99,102,241,.3); }
.btn-ghost { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn:active { transform: scale(.975); }

/* ---------------- OWNER BAR ---------------- */
.owner-bar { border-bottom: 1px solid var(--border); background: var(--surface); }
.owner-inner { display: flex; align-items: center; gap: 10px; padding: 12px 22px; flex-wrap: wrap; }
.owner-icon { font-size: 15px; }
#ownerKeyInput {
  flex: 1; min-width: 220px;
  padding: 10px 14px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
}
#ownerKeyInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ---------------- VIEWS ---------------- */
.view { padding-top: 42px; padding-bottom: 70px; }

/* ---------------- HERO ---------------- */
.hero { text-align: center; max-width: 780px; margin: 0 auto 56px; }
.hero-pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .4px;
  color: var(--accent-2); background: var(--accent-bg);
  border: 1px solid rgba(99,102,241,.28); padding: 7px 15px; border-radius: 999px;
  margin-bottom: 22px;
}
.hero h1 { font-size: clamp(30px, 5.2vw, 50px); font-weight: 800; letter-spacing: -1.8px; line-height: 1.08; margin-bottom: 18px; }
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent-2), var(--accent) 55%, #a78bfa);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 15.5px; line-height: 1.75; color: var(--text-2); margin-bottom: 30px; }
.hero-sub b { color: var(--text); }
.hero-actions { display: flex; gap: 11px; justify-content: center; flex-wrap: wrap; }

.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 46px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 12px;
}
.stat b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 4px; }
.stat span { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

/* ---------------- FEATURES ---------------- */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 24px 22px; transition: all var(--t);
}
.card:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--sh); }
.card-ico {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--accent-bg); border: 1px solid rgba(99,102,241,.25);
  border-radius: var(--r-sm); font-size: 19px; margin-bottom: 15px;
}
.card h3 { font-size: 15px; font-weight: 650; margin-bottom: 9px; letter-spacing: -.2px; }
.card p { font-size: 13.5px; line-height: 1.7; color: var(--text-2); }
.card code, .docs-body code {
  font-size: 12px; background: var(--surface-3); color: var(--accent-2);
  padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border);
}

/* ---------------- HOWTO ---------------- */
.howto { margin-top: 60px; }
.howto h2 { font-size: 22px; font-weight: 700; letter-spacing: -.6px; margin-bottom: 20px; text-align: center; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 13px; }
.steps li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px; font-size: 13.5px;
  line-height: 1.65; color: var(--text-2); counter-increment: step;
  position: relative; padding-top: 44px;
}
.steps li::before {
  content: counter(step); position: absolute; top: 16px; left: 18px;
  width: 22px; height: 22px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border-radius: 6px;
  font-size: 11.5px; font-weight: 700;
}
.steps { counter-reset: step; }
.steps li b { color: var(--text); display: block; margin-bottom: 4px; }
.steps li i { color: var(--accent-2); font-style: normal; font-weight: 600; }

/* ---------------- PAGE HEAD ---------------- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h2 { font-size: 25px; font-weight: 750; letter-spacing: -.9px; margin-bottom: 5px; }
.page-actions { display: flex; gap: 8px; }

/* ---------------- NEW BOX ---------------- */
.newbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; margin-bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  animation: slideDown 200ms cubic-bezier(.4,0,.2,1);
}
@keyframes slideDown { from { opacity:0; transform: translateY(-10px);} to {opacity:1;transform:translateY(0);} }
.newbox-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.newbox input[type=text], .newbox input:not([type]), #localPartInput {
  flex: 1; min-width: 190px;
  padding: 11px 14px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13.5px; font-family: inherit;
}
.newbox select {
  padding: 11px 14px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13.5px; font-family: inherit; cursor: pointer; min-width: 170px;
}
.newbox input:focus, .newbox select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------------- INBOX GRID ---------------- */
.inbox-grid { display: grid; grid-template-columns: 310px 1fr; gap: 16px; align-items: start; }

.sidebar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; position: sticky; top: 78px;
}
.sidebar-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: var(--text-3);
}
.inbox-list { max-height: 400px; overflow-y: auto; padding: 7px; }
.inbox-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 11px; border-radius: var(--r-sm);
  font-size: 12.8px; color: var(--text-2); cursor: pointer;
  transition: all var(--t); word-break: break-all; line-height: 1.4;
  border: 1px solid transparent;
}
.inbox-item:hover { background: var(--surface-2); color: var(--text); }
.inbox-item.active {
  background: var(--accent-bg); color: var(--text);
  border-color: rgba(99,102,241,.3); font-weight: 600;
}
.inbox-item .lock { font-size: 11px; }
.sidebar-foot {
  padding: 11px; border-top: 1px solid var(--border);
  display: flex; gap: 7px;
}
.sidebar-foot .btn { flex: 1; justify-content: center; }

/* ---------------- PANEL ---------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.panel-head h3 { font-size: 14px; font-weight: 650; word-break: break-all; letter-spacing: -.2px; }
.count {
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-3);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.panel-tools {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.panel-tools input[type=text], #searchInput {
  flex: 1; min-width: 180px; padding: 9px 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; font-family: inherit;
}
.panel-tools input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ---------------- MESSAGES ---------------- */
.message-list { min-height: 300px; max-height: 620px; overflow-y: auto; }
.message-item { padding: 16px 18px; border-bottom: 1px solid var(--border); transition: background var(--t); }
.message-item:last-child { border-bottom: 0; }
.message-item:hover { background: var(--surface-2); }
.message-item.unread { border-left: 2.5px solid var(--accent); }
.message-item .message-meta {
  font-size: 11px; color: var(--text-3); margin-bottom: 7px;
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  font-family: 'JetBrains Mono', monospace;
}
.message-item strong { display: block; font-size: 13.5px; font-weight: 650; margin-bottom: 7px; letter-spacing: -.1px; }
.message-item .body-text {
  font-size: 13px; color: var(--text-2); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}

/* ---------------- EMPTY ---------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 20px; text-align: center; }
.empty-state .icon { font-size: 38px; margin-bottom: 14px; opacity: .35; }
.empty-state .title { font-size: 14.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.empty-state .sub { font-size: 13px; color: var(--text-3); max-width: 300px; line-height: 1.65; }

/* ---------------- DOCS ---------------- */
.docs-grid { display: grid; grid-template-columns: 200px 1fr; gap: 34px; align-items: start; }
.docs-nav { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 2px; }
.docs-nav a {
  font-size: 13px; font-weight: 500; color: var(--text-3);
  text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm);
  border-left: 2px solid transparent; transition: all var(--t);
}
.docs-nav a:hover { color: var(--text); background: var(--surface-2); border-left-color: var(--accent); }
.docs-body section { margin-bottom: 40px; scroll-margin-top: 84px; }
.docs-body h3 {
  font-size: 18px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.docs-body p { font-size: 13.5px; color: var(--text-2); line-height: 1.75; margin-bottom: 12px; }
.docs-body b { color: var(--text); }
.tag-ok {
  font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--green); background: var(--green-bg); border: 1px solid rgba(34,197,94,.3);
  padding: 4px 9px; border-radius: 999px;
}
.docs-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 12.8px; }
.docs-body th {
  text-align: left; padding: 10px 13px; background: var(--surface-2);
  color: var(--text-3); font-size: 10.5px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; border-bottom: 1px solid var(--border);
}
.docs-body th:first-child { border-top-left-radius: var(--r-sm); }
.docs-body th:last-child { border-top-right-radius: var(--r-sm); }
.docs-body td { padding: 10px 13px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: top; }
.docs-body tr:hover td { background: var(--surface); }
.docs-body pre {
  background: #0d0d10; border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 15px 17px; overflow-x: auto;
  margin: 12px 0; font-size: 12.2px; line-height: 1.75;
}
.docs-body pre code { background: none; border: 0; padding: 0; color: #c9d1d9; font-size: 12.2px; }

/* ---------------- FOOTER ---------------- */
.footer { border-top: 1px solid var(--border); background: rgba(18,18,21,.5); margin-top: 30px; }
.footer-inner {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 24px 22px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap;
}

/* ---------------- TOAST ---------------- */
.toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--text);
  box-shadow: var(--sh-lg); animation: toastIn 280ms cubic-bezier(.4,0,.2,1);
  max-width: 340px;
}
.toast.fadeout { animation: toastOut 200ms forwards; }
@keyframes toastIn { from { opacity:0; transform: translateY(16px) scale(.96);} to {opacity:1;transform:none;} }
@keyframes toastOut { to { opacity:0; transform: translateY(8px) scale(.97);} }

/* ---------------- QUOTA BAR ---------------- */
.quotabar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 15px 18px; margin-bottom: 16px;
}
.quota-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 11px; }
.quota-title { font-size: 13px; font-weight: 650; }
.quota-head .btn { margin-left: auto; }
.quota-track { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.quota-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width 400ms cubic-bezier(.4,0,.2,1);
}
.quota-fill.warn { background: linear-gradient(90deg, var(--amber), #f97316); }
.quota-fill.crit { background: linear-gradient(90deg, var(--red), #dc2626); }
.quota-legend {
  display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px;
  font-size: 12px; color: var(--text-3);
}
.quota-legend b { color: var(--text-2); font-weight: 650; }

.footlink { color: var(--text-3); text-decoration: none; border-bottom: 1px dotted var(--border-2); }
.footlink:hover { color: var(--accent-2); }

/* ---------------- SCROLLBAR ---------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #45454f; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 900px) {
  .docs-grid { grid-template-columns: 1fr; gap: 20px; }
  .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
  .inbox-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .inbox-list { max-height: 220px; }
}
@media (max-width: 620px) {
  .wrap { padding: 0 15px; }
  .nav-inner { padding: 0 15px; height: 58px; }
  .brand-text { font-size: 15px; }
  .navlink { padding: 7px 9px; font-size: 12.5px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .view { padding-top: 28px; }
  .hero { margin-bottom: 40px; }
  .hero-sub { font-size: 14.5px; }
  .page-head h2 { font-size: 21px; }
  .message-item { padding: 14px; }
}
@media (max-width: 460px) {
  .nav-links .navlink { display: none; }
  .nav-links .navlink:first-child { display: inline-flex; }
}
