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

:root {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --surface-hover: #3a3a3a;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #4a9eff;
  --accent-hover: #3a8eef;
  --body-fill: #3d3d3d;
  --body-stroke: #555;
  --body-hover: #4a9eff;
  --danger: #ff4a4a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  padding: 1rem 0;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Body Diagram */
.body-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.body-3d-container {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

/* 3D Body Canvas */

.hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Notes Section */
.notes-section {
  flex: 1;
}

.notes-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.data-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.data-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.data-actions button {
  flex: 1;
}

.data-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

.notes-controls input,
.notes-controls select {
  flex: 1;
  min-width: 120px;
  padding: 0.75rem;
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.notes-controls input:focus,
.notes-controls select:focus {
  outline: none;
  border-color: var(--accent);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.note-card:hover {
  background: var(--surface-hover);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.note-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.note-part {
  font-weight: 600;
  color: var(--accent);
  text-transform: capitalize;
}

.note-status {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
}

.note-status--ongoing {
  color: #f5b35c;
  border: 1px solid rgba(245, 179, 92, 0.4);
}

.note-status--resolved {
  color: #7fe29e;
  border: 1px solid rgba(127, 226, 158, 0.4);
}

.note-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.note-submeta {
  margin-top: 0.35rem;
}

.note-duration {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.note-text {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}

.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text);
}

.icon-button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-button:hover {
  color: var(--text);
}

.modal-content h2 {
  font-size: 1.25rem;
  margin: 0;
}

.modal-content input[type="date"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 0.75rem;
}

.modal-content input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-content textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}

.modal-content textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.note-display-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.note-display-date {
  font-size: 0.9rem;
}

.note-display-duration {
  font-size: 0.75rem;
}

.note-display-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-modal-help {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.data-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--surface-hover);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  resize: vertical;
  min-height: 160px;
}

.data-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.data-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.1rem;
  margin-top: 0.5rem;
}


.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-actions-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.modal-actions-row .spacer {
  flex: 1;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
  flex: 1;
  padding: 0.875rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-secondary:hover {
  background: #4a4a4a;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #e03a3a;
}

.btn-success {
  background: #2ecc71;
  color: white;
}

.btn-success:hover {
  background: #27b864;
}

/* Responsive */
@media (min-width: 600px) {
  main {
    flex-direction: row;
    align-items: flex-start;
  }

  .body-section {
    position: sticky;
    top: 1rem;
    width: 45%;
  }

  .body-3d-container {
    max-width: 500px;
  }

  .notes-section {
    width: 55%;
  }
}
