@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-root: #09090b;
  --bg-surface: #121214;
  --bg-elevated: #18181b;
  --bg-hover: #222228;
  --border: #27272a;
  --border-accent: #3b3b40;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-soft: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.10);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.10);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99, 102, 241, 0.04), transparent);
  background-attachment: fixed;
}

/* ---------------------------------- Layout ---------------------------------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ---------------------------------- Header ---------------------------------- */
header {
  text-align: center;
  margin-bottom: 36px;
}

header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e0e7ff 0%, #818cf8 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

header p {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* ---------------------------------- Toolbar ---------------------------------- */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.toolbar select {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2371717a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 18px;
  padding-right: 36px;
  transition: all var(--transition);
}

.toolbar select:hover {
  border-color: var(--border-accent);
}

.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toolbar button {
  padding: 10px 14px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.toolbar button:active {
  transform: scale(0.97);
}

.toolbar button.danger {
  color: var(--red);
  border-color: transparent;
  background: var(--red-bg);
}

.toolbar button.danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* ---------------------------------- New Inbox Box ---------------------------------- */
.new-box {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 10px;
  animation: slideDown 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.new-box.hidden {
  display: none;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.new-box input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-root);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--transition);
}

.new-box input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.new-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.new-box button {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.new-box button:active {
  transform: scale(0.97);
}

#createCustomBtn {
  background: var(--green);
  color: #000;
}

#createCustomBtn:hover {
  background: #16a34a;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.25);
}

#createRandomBtn {
  background: var(--accent);
  color: #fff;
}

#createRandomBtn:hover {
  background: var(--accent-soft);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ---------------------------------- Panel ---------------------------------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  letter-spacing: -0.2px;
}

.panel-head span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 12px;
  background: var(--bg-hover);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ---------------------------------- Message List ---------------------------------- */
.message-list {
  min-height: 260px;
}

.message-item {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: default;
}

.message-item:last-child {
  border-bottom: none;
}

.message-item:hover {
  background: var(--bg-hover);
}

.message-item .message-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.message-item .message-meta::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.message-item strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.message-item p {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.7;
}

/* ---------------------------------- Empty States ---------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
  filter: grayscale(1);
}

.empty-state .title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.empty-state .sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.6;
}

/* ---------------------------------- Footer ---------------------------------- */
footer {
  text-align: center;
  padding: 32px 0 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
  letter-spacing: 0.2px;
}

footer a span {
  color: var(--accent-soft);
  font-weight: 600;
  transition: color var(--transition);
}

footer a:hover {
  color: var(--text-secondary);
}

footer a:hover span {
  color: var(--accent);
}

/* ---------------------------------- Toast ---------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: all;
}

.toast.fadeout {
  animation: toastOut 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* ---------------------------------- Responsive ---------------------------------- */
@media (max-width: 560px) {
  .app {
    padding: 20px 12px 60px;
  }

  header h1 {
    font-size: 28px;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
  }

  .toolbar select {
    width: 100%;
    flex: none;
  }

  .toolbar button {
    padding: 8px 10px;
    font-size: 11px;
  }

  .new-box {
    flex-direction: column;
    padding: 14px;
  }

  .panel-head {
    padding: 12px 14px;
  }

  .message-item {
    padding: 14px 14px;
  }
}
