:root {
  --ink: #f2f3f5;
  --ink-soft: #9aa1ac;
  --ink-faint: #6b7280;
  --bg: #0a0c11;
  --surface: #12151c;
  --surface-2: #171a22;
  --border: #23262f;
  --accent: #4f8cff;
  --accent-2: #35d4f5;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --accent-ring: rgba(79, 140, 255, 0.28);
  --mint: #22c55e;
  --amber: #f59e0b;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

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

html,
body {
  min-height: 100%;
}

body {
  font-family: "Figtree", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(79, 140, 255, 0.08), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(53, 212, 245, 0.05), transparent 45%),
    var(--bg);
  letter-spacing: -0.01em;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.brand h1 {
  font-family: "Syne", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.brand p {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.status-pill.live .dot {
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.status-pill.warn .dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
  padding: 20px 24px 24px;
  min-height: 0;
}

.pane {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--surface-2);
}

.search-head {
  padding: 22px 22px 12px;
}

.search-head h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
  color: var(--ink);
}

.search-head p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.search-form {
  display: grid;
  gap: 10px;
  padding: 0 22px 18px;
}

.label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
  min-width: 0;
}

.field input::placeholder {
  color: var(--ink-faint);
}

.btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  border-radius: 9px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #ffffff;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: wait;
  filter: saturate(0.5);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px 12px;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.mail-list {
  overflow: auto;
  padding: 0 10px 14px;
}

.mail-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 14px 12px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: start;
}

.mail-item:hover,
.mail-item.active {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.unread-dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: transparent;
}

.mail-item.unread .unread-dot {
  background: var(--accent);
}

.mail-item strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 3px;
  color: var(--ink);
}

.mail-item .subject {
  color: var(--ink);
  font-size: 0.88rem;
}

.mail-item .from {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-top: 4px;
}

.mail-item time {
  color: var(--ink-faint);
  font-size: 0.72rem;
  white-space: nowrap;
}

.reader {
  background: var(--surface);
  color: var(--ink);
  display: grid;
  grid-template-rows: auto 1fr;
}

.reader-empty,
.reader-loading {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  color: var(--ink-soft);
  min-height: 100%;
}

.reader-empty h3,
.reader-loading h3 {
  font-family: "Syne", sans-serif;
  color: var(--ink);
  margin-bottom: 8px;
}

.reader-header {
  padding: 26px 32px 18px;
  border-bottom: 1px solid var(--border);
}

.reader-header .kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 650;
}

.reader-header h3 {
  font-family: "Syne", sans-serif;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 14px;
  color: var(--ink);
}

.people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.people b {
  color: var(--ink);
  font-weight: 650;
}

.reader-body {
  overflow: auto;
  padding: 0;
  min-height: 0;
}

.reader-body iframe {
  width: 100%;
  min-height: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.plain-body {
  padding: 28px 32px;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 32px 16px;
}

.chip {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
}

.empty-list,
.error-box {
  margin: 8px 22px 18px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.error-box {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.skeleton {
  height: 64px;
  margin: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(90deg, #171a22, #1f232d, #171a22);
  background-size: 200% 100%;
  animation: shine 1.2s infinite;
}

@keyframes shine {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 42vh) 1fr;
    padding: 8px 12px 16px;
  }

  .topbar {
    padding: 16px 16px;
  }
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-mark {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.9;
}

.footer-text {
  font-family: "Syne", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.footer-text strong {
  font-weight: 700;
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 55%, var(--accent));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  transition: background-position 0.6s ease;
}

.app-footer:hover .footer-text strong {
  background-position: -100% 0;
}

/* Topbar actions + info button */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.icon-btn:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

/* Notice modal */
.notice {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.notice[hidden] {
  display: none;
}

.notice-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.notice-card {
  position: relative;
  width: min(540px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(600px 220px at 0% -10%, rgba(79, 140, 255, 0.1), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  animation: notice-in 0.22s ease both;
}

@keyframes notice-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.notice-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.notice-badge {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.28);
}

.notice-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.notice-card h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.notice-body {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.notice-body strong {
  color: var(--ink);
  font-weight: 650;
}

.notice-body em {
  color: var(--ink);
  font-style: normal;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86em;
}

.notice-scope {
  list-style: none;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  gap: 9px;
}

.notice-scope li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 0.88rem;
}

.notice-scope .mk {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.notice-scope .is-yes .mk {
  background: rgba(34, 197, 94, 0.14);
  color: var(--mint);
}

.notice-scope .is-no .mk {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.notice-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.notice-actions .btn {
  padding: 10px 22px;
}

@media (max-width: 520px) {
  .notice-card { padding: 22px 18px 18px; }
  .notice-head { gap: 12px; }
}
