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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f0f4f8;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
}

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  padding: 24px;
}

/* Index page */
.index-card {
  margin-top: 15vh;
  text-align: center;
}

.index-card h1 {
  font-size: 28px;
  color: #1a73e8;
  margin-bottom: 8px;
}

.subtitle {
  color: #666;
  margin-bottom: 24px;
}

#query-form {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

#email-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

#email-input:focus {
  border-color: #1a73e8;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #1a73e8;
  color: #fff;
}

.btn-primary:hover {
  background: #1557b0;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  background: #e8eef3;
  color: #333;
}

.btn-sm:hover {
  background: #d0dbe5;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Inbox header */
.inbox-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.inbox-header h1 {
  font-size: 22px;
  color: #1a73e8;
}

.email-badge {
  font-size: 14px;
  color: #555;
  background: #e8eef3;
  padding: 4px 10px;
  border-radius: 12px;
  word-break: break-all;
}

.toolbar {
  margin-bottom: 16px;
}

/* Mail list */
.mail-list {
  border-top: 1px solid #eee;
}

.mail-item {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.mail-item:hover {
  background: #f8fafc;
}

.mail-subject {
  font-size: 15px;
  font-weight: 500;
  color: #1a73e8;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #888;
}

.mail-from {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 14px;
  color: #666;
}

/* Detail page */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #1a73e8;
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  text-decoration: underline;
}

.mail-headers {
  border-bottom: 1px solid #eee;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.header-row {
  display: flex;
  padding: 4px 0;
  font-size: 14px;
}

.header-label {
  width: 60px;
  flex-shrink: 0;
  color: #888;
  font-weight: 500;
}

.header-value {
  color: #333;
  word-break: break-all;
}

.mail-body-iframe {
  width: 100%;
  min-height: 400px;
  border: none;
}

.mail-body-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.7;
  color: #444;
}

/* States */
.loading, .empty, .error {
  text-align: center;
  padding: 40px 16px;
  color: #888;
  font-size: 15px;
}

.error {
  color: #d93025;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 12px 8px;
  }

  .card {
    padding: 16px;
  }

  #query-form {
    flex-direction: column;
  }

  .inbox-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mail-meta {
    flex-direction: column;
    gap: 2px;
  }

  .header-row {
    flex-direction: column;
  }

  .header-label {
    width: auto;
    margin-bottom: 2px;
  }
}
