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

body {
  background: #f7f7f7;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
}

main {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #7c3aed;
}

textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #ffffff;
  color: #1a1a1a;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus {
  border-color: #555;
}

textarea[readonly] {
  background: #fafafa;
  color: #333;
  cursor: default;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

button {
  padding: 0.625rem 1.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  background: #7c3aed;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) {
  background: #6d28d9;
}

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

#error-msg {
  font-size: 0.875rem;
  color: #c0392b;
  direction: rtl;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem 0.5rem;
  font-size: 0.8rem;
  color: #999;
}

#history-btn {
  padding: 0;
  background: none;
  color: #999;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

#history-btn:hover {
  color: #7c3aed;
  background: none;
}

#history-section {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

#history-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.75rem;
}

#history-table-wrap {
  overflow-x: auto;
}

#history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#history-table th,
#history-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e0e0e0;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  max-width: 260px;
}

#history-table th {
  background: #f3f0ff;
  color: #7c3aed;
  font-weight: 600;
}

#history-table tr:nth-child(even) td {
  background: #fafafa;
}
