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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #222;
}

/* 入力エリア */
.input-area {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

#colorPicker {
  width: 52px;
  height: 44px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
  flex-shrink: 0;
}

#colorCode {
  width: 100px;
  font-family: monospace;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
  flex-shrink: 0;
}

#colorCode:focus {
  border-color: #4a90d9;
}

#colorName {
  flex: 1;
  min-width: 120px;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  outline: none;
}

#colorName:focus {
  border-color: #4a90d9;
}

#addBtn {
  width: 100%;
  padding: 12px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#addBtn:hover {
  background: #357abd;
}

/* パレットヘッダー */
.palette-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#colorCount {
  font-size: 0.9rem;
  color: #666;
}

#clearBtn {
  font-size: 0.85rem;
  padding: 6px 12px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#clearBtn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
}

/* パレット */
.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.color-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  position: relative;
}

.color-swatch {
  height: 90px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.color-swatch:hover {
  opacity: 0.9;
}

.color-info {
  padding: 8px 10px;
}

.color-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.color-hex {
  font-family: monospace;
  font-size: 0.8rem;
  color: #888;
  cursor: pointer;
}

.color-hex:hover {
  color: #4a90d9;
}

.delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.color-card:hover .delete-btn {
  opacity: 1;
}

/* トースト */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* スマホ対応 */
@media (max-width: 480px) {
  h1 {
    font-size: 1.3rem;
  }

  .palette {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }

  .delete-btn {
    opacity: 1;
  }
}
