:root {
  --bg: #0f1220;
  --text: #e8e9f1;
  --muted: #9aa0b3;
  --border: rgba(255, 255, 255, 0.08);
  --btn: #2a2f4a;
  --btnHover: #343b5f;
  --accent: #6aa6ff;
  --danger: #ff5d5d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #1a1f3a 0%, var(--bg) 50%);
  color: var(--text);
}

.container {
  max-width: 1400px;
  padding: 18px;
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 6px 0;
  font-size: 22px;
  font-weight: 800;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.panelHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.panel h2 {
  margin: 0;
  font-size: 14px;
  color: #d6d8e6;
  letter-spacing: 0.2px;
}

textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  outline: none;
  line-height: 1.35;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: #fff;
  color: #333;
  width: 90%;
  max-width: 1200px;
  height: 90%;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 15px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
}

/* Mail Content Reset within Modal */
.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.modal-body .mail-text-content {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 14px;
  line-height: 1.5;
}

.actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
}

.btn:hover {
  background: var(--btnHover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: rgba(106, 166, 255, 0.35);
}

.btn.danger {
  border-color: rgba(255, 93, 93, 0.35);
}

.grid {
  display: grid;
  grid-template-columns: 320px 420px 1fr;
  gap: 14px;
}

.list {
  height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.item.active {
  outline: 2px solid rgba(106, 166, 255, 0.35);
  outline-offset: -2px;
}

.item .title {
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer {
  height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
}

.log {
  height: 180px;
  overflow: auto;
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .list,
  .viewer {
    height: 320px;
  }
}