* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.container {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 16px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 8px 0;
  font-size: 2.2rem;
}

.page-header p {
  margin: 0;
  color: #6b7280;
  font-size: 1rem;
}

.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.input-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #374151;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.35;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
  outline: none;
}

.note-upload-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.note-upload-wrapper:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.note-upload-wrapper textarea {
  width: auto;
  min-width: 0;
  min-height: 48px;
  height: 48px;
  padding: 12px 14px;
  border: none;
  border-radius: 0;
  resize: none;
  overflow: hidden;
  box-shadow: none;
}

.note-upload-button {
  width: 56px;
  min-width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  align-self: stretch;
  border-left: 1px solid #d1d5db;
  background: #f9fafb;
  cursor: pointer;
  user-select: none;
}

.note-upload-button:hover {
  background: #f3f4f6;
}

.camera-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.image-count-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #2563eb;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-upload-wrapper.has-images .note-upload-button {
  background: #eff6ff;
}

.visually-hidden-file-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:hover {
  opacity: 0.95;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn-delete {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-delete:hover {
  background: #fef2f2;
  opacity: 1;
}

.btn-toggle {
  background: transparent;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  min-width: 40px;
}

.btn-toggle:hover {
  background: #f9fafb;
  opacity: 1;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-row {
  padding: 14px 0;
  border-bottom: 1px solid #e5e7eb;
}

.item-row:last-child {
  border-bottom: none;
}

.item-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.item-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.item-name {
  font-size: 1.05rem;
  font-weight: 700;
  word-break: break-word;
}

.item-meta {
  font-size: 0.92rem;
  color: #6b7280;
}

.item-details {
  margin-top: 14px;
  padding: 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.detail-block + .detail-block {
  margin-top: 16px;
}

.detail-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 8px;
}

.detail-note {
  margin: 0;
  color: #111827;
  line-height: 1.5;
  white-space: pre-wrap;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.detail-image {
  width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  object-fit: cover;
}

.empty-state {
  margin: 0;
  color: #6b7280;
  font-style: italic;
}

.list-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

.error-box {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 10px;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .add-form {
    grid-template-columns: 1fr;
  }

  .item-main-row {
    align-items: flex-start;
  }

  .item-actions {
    margin-left: 8px;
  }

  .list-actions {
    justify-content: stretch;
  }

  .list-actions .btn {
    width: 100%;
  }
}