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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.status {
  font-size: 1.1rem;
  text-align: center;
  padding: 10px 20px;
  border-radius: 8px;
  background: #16213e;
}

.status.connected {
  background: #0a3d2a;
  color: #4ade80;
}

.status.error {
  background: #3d0a0a;
  color: #f87171;
}

.timer {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  color: #a0a0b8;
}

#qr-container {
  background: white;
  padding: 16px;
  border-radius: 12px;
  display: inline-block;
}

#qr-container canvas {
  display: block;
}

.message-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 100px;
  padding: 14px;
  font-size: 18px;
  border: 2px solid #0f3460;
  border-radius: 8px;
  background: #16213e;
  color: #e0e0e0;
  resize: vertical;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

button {
  min-height: 48px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #0f3460;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #1a4a8a;
}

button:active {
  background: #0a2540;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn {
  width: 100%;
  background: #3b82f6;
  font-size: 1.1rem;
}

.send-btn:hover {
  background: #2563eb;
}

.history {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: #16213e;
  border-radius: 8px;
  word-break: break-word;
}

.history-item.sent {
  border-left: 3px solid #3b82f6;
}

.history-item.received {
  border-left: 3px solid #4ade80;
}

.history-item .text {
  flex: 1;
  font-size: 18px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.history-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 4px;
}

.copy-btn {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.copy-btn.copied {
  background: #0a3d2a;
}

.hidden {
  display: none !important;
}

.expire-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 100;
}

.expire-overlay h2 {
  font-size: 1.5rem;
}

.expire-overlay button {
  font-size: 1.2rem;
  padding: 16px 32px;
}

/* Tesla screen: larger fonts for readability */
.tesla-view .history-item .text {
  font-size: 24px;
}

/* Phone optimizations */
@media (max-width: 480px) {
  .container {
    padding: 16px;
  }

  h1 {
    font-size: 1.3rem;
  }

  textarea {
    font-size: 16px;
  }
}
