:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --card: #ffffff;
  --border: #e0e0e3;
  --text: #1a1a1e;
  --muted: #6b6b74;
  --accent: #3457d5;
  --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --card: #202024;
    --border: #333338;
    --text: #f0f0f2;
    --muted: #9a9aa2;
    --accent: #7a93ff;
    --danger: #ff6b5b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px 16px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

input[type="email"],
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 10px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.secondary {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 4px 0 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.message-cell {
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row {
  cursor: pointer;
}

.message-row:hover {
  background: var(--bg);
}

.details-row td {
  border-bottom: 1px solid var(--border);
  padding: 0 6px 10px;
}

.details-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.code {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.message-cards,
.card-pager {
  display: none;
}

@media (max-width: 600px) {
  .messages-table {
    display: none;
  }

  .message-cards {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    scrollbar-width: none;
  }

  .message-cards::-webkit-scrollbar {
    display: none;
  }

  .message-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
  }

  .message-card .message-cell {
    max-width: none;
  }

  .card-pager {
    display: block;
    text-align: center;
    margin-top: 8px;
  }
}

.identifier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.identifier-row:last-child {
  border-bottom: none;
}

.add-identifier-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 12px;
}

.add-identifier-form input,
.add-identifier-form select,
.add-identifier-form button {
  height: 42px;
  margin-bottom: 0;
}

.add-identifier-form input {
  flex: 1;
}

.add-identifier-form select {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
