* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 1.5rem 2rem;
  gap: 1rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.5rem;
}

.message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: #2563eb;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: white;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.message-timestamp {
  display: block;
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 0.25rem;
}

.message.thinking {
  color: #6b7280;
  font-style: italic;
}

.message-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

textarea#message-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  resize: none;
  outline: none;
}

textarea#message-input:focus {
  border-color: #2563eb;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e5e7eb;
  color: #1f2937;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: #6b7280;
  max-width: 400px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.memo-panel {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.memo-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.memo-actions {
  display: flex;
  gap: 0.5rem;
}

.memo-content {
  padding: 1.5rem;
  overflow-y: auto;
  line-height: 1.6;
}

.memo-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}

.memo-content h3:first-child {
  margin-top: 0;
}

.memo-content .field-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.memo-content .field-label {
  color: #6b7280;
  font-size: 0.9rem;
}

.memo-content .field-value {
  color: #1f2937;
}

.memo-content ul {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.25rem;
}

.memo-content .status-pill {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-pill.green {
  background: #d1fae5;
  color: #065f46;
}

.status-pill.yellow {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.red {
  background: #fee2e2;
  color: #991b1b;
}

.memo-content .item-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.memo-content .item-card .item-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.memo-content .item-card .item-meta {
  font-size: 0.85rem;
  color: #6b7280;
}

.error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0.5rem 0;
}
